We usually depend on Testng for generating the default reports. Apart from that we use XSLT reports as well to generate PIE Charts based on Failed,Passed,Skipped Testcases.
During this process we face lot of issues. Few of the most commonly observed issues are as follows:
[xslt] Unknown file:23:146: Fatal Error! Could not find function: if
[xslt] : Fatal Error! Fatal error during transformation Cause: Fatal error during transformation
In order to resolve this we have to follow the below steps. At every step we will check and see whether issues are resolved or not.
Step 1 :
Make sure the build.xml file contains ‘SaxonLiaison’ processor added.
Example:
1 |
<xslt in="${outputdir}/test-output/testng-results.xml" style="${basedir}/testng-results.xsl" out="${outputdir}/testng-xslt/index.html" processor="SaxonLiaison"> |
Re-run the build.xml and verify the issue is resolved. If still the issue is not resolved try performing Step2.
Step 2 :
Make sure the following jars added to the lib folder and Project build path as well.
saxon-8.7.jar -> Link to download the saxon jar-> Click here
SaxonLiaison.jar ->Link to download the SaxonLiaison jar-> Click here
guice-3.0.jar->Link to download guice-3.0.jar-> Click here
Re-run the build.xml and verify the issue is resolved. If the issue is not resolved goto Step3.
Step 3:
Refer to the build.xml mentioned below .Try to do necessary changes.
Re-run the build.xml and verify the issue is resolved.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
<project name="TestNG" default="makexsltreport" basedir="."> <tstamp> <format property="currentExcecution" pattern="dd_MM_yyyy_hh_mm_ss_aa" locale="en,US" /> </tstamp> <property name="LIB" value="${basedir}/lib" /> <property name="BIN" value="${basedir}/bin" /> <property name="src" value="src" /> <property name="build" value="build" /> <property name="libdir" value="lib" /> <property name="outputdir" value="${basedir}/${currentExcecution}" /> <taskdef name="testng" classname="org.testng.TestNGAntTask"> <classpath> <pathelement location="lib/testng-6.8.5.jar" /> </classpath> </taskdef> <path id="master-classpath"> <pathelement location="${BIN}" /> <fileset dir="${LIB}"> <include name="**/*.jar" /> </fileset> </path> <!-- set global properties for this build --> <path id="classpath.test"> <fileset dir="${libdir}" includes="*.jar" /> <pathelement location="${build}" /> <pathelement location="${srcdir}" /> </path> <!-- clean --> <target name="clean" description="clean up"> <delete dir="${build}" /> </target> <!-- init --> <target name="init" depends="clean"> <mkdir dir="${build}" /> </target> <!-- compile --> <target name="compile" depends="init" description="compile the source "> <javac srcdir="${src}" destdir="${build}" classpathref="classpath.test"> </javac> </target> <!-- run --> <target name="run" depends="compile"> <mkdir dir="${outputdir}"> </mkdir> <testng outputDir="${outputdir}/test-output/" classpathref="classpath.test" haltonfailure="false"> <xmlfileset dir="${src}" includes="testng.xml" /> </testng> </target> <target name="makexsltreport" depends="run"> <delete dir="${basedir}/${currentExecution}/testng-xslt"> </delete> <mkdir dir="${outputdir}/testng-xslt"> </mkdir> <xslt in="${outputdir}/test-output/testng-results.xml" style="${basedir}/testng-results.xsl" out="${outputdir}/testng-xslt/index.html" processor="SaxonLiaison"> <param expression="${outputdir}/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="master-classpath"> </classpath> </xslt> </target> </project> <!-- <target name="package" depends="compile" description="generate the distribution"> <jar jarfile="${build}/TestNG.jar" basedir="${build}" /> </target> --> |
Step 4:
Re-verify the testng-results.xsl available in the project directory by downloading from the link Click here .Try to do necessary changes.
Re-run the build.xml and verify all the issues are resolved.
If even after the issues are not resolved, please refer to the directory structure mentioned in the below screenshot.
Resolving “No suites, classes, methods or jar file was specified” in Ant TestNG
Make sure the testng.xml is available in the src folder as mentioned in the image below. Refer to the point1.
Pingback: extent reports in selenium webdriver - TotalQA