【发布时间】:2015-02-01 18:41:53
【问题描述】:
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>ant makexsltreports 构建文件:E:\Selenium Main\TestNG\build.xml
makexslt 报告: [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: 文件:/E:/Selenium%20Main/TestNG/src/xslt/testng-results.xsl;行号:34;列号 : 71;与元素类型“meta”关联的属性名称“data-pjax-transient”必须后跟“=”字符。 [xslt]:致命错误! org.xml.sax.SAXParseException; systemId: 文件:/E:/Selenium%20Main/TestNG/src/xslt/testng-results.xsl;行号:34;列号:71;与元素类型“meta”关联的属性名称“data-pjax-transient”必须是 fol 由 '=' 字符降低。原因:org.xml.sax.SAXParseException; systemId: 文件:/E:/Selenium%20Main/TestNG/src/xslt/testng-results.xsl;行号:34;列号:71;与元素类型“meta”关联的属性名称“data-pjax-transient” m 后面必须跟 '=' 字符。 [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: 文件:/E:/Selenium%20Main/TestNG/src/xslt/testng-results.xsl;行号:34; 列号:71;与元素类型“meta”关联的属性名称“data-pjax-transient”必须后跟“=”字符。
总时间:1秒
E:\Selenium Main\TestNG>
谢谢
【问题讨论】:
标签: eclipse selenium ant testng build.xml