Selenium result report + testNG + ANT build.xml

In this post, we will see how to convert testng report (index.html) to a more readable/emailable report by using ANT build and build.xml.
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

testcase1: pass

testcase2: pass

testcase3: failed

testcase4: skipped



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 –
Download the latest zip file from here,
Extract and keep it in a easily accessible folder and follow below steps:
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)

To know how to update environmental variable, click here.
build.xml and testng-results.xsl: Download from here, and place under your project folder.

How to Run the build.xml:
1) After all the above setup is done, Right click on the build.xml and select “Run As”, click on “Ant Build…”, a dialog appears to select and execute the required targets.
2) Even we can run the build.xml from the command prompt:
On the current directory (location, where your project resides), Hold “Shift key” and Right click on the directory and select option “Open command window here” and type the following command to execute build.xml or tests
            let’s say my project is under c:
            c:myproject > ant -buildfile build.xml and press Enter (this will execute the default target)
            To execute particular target (let’s say I have a target “GenerateReport”
             c:myproject > ant -buildfile build.xml GenerateReport and click on Enter

Customized html report page – open from folder /XSLT_Reports/output/index.html to see the report as shown in the beginning.

Content posted is based on learning or working experience,
Share the post with others if find useful,
Any queries?, leave comments or discuss on our, Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *