我已经在 Eclipse 中自动使用 TestNg 框架,但我无法在最终的 index.html 文件中获得失败的测试用例报告。每当我通过命令提示符运行 ant 脚本时,我都会将所有测试用例作为失败/通过。但报告似乎没有显示失败的案例。下面是我在项目中使用的 XML 文件。如果这有点破旧,请向我道歉。我还仔细检查了清洁程序是否被调用,但没有运气。任何指针/想法/建议?
<project name="UAT_Automation" basedir="C:\Users\gthelu\workspace\TestCasesSuite">
<property name="home.dir" value="${basedir}"/>
<property name="build.dir" value="${home.dir}/build"/>
<!--property name="jars" value="C:\Program Files (x86)\Java\selenium jar's" -->
<property name="src.dir" value="${home.dir}/src"/>
<property name="ng.result" value="test-output"/>
<property name="lib.dir" value="./Lib"/>
<property name="browser" value="C:\Program Files (x86)\Mozilla Firefox\firefox.exe"/>
<property name="index.dir" value = "${basedir}/testng_output/index.html"/>
<!-- setClassPath -->
<target name="setClassPath">
<path id="classpath_jars">
<pathelement path="${basedir}/" />
<fileset dir="${lib.dir}" includes="*.jar" />
</path>
<pathconvert pathsep=":" property="test.classpath" refid="classpath_jars" />
</target>
<!-- loadTestNG -->
<target name="loadTestNG" depends="setClassPath">
<taskdef resource="testngtasks" classpath="${test.classpath}"/>
</target>
<!-- build -->
<target name="build">
<mkdir dir="${build.dir}"/>
<tstamp>
<format property="timestamp" pattern="dd-MM-yyyy_(HH-mm-ss)"/>
</tstamp>
<property name="build.log.dir" location="${basedir}/buildlogs"/>
<mkdir dir="${build.log.dir}"/>
<property name="build.log.filename" value="build_${timestamp}.log"/>
<record name="${build.log.dir}/${build.log.filename}" loglevel="verbose" append="false"/>
<echo message="build logged to ${build.log.filename}"/>
</target>
<!-- Clean -->
<target name="clean">
<echo message="deleting existing build directory"/>
<delete dir="${build.dir}"/>
</target>
<!-- Compile -->
<target name="compile" depends="clean,build,setClassPath,loadTestNG">
<echo message="classpath:${test.classpath}"/>
<echo message="compiling.........."/>
<javac destdir="${build.dir}" srcdir="${src.dir}" classpath="${test.classpath}"/>
</target>
<!-- executeApp -->
<target name="executeApp" depends="compile">
<testng classpath="${test.classpath}:${build.dir}">
<xmlfileset dir="${basedir}" includes="testng.xml"/>
</testng>
</target>
<!-- Report -->
<target name="report" depends="executeApp">
<delete dir="${basedir}/testng-xslt"/>
<mkdir dir="${basedir}/testng-xslt"/>
<xslt in="${basedir}/test-output/testng-results.xml"
style="${basedir}/src/xslt/testng-results.xsl" out="${basedir}/testng-xslt/index.html" processor="SaxonLiaison">
<param expression="${basedir}/testng-xslt/" name="testNgXslt.outputDir"/>
<param expression="true" name="testNGXslt.sortTestCaseLinks"/>
<param expression="FAIL,SKIP,PASS,BY_CLASS" name="testNgXslt.testDetailsFilter"/>
<param expression="true" name="testNgXslt.showRuntimeTotals"/>
<classpath refid="classpath_jars"/>
</xslt>
</target>
<!-- makexsltreports-->
<target name="makexsltreports" depends="executeApp">
<exec executable="${browser}" spawn="yes">
<arg line="${index.dir}" />
</exec>
</target>
</project>