`
Rainbow702
  • 浏览: 1074113 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
阅读更多

通过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,便没有这种问题,但是这种方法我没有试过。

 

分享到:
评论

相关推荐

    JUnit Ant Eclipse, JUnitReport报告

    在描述中提到的博文链接,作者可能详细介绍了如何配置和使用这三个工具进行测试并生成JUnitReport报告。JUnitReport是一个Ant任务,它可以收集JUnit测试的结果,生成HTML格式的报告,包含测试用例的数量、成功/失败...

    雾山的Robotium学习笔记---使用junitreport导出测试报告

    本篇笔记将深入探讨如何利用Robotium结合`junitreport`工具来生成详细的测试报告,帮助我们更好地理解和评估测试结果。 首先,我们要了解Robotium的基本概念。Robotium提供了Solo类,它包含了一系列方法,如点击...

    使用ant脚本编译并运行junit单元测试,并生成测试报告

    本文将深入探讨如何使用Ant脚本来编译Java代码、运行JUnit单元测试以及生成测试报告。 首先,我们需要理解Ant的基本结构。一个Ant项目通常由一个名为`build.xml`的文件组成,其中包含了构建过程的步骤。这个文件...

    通向架构师的道路(第二十五天)SSH的单元测试与dbunit的整合.docx

    例如,我们可以使用Ant的JUnitReport任务来生成测试报告,并将其与SSH项目的打包过程集成。 _ssh单元测试与DbUnit整合 在SSH项目中,我们可以使用DbUnit来测试DAO层的代码,并使用JUnit来测试其他组件。例如,我们...

    android junit4

    运行时,1.选中AppsTester.java 2.鼠标右键 3. Debug as android Junit Test 4.Logcat就能看到测试输出 AndroidManifest.xml导入(已做好) 1. &lt;!-- Android JUnit配置 --&gt; 2. targetPackage与上面mainfest的...

    junit ant集成生成html,xml,文本结果

    另外,你可以使用Ant本身或其他第三方工具(如JaCoCo或JunitReport)来生成HTML报告。以下是一个使用`junitreport`任务生成HTML报告的例子: ```xml &lt;junitreport todir="${test.reports.dir}"&gt; ${test.reports....

    jasmine-xml-reporter:Jasmine 2的--junitreport和--output命令行参数

    该模块使用模块生成JUnit XML报告(当存在--junitreport参数时),并且可以选择将生成的文件放在--output参数所指定的文件夹中。 安装 与任何节点模块一样简单: npm install jasmine-xml-reporter 用法 要仅使用...

    android-junit-report-1.0.3

    将AndroidManifest.xml文件中的TestRunner改成com.zutubi.android.junitreport.JUnitReportTestRunner就可以自动生成xml报告文件

    Generate the JUNIT report by Ant and Junit

    在生成JUnit报告时,我们需要在`build.xml`中添加特定的构建目标。通常,这包括一个`test`目标,用于运行JUnit测试,以及一个`junit-report`目标,用于生成测试报告。在`test`目标中,可以使用`junit`任务来调用...

    ant结合JUnit进行软件自动测试

    执行完测试后,`&lt;junitreport&gt;`任务用于处理生成的XML测试报告,将其转换为易于阅读的HTML格式,存放在"reports"目录下。`&lt;report&gt;`标签可以设置不同的格式,如"frames"表示带有框架的报告,便于查看。 运行`ant ...

    ant junit report 自定义

    ant junit report 自定义

    解决checkstyle出现的问题:Got an exception - java.lang.RuntimeException Unable to get class information for Exception

    在开发过程中,我们可能会遇到使用Checkstyle时出现的异常情况,例如:“Got an exception - java.lang.RuntimeException: Unable to get class information for **Exception”。这种错误通常是因为Checkstyle在分析...

    Frisby-for-DM-test:使用 Frisby.js 测试 DM

    Frisby-for-DM-测试在localhost 443/8080端口运行DM/WEB服务器,然后启动frisby进行测试。 命令: jasmine-node spec --junitreport 通过 --junitreport 生成测试报告

    test2junit:以Junit XML格式发出Clojure测试输出,并可以选择自动调用HTML生成

    这些文件可以与junitreport一起使用,以创建HTML格式的报告。 您可以通过project.clj文件来调整一些设置: ; specify your output directory :test2junit-output-dir " test-results " ; to run ant ...

    ANT學習筆記(一)——ANT 結合JUNIT4學習DEMO

    3. **生成报告**:可以通过`&lt;junit&gt;`任务的`formatter`子元素生成测试报告,或者使用`&lt;junitreport&gt;`任务进一步处理测试结果。 **示例项目AntAndJunitDemo** 在`AntAndJunitDemo`项目中,你将找到以下文件结构: ...

    ant.rar +使用文档

    `&lt;junit&gt;`任务用于执行测试,`&lt;junitreport&gt;`用于生成HTML格式的测试报告。 10. **部署与发布**:Ant可以用于部署应用到各种服务器环境,例如WebLogic、Tomcat等,通过定制特定的任务或目标来完成发布过程。 通过...

    自动化测试系列四 ANT

    3. **生成测试报告**:ANT还可以集成各种测试报告生成工具,如JunitReport或TestNG的报告生成,提供详细的测试报告,便于分析测试结果。 4. **持续集成**:ANT与持续集成工具如Jenkins、Hudson或Bamboo集成良好,...

Global site tag (gtag.js) - Google Analytics