2
我使用TestNG + ant +批處理文件來運行硒webddriver testscripts,但emailreport很直觀,我想創建xslt。我找到了說明創建xslt報告而沒有批處理可運行文件的教程。但我也需要批處理文件。生成xslt報告
在這裏,我貼我的build.xml文件
<project name="Planobot_Final" default="run" basedir=".">
<property name="source" value="./src" />
<property name="lib" value="./Lib" />
<property name="build_root" value="./Maheswar/" />
<property name="build_child" value="${build_root}/Test-Data" />
<property name="dist_dir" value="./dist" />
<property name="jar_name" value="Planobot.jar" />
<property name="testng_output.dir" value="${basedir}/testng_output" />
<!-- Clean -->
<target name="clean">
<delete dir="${build_root}" />
<delete dir="${build_child}" />
<delete dir="${dist_dir}" />
<delete dir="${basedir}/testng-xslt" />
<delete dir="${testng_output.dir}" />
</target>
<!-- Init -->
<target name="init">
<mkdir dir="${build_root}" />
<mkdir dir="${build_child}" />
<mkdir dir="${dist_dir}" />
<mkdir dir="${basedir}/testng-xslt" />
<mkdir dir="${testng_output.dir}" />
</target>
<!-- Compile -->
<target name="compile">
<javac srcdir="${source}" destdir="${dist_dir}">
<classpath>
<fileset dir="${lib}">
<include name="**/*.jar" />
</fileset>
</classpath>
</javac>
</target>
<!-- Default -->
<target name="run">
<antcall target="clean" />
<antcall target="init" />
<antcall target="compile" />
<antcall target="jar" />
<antcall target="deploy" />
</target>
<!-- Jar -->
<target name="jar">
<jar destfile="${build_root}/${jar_name}" basedir="${dist_dir}">
<manifest>
<attribute name="Main-Class" value="org.testng.TestNG" />
<attribute name="Class-Path" value="/lib/*.*" />
<attribute name="Implementation-Version" value="6.6beta-201206151641" />
</manifest>
<fileset dir="${dist_dir}" />
<fileset file="${basedir}\testng.xml" />
</jar>
</target>
<!-- Deploy -->
<target name="deploy">
<copydir dest="${build_child}" src="${basedir}/Test-Data" />
<copydir dest="${build_root}/lib" src="${basedir}/Lib">
</copydir>
<!--<copyfile dest="${build_root}/lib" src="${build_root}/${jar_name}"/> -->
<copy file="${build_root}/${jar_name}" todir="${build_root}/lib">
</copy>
<copy file="./Final.bat" todir="${build_root}">
</copy>
<copy file="./testng.xml" todir="${build_root}">
</copy>
</target>
<target name="xslt" depends="run">
<xslt in="${basedir}/testng_output/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="master-classpath">
</classpath>
</xslt>
</target>
也final.bat文件
echo Setting JAVA_HOME
set JAVA_HOME="C:\\Java\\jdk1.7.0"
echo setting PATH
set PATH="C:\\Java\\jdk1.7.0";%PATH%
echo Display java version
set BASELIBS="D:\\Planobot-KHFW\\Planobot_Test\\Maheswar\\lib"
::This is the planobotlog properties file.
::set JAVA_OPTIONS=-DconfDir=D:\Planobot-KHFW\Planobot_Test\Maheswar\Test-Data\Property
::set PropertyDirectory = "D:\\Planobot-KHFW\\Planobot_Test\\${app_root_dir}\\testArea\\Test-Data\\Property"
::Before running the batch delete the hardcodded value of confDir in all the testcases
::set JAVA_OPTIONS=PropDir=D:\Planobot-KHFW\Planobot_Test\${app_root_dir}\testArea\Test-Data\Property
`set CLASS_PATH=%BASELIBS%\\dom4j-1.6.1.jar;%BASELIBS%\\JSErrorCollector-0.4.jar;%BASELIBS%\\jxl.jar;%BASELIBS%\\log4j-1.2.14.jar;%BASELIBS%\\maven-eclipse-plugin-2.2.jar;%BASELIBS%\\poi-3.0.2-FINAL.jar;%BASELIBS%\\poi-3.9-20121203.jar;%BASELIBS%\\poi-examples-3.9-20121203.jar;%BASELIBS%\\poi-excelant-3.9-20121203.jar;%BASELIBS%\\poi-ooxml-3.9-20121203.jar;%BASELIBS%\\poi-ooxml-schemas-3.9-20121203.jar;%BASELIBS%\\poi-scratchpad-3.9-20121203.jar;%BASELIBS%\\saxon-8.7.jar;%BASELIBS%\\selenium-java-2.33.0.zip;%BASELIBS%\\selenium-server-standalone-2.33.0.jar;%BASELIBS%\\testng.jar;%BASELIBS%\\xmlbeans-2.3.0.jar;%BASELIBS%\\Planobot.jar;`
echo %BASELIBS%\\dom4j-1.6.1.jar
java -cp %CLASS_PATH% %JAVA_OPTIONS% org.testng.TestNG -testjar %BASELIBS%\\Planobot.jar -xmlpathinjar testng.xml
ant makexsltreports
@pause
但我不能得到XSLT報告,