We will see how we can generate the following report[screenshot] after done the required steps:
Things Required:
Eclipse IDE –
If you are new, please follow this link
Create 4 .java files such a way that: 2 successful, 1 skipped and 1 failed on run
package tcs; import org.testng.annotations.Test; public class tc1 { @Test public void method1(){ System.out.println("tc1: testcase1");} }
testcase2: pass
package tcs; import org.testng.annotations.Test; public class tc2 { @Test public void method1(){ System.out.println("tc2: testcase2");} }
testcase3: failed
package tcs; import org.testng.annotations.Test; public class tc3 { @Test public void method1(){ int i = 5/0; System.out.println(i+"testcase3"); } }
testcase4: skipped
package tcs; import org.testng.SkipException; import org.testng.annotations.Test; public class tc4 { @Test public void method1(){ throw new SkipException("skipped: testcase4");} }
testng.xml –
Right click on the project, select “TestNG” and click on “Convert to TestNG” to create the testng.xml and place under project folder.
ANT build –
Environmental setup for ANT:
Add / Edit System variables “path” as: append the “apache ANT” extracted folder path as value.
path = C:apache-ant-1.9.4bin (consider the extracted file is on C: drive)
build.xml and testng-results.xsl: Download from here, and place under your project folder.
How to Run the build.xml:
2) Even we can run the build.xml from the command prompt:
Customized html report page – open from folder /XSLT_Reports/output/index.html to see the report as shown in the beginning.