web analytics
Google + RSS Feed

Generate Interactive reports Using TestNG+ANT +XSLT In Selenium


January 5, 2014 by admin

Important Links



XSLT stands for XML (Extensible Markup Language) Stylesheet Language for Transformations.
XSLT gives interactive(user friendly) reports with “Pie Chart”; but only on TestNG framework. It is better compared to ReportNG and ordinary TestNG reports. Its uses the pure XSL for report generation and Saxon as an XSL2.0 implementation.

XSLT = XSL Transformations

Steps to Generate testng-xslt report:

1. Download testmg-xslt.zip
2. Unzip and copy the testng-results.xsl from the testng-xslt folder(testng-xslt-1.1\src\main\resources) to your own project folder.
3. Now copy the saxon library from (testng-xslt-1.1\lib\saxon-8.7.jar)to your project lib folder.
4. Modify your build.xml of ant and add the following target to it.

Build.xml Configuration

<?xml version=”1.0″ encoding=”UTF-8″?>

<property name=”src.dir” value=”src” />
<property name=”lib.dir” value=”lib” />
<property name=”log.dir” value=”logs” />
<property name=”build.dir” value=”build” />
<property name=”classes.dir” value=”classes” />
<property name=”reports.dir” value=”reports” />
<property name=”testNG.report” value=”${reports.dir}/TestNG” />
<property name=”suite.dir” value=”suite” />
<!– Class-Path –>
<path id=”classpath”>
<pathelement location=”${classes.dir}”/>
<fileset dir=”${lib.dir}” includes=”*.jar”/>
<!– Delete directories that are not needed –>
<target name=”delete-dir” >
<delete dir=”${build.loc}”/>
<delete dir=”${reports.dir}”/>
<delete dir=”${classes.dir}”/>
<echo> /* Deleted existing Compiled Directory Classes */ </echo>
<!– Create Directories –>
<target name=”create-source-dir” depends=”delete-dir”>
<mkdir dir=”${classes.dir}”/>
<mkdir dir=”${reports.dir}”/>
<mkdir dir=”${testNG.report}”/>
<echo> /* Created Directories */ </echo>
<!– Compiling Tests –>
<target name=”compile-classes” depends=”create-source-dir”>
<javac destdir=”${classes.dir}” includeantruntime=”false” debug=”true” srcdir=”${src.dir}”>
<classpath refid=”classpath”/>
<echo> /* Compiled Directory Classes */ </echo>
<!– Running Tests and TestNG report generation –>
<target name=”testNGreport” depends=”compile-classes”>
<taskdef resource=”testngtasks” classpathref=”classpath”/>
<testng classpathref=”classpath” outputDir=”${testNG.report}” haltOnfailure=”false”>
<xmlfileset dir=”.” includes=”${suite.dir}/TestNG.xml” />
<echo> /* Run Directory Classes */ </echo>

<target name=”testng-xslt-report”>
<delete dir=”${basedir}/testng-xslt”>
<mkdir dir=”${basedir}/testng-xslt”>
<xslt in=”${basedir}/reports/TestNG/testng-results.xml” style=”${basedir}/testng-results.xsl” out=”${basedir}/testng-xslt/index.html”>
<param expression=”${basedir}/testng-xslt/” name=”testNgXslt.outputDir” />

<param expression=”true” name=”testNgXslt.sortTestCaseLinks” />

<param expression=”FAIL,SKIP,PASS,CONF,BY_CLASS” name=”testNgXslt.testDetailsFilter” />

<param expression=”true” name=”testNgXslt.showRuntimeTotals” />

<classpath refid=”classpath”>


5. Create TestNG.xml file in your project with the following script for TestNG execution.
<?xml version=”1.0″ encoding=”UTF-8″?>
<suite name=”Suite” parallel=”false”>
  <test name=”Test”>
      <class name=”package.classname”/>
  </test> <!– Test –>
</suite> <!– Suite –>
6. Now, try to run the command.
Navigate to Project Location from command prompt


  1. laxmi says:


    Are the results generated PASSED: FAILED: in console of eclipse are the one which makes the results green or red in xslt reports.

  2. admin says:

    The above code results was passed and Passed results comes in GREEN color in XSLT reports.

Leave a Reply

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

six × = 30

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Recent Posts