Issue with generating testng XSLT report from build.xml file

63 views
Skip to first unread message

santosh M

unread,
Oct 10, 2014, 7:53:21 AM10/10/14
to seleniu...@googlegroups.com
Hi Selenium users,

Currently I am able to compile, run the script through testng build.xml from cmd, but not able to generate testNg XSLT reports from build.xml.

Below build.xml file I am using.

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE project [
]>

<project name="MFPTestProject" basedir=".">
    <!-- ========== Initialize Properties =================================== -->
        <property environment="env"/>
        <property name="ws.home" value="${basedir}"/>
        <property name="test.dest" value="${ws.home}/build"/>
        <property name="test.src" value="${ws.home}/src"/>
        <property name="ws.jars" value="${basedir}/lib"/>
        <property name="browser" value="/usr/bin/google-chrome"/>

        <!-- ====== For setting the classpath ====  -->
        <target name="setClassPath" unless="test.classpath">
            <path id="classpath_jars">
                <fileset dir="${ws.jars}" includes="*.jar"/>
            </path>
             <pathconvert pathsep=":" property="test.classpath" refid="classpath_jars"/>
        </target>
        <!-- ============ Initializing other stuff ===========  -->
        <target name="init" depends="setClassPath">
        <taskdef name="testng" classpath="${test.classpath}" classname="org.testng.TestNGAntTask" />
        </target>
        <!-- cleaning the destination folders -->
        <target name="clean">
            <delete dir="${test.dest}"/>
        </target>
        <!-- target for compiling the java files -->
        <target name="compile" depends="init, clean" >
            <delete includeemptydirs="true" quiet="true">
                <fileset dir="${test.dest}" includes="**/*"/>
            </delete>
            <echo message="making directory..."/>
            <mkdir dir="${test.dest}"/>

            <echo message="compiling..."/>
            <javac
                debug="true"
                destdir="${test.dest}"
                srcdir="${test.src}"
                target="1.6"
                classpath="${test.classpath}"
                includeantruntime="true"
            >
            </javac>
          </target>
        <!-- run -->
        <target name="run" depends="compile">
            <testng classpath="${test.classpath}:${test.dest}" suitename="InitialTestSuite">
               <xmlfileset dir="src/com/iFocus/mfp/triggerexecution/" includes="Websites.xml"/>
            </testng>
        </target>
        <!--  ========== Generating reports using XSLT utility ==============    -->
        <target name="testng-xslt-report">
                    <delete dir="${basedir}/ReportFiles">
                    </delete>
                    <mkdir dir="${basedir}/ReportFiles">
                    </mkdir>
                    <echo message="Generating XSLT report..."/>
            <xslt in="${basedir}/test-output/testng-results.xml" style="${basedir}/configurations/testng-results.xsl" out="${basedir}/ReportFiles/MFP_AutomationReport.html">
                 <param expression="${basedir}/ReportFiles/" 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_jars">
                 </classpath>
             </xslt>
            <echo message="XSLT report generated"/>
         </target>
        <!-- ====== Fetch the generated report's index.html, open a chrome browser and show the report.========= -->
         <target name="runAndViewReport" depends="run, testng-xslt-report">
                <exec executable="${browser}" spawn="yes">
               <arg line="'${basedir}/ReportFiles/MFP_AutomationReport.html'" />
              </exec>
            <echo message="Opening up the report in a browser..."/>
         </target>
</project>

Steps followed:-
1. ant compile------>Successful
2. ant run---->Successful
3. ant testng-xslt-report---->Failed

Facing below issue on running "ant testng-xslt-report"
build.xml:82: Reference classpath_jars not found.

The line number 82 refers to below line in build.xml file.

            <xslt in="${basedir}/test-output/testng-results.xml" style="${basedir}/configurations/testng-results.xsl" out="${basedir}/ReportFiles/MFP_AutomationReport.html">

Any suggestion/inputs would be appreciated...

Thanks&Regards,
Matti

Serguei Kouzmine

unread,
Oct 19, 2014, 7:46:42 PM10/19/14
to seleniu...@googlegroups.com
Hello S

Please move the
classpath definition
for classpath_jars

<path id=
"
classpath_jars"
<pathelement location="path_to_your.jar"/>


</path>

 - use your file sets after it starts to work...
to the top of the build file

as described on
http://www.coderanch.com/t/109038/tools/set-classpath-ant
http://stackoverflow.com/questions/5104507/how-can-i-specify-the-path-of-a-jar-in-an-ant-buildfile
 - the target dependency between testng-xslt-report and setClassPath  may not be to rely upon

santosh M

unread,
Oct 20, 2014, 7:45:08 AM10/20/14
to seleniu...@googlegroups.com
Thanks for reply..

This issue is fixed by adding depends on generating XSLT report. Please refer below line of code..

<target name="testng-xslt-report" depends="run">
               <delete dir="${basedir}/ReportFiles">
               </delete>
               <mkdir dir="${basedir}/ReportFiles">
               </mkdir>
               <echo message="Generating XSLT report..."/>
      <xslt in="${basedir}/test-output/testng-results.xml" style="${basedir}/configurations/testng-results.xsl" out="${basedir}/ReportFiles/MFP_AutomationReport.html">
            <param expression="${basedir}/ReportFiles/" 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_jars">
            </classpath>
        </xslt>
    <echo message="XSLT report generated"/>
    </target>

Thanks&Regards,
Matti

--
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/As3nWwFK8bs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/0cce7871-651a-4e56-9908-32135f2a4424%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Sudheer Qa

unread,
May 26, 2015, 4:56:54 AM5/26/15
to seleniu...@googlegroups.com
The resolution for this issue is explained clearly in this blogger. 

Please have a look at it.. 

http://tobeanexpert.blogspot.in/2015/05/generate-xslt-report-ant-buildxml.html

I hope this will helps you.. 

Thanks, 
sudheer.
Reply all
Reply to author
Forward
0 new messages