我正在使用 TestNG + ant + 批处理文件来运行 selenium webddriver 测试脚本,但是 emailreport 很直观,我想创建 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 报告。,