Thursday, June 20, 2013

Ant task for generating XSLT report

Once you are executed the test by TestNG or TestNG with Group, you can invoke the following ant target to generate xslt report.
 

 
 
  
   
   
  
 
Note: To work this above code you should have the following 2 jars in your class path:
SaxonLiaison.jar and saxon-8.7.jar 
In my example i have used a custom style which is specified in the "xslt_style/testng-results.xsl" file. After executing this target you will find your xslt report in "index.html" file which is in the "reports.xslt" directory specified in the ant property.

The report generated by testng with xslt looks something like the below image:


Ant task to run all tests by the specified group name

Following ant task shows us how to run all testng tests those are specified with the group "alltests" in the test classes. We can actually do this by two ways. 

Type-I(from testng suite) 
The following target runs all the tests with group "alltests". In this case it will search for all the tests that are specified with group "alltests" and only for the tests/classes/packages specified in the testng.xml(test suite) only. After executing the tests it creates the testng report in the "reprots.testng" directory specified in ant property.
 

 
 
  
   
  
 
Type-II(directly from the classes) 
The following target runs all the tests with group "alltests". In this case it will search for all the tests that compiled and there in the "classes" directory specified in the ant property. After executing the tests it creates the testng report in the "reprots.testng" directory specified in ant property.
 

 
 
  
   
   
   
  
 
The report generated by testng looks like the below snapshot: