使用junitreport生成报告时,发生异常的情况

通过ant中的 junitreport task来生成JUnit测试报告,target的代码如下:

 

<target depends="build" name="AllTests">
	<mkdir dir="${junit.output.dir}"/>
	<junit fork="yes" printsummary="withOutAndErr">
		<formatter type="xml"/>
		<test name="com.fujitsu.netproto_knowhow.testcase.AllTests" todir="${junit.output.dir}"/>
		<classpath refid="netproto_knowhow.classpath"/>
	</junit>
</target>
<target name="junitreport" depends="AllTests">
	<mkdir dir="${junit.output.report}"/>    	
	<junitreport todir="${junit.output.report}">
		<fileset dir="${junit.output.dir}">
			<include name="TEST-*.xml"/>
		</fileset>
		<report format="frames" todir="${junit.output.report}"/>
	</junitreport>
</target>

可是,我在Eclipse中执行这个target的时候,却一直报下面这个错误

[junitreport] Processing F:\Workspaces\HTML5\netproto_knowhow\ant\junit\20130410092003\html\TESTS-TestSuites.xml to C:\Users\WANGZH~1\AppData\Local\Temp\null1293654028
[junitreport] Loading stylesheet jar:file:/F:/Development_Tools/eclipse-jee-juno-SR2-win32/plugins/org.apache.ant_1.8.3.v201301120609/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/xsl/junit-frames.xsl
[junitreport] : Error! The first argument to the non-static Java function 'replace' is not a valid object reference.
[junitreport] : Error! Cannot convert data-type 'void' to 'reference'.
[junitreport] : Fatal Error! Could not compile stylesheet
[junitreport] Failed to process F:\Workspaces\HTML5\netproto_knowhow\ant\junit\20130410092003\html\TESTS-TestSuites.xml

  Eclipse中,我的JRE版本是 1.6 U39,ant 版本是1.8.3,JUnit版本是4.10.

 

  百度了很长时间,没有找到答案。

  换谷歌,终于在stackoverflow上找到了一个解决方案:

  http://stackoverflow.com/questions/10536095/ant-junit-build-error-inside-eclipse

  按照上面的贴子中的想法,我变通了一下,将我自己的JRE版本换成了1.5的,便不会再现上面的这个问题。

  但是,由于JUnit4.10与JRE5不兼容,所以,需要换成JUnit3,或者JUnit4的低版本。

 

   大家也可以试试JRE6的低版本,比如,JRE6 u26 等等,也是可以的。

 

 

   网上还有一种做法,就是不在Eclipse中执行ant,便没有这种问题,但是这种方法我没有试过。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值