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"?>
<project>
<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"/>
</path>
<!-- 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>
</target>
<!-- 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>
</target>
<!-- Compiling Tests -->
<target name="compile-classes" depends="create-source-dir">
<javac destdir="${classes.dir}" includeantruntime="false" debug="true" srcdir="${src.dir}">
<classpath refid="classpath"/>
</javac>
<echo> /* Compiled Directory Classes */ </echo>
</target>
<!-- 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" />
</testng>
<echo> /* Run Directory Classes */ </echo>
</target>
<target name="testng-xslt-report">
<delete dir="${basedir}/testng-xslt">
</delete>
<mkdir dir="${basedir}/testng-xslt">
</mkdir>
<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">
</classpath>
</xslt>
</target>
</project>
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"?>
<project>
<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"/>
</path>
<!-- 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>
</target>
<!-- 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>
</target>
<!-- Compiling Tests -->
<target name="compile-classes" depends="create-source-dir">
<javac destdir="${classes.dir}" includeantruntime="false" debug="true" srcdir="${src.dir}">
<classpath refid="classpath"/>
</javac>
<echo> /* Compiled Directory Classes */ </echo>
</target>
<!-- 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" />
</testng>
<echo> /* Run Directory Classes */ </echo>
</target>
<target name="testng-xslt-report">
<delete dir="${basedir}/testng-xslt">
</delete>
<mkdir dir="${basedir}/testng-xslt">
</mkdir>
<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">
</classpath>
</xslt>
</target>
</project>
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">
<classes>
<class name="package.classname"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
6. Now, try to run the command.
Navigate to Project Location from command prompt
ant testng-xslt-report
Results will be look like this:
Am using selenium webdriver (ANT+TestNG+Java).How do I save results of TestNG with time-stamp and build no.(testng-results-Build no:DD-MM-YYYY_HH-MM-SS.xml),without overwriting previous results. Could anyone share the build.xml code?
ReplyDeleteHi,
ReplyDeleteFrom eclipse when I try to build "build.xml" using ANT, the build is successful.
But when I tried the above code from cmd I get following error:
C:\Eclipse\SBC Regression\SBC>ant testng-xslt-report
Buildfile: C:\Eclipse\SBC Regression\SBC\build.xml
testng-xslt-report:
[delete] Deleting directory C:\Eclipse\SBC Regression\SBC\testng-xslt
[mkdir] Created dir: C:\Eclipse\SBC Regression\SBC\testng-xslt
BUILD FAILED
C:\Eclipse\SBC Regression\SBC\build.xml:52: input file C:\Eclipse\SBC Regression
\SBC\reports\TestNG\testng-results.xml does not exist
Total time: 0 seconds
C:\Eclipse\SBC Regression\SBC>