Testng本身可以工作,我可以得到结果。我试图使用XSLT报告来让事情变得更漂亮,但我没有运气。以下是eclipse的设置方式:http://i.imgur.com/A6XRbKt.jpg
BUILD.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 Main\TestNG\lib"/>
<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&gt; ant makexsltreports 构建文件:E:\ Selenium Main \ TestNG \ build.xml
makexsltreports: [xslt]处理E:\ Selenium Main \ TestNG \ test-output \ testng-results.xml到E:\ Selenium Main \ TestNG \ XSLT_Reports \ output \ index.html [xslt]加载样式表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; lineNumber:34;得到columnnumber :71;属性名称&#34; data-pjax-transient&#34;与元素类型相关联&#34; meta&#34;必须遵循&#39; =&#39;字符。 [xslt]:致命错误! org.xml.sax.SAXParseException; systemId:file:/ E:/Selenium%20Main/TestNG/src/xslt/testng-results.xsl; lineNumber:34; columnNumber:71;属性名称&#34; data-pjax-transient&#34;与元素类型相关联&#34; meta&#34;必须是fol 被&#39;低调=&#39;字符。原因:org.xml.sax.SAXParseException; systemId:file:/ E:/Selenium%20Main/TestNG/src/xslt/testng-results.xsl; lineNumber:34; columnNumber:71;属性名称&#34; data-pjax-transient&#34;与元素类型相关联&#34; meta&#34;米 接下来是&#39; =&#39;字符。 [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; lineNumber:34; columnNumber:71;属性名称&#34; data-pjax-transient&#34;与元素类型相关联&#34; meta&#34;必须遵循&#39; =&#39;字符。
总时间:1秒
E:\ Selenium Main \ TestNG&gt;
谢谢
答案 0 :(得分:0)
好吧,我解决了这个问题。 testng-results.xsl是它看起来的问题。我用在互联网上找到的另一个副本替换了该文件,现在可以正常使用了!