Testng本身就可以工作,我可以生成结果。 我正在尝试使用 XSLT 报告使事情变得更漂亮,但我没有任何运气。 以下是日食的设置方式: https://i.stack.imgur.com/XgiNP.jpg
构建.XML文件:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE project [
]>
<project name="TestNG" default="usage" basedir=".">
<!-- ========== Initialize Properties =================================== -->
<property environment="env"/>
<property name="ws.home" value="${basedir}"/>
<property name="ws.jars" value="E:Selenium MainTestNGlib"/>
<property name="test.dest" value="${ws.home}/build"/>
<property name="test.src" value="${ws.home}/src"/>
<property name="ng.result" value="test-output"/>
<!--target name="start-selenium-server">
<java jar="${ws.home}/lib/selenium-server.jar"/>
</target-->
<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>
<target name="init" depends="setClassPath">
<tstamp>
<format property="start.time" pattern="MM/dd/yyyy hh:mm aa" />
</tstamp>
<condition property="ANT"
value="${env.ANT_HOME}/bin/ant.bat"
else="${env.ANT_HOME}/bin/ant">
<os family="windows" />
</condition>
<taskdef name="testng" classpath="${test.classpath}"
classname="org.testng.TestNGAntTask" />
</target>
<!-- all -->
<target name="all">
</target>
<!-- clean -->
<target name="clean">
<delete dir="${test.dest}"/>
</target>
<!-- compile -->
<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="classpath------: ${test.classpath}"/>
<echo message="compiling..."/>
<javac
debug="true"
destdir="${test.dest}"
srcdir="${test.src}"
target="1.5"
classpath="${test.classpath}"
>
</javac>
</target>
<!-- build -->
<target name="build" depends="init">
</target>
<!-- run -->
<target name="run" depends="compile">
<testng classpath="${test.classpath}:${test.dest}" suitename="sivaprasad">
<xmlfileset dir="${ws.home}" includes="testng.xml"/>
</testng>
<!--
<testng classpath="${test.classpath}:${test.dest}" groups="fast">
<classfileset dir="${test.dest}" includes="example1/*.class"/>
</testng>
-->
</target>
<target name="usage">
<echo>
ant run will execute the test
</echo>
</target>
<path id="test.c">
<fileset dir="${ws.jars}" includes="*.jar"/>
</path>
<target name="makexsltreports">
<mkdir dir="${ws.home}/XSLT_Reports/output"/>
<xslt in="${ng.result}/testng-results.xml" style="src/xslt/testng-results.xsl"
out="${ws.home}/XSLT_Reports/output/index.html" classpathref="test.c" processor="SaxonLiaison">
<param name="testNgXslt.outputDir" expression="${ws.home}/XSLT_Reports/output/"/>
<param name="testNgXslt.showRuntimeTotals" expression="true"/>
</xslt>
</target>
<!-- ****************** targets not used ****************** -->
</project>
错误信息:E:\Selenium Main\TestNG>ant makexsltreports构建文件: E:\Selenium Main\TestNG\build.xml
makexsltreports: [xslt]处理 E:\Selenium Main\TestNG\test-output\testng-results.xml to E:\Selenium Main\TestNG\XSLT_Reports\output\index.html [xslt]Loading stylesheet E:\Selenium Main\TestNG\src\xslt\testng-results.xsl [xslt]E:\Selenium Main\TestNG\src\xslt\testng-results.xsl:34:71: 致命错误!XML 解析器报告的错误原因:org.xml.sax.SAXParseException;systemId: file:/E:/Selenium%20Main/TestNG/src/xslt/testng-results.xsl;行号: 34;列编号: 71;与元素类型"meta"关联的属性名称"data-pjax-transient"必须后跟 ' = ' 字符。 [xslt]:致命错误!org.xml.sax.SAXParseException;systemId: file:/E:/Selenium%20Main/TestNG/src/xslt/testng-results.xsl;行号: 34;列数: 71;与元素类型"meta"关联的属性名称"data-pjax-transient"必须是fol由 ' = ' 字符降低。原因:org.xml.sax.SAXParseException;systemId: file:/E:/Selenium%20Main/TestNG/src/xslt/testng-results.xsl;行号: 34;列数: 71;与元素类型"meta"m关联的属性名称"data-pjax-transient"ust 后跟 ' = ' 字符。 [xslt]无法处理 E:\Selenium Main\TestNG\test-output\testng-results.xml
构建失败E:\Selenium Main\TestNG\build.xml:100: 使用 E:\Selenium Main\TestNG\src\xslt\testng-results.xsl: org.xml.sax.SAXParseException;systemId: file:/E:/Selenium%20Main/TestNG/src/xslt/testng-results.xsl;行号: 34;列数: 71;与元素类型"meta"关联的属性名称"data-pjax-transient"必须后跟 ' = ' 字符。
总时间: 1 秒
E:\Selenium Main\TestNG
>谢谢
好的,我解决了这个问题。 testng-results.xsl是它看起来的问题。我用互联网上找到的另一个副本替换了该文件,它现在可以工作了!