- 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
- Language for XML documents. XSLT stands for XSL Transformations.
- In this tutorial you will learn how to use XSLT to transform XML
- Documents into other formats, like XHTML. XSLT which gives good graphical generated reports.
Steps for generating reports:
Step 1:Ant should be installed ,If it is not installed ,By using
Step 2: Download the Xslt .
Step 3: After UnZip ,You Will get
Step 4: Now copy the Saxon jar add the jars files to your project through build path from the lib folder.
Step 5:Modify your build.xml of ant and add the following target to it.
<?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>
Step 6:Modify the Testng xml
<?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 -->
Step:7
Open this report in the browser.
The XSLT Report looks like this.

.png)
.png)
No comments:
Post a Comment