zoukankan      html  css  js  c++  java
  • Eclipse JUnit 生成报告

    http://blog.sina.com.cn/s/blog_8af106960102v6qh.html

    对Eclipse的工程写单元测试:

    第一步:

    1. 一个工程有多个测试类,将测试类放到一个测试包utpkg下。

    2. 每一个测试类写好,都单独执行run as ->JUnit Test测一下。

    第二步:

    1. 所有的测试类写好后,对工程右键->export->General->Ant Buildfiles=>next->选中工程名,默认的选项:name for and buildfile:build.xml;JUnit output directory:JUnit(不用手动创建,执行build.xml时会自动生成).=>finish.

    2. 在工程下会生成一个build.xml的蚂蚁图标的文件。

    第三步:

    1. 右击build.xml文件,->run as->3 ant build...

    2. 在Targets栏下选择要执行的targets. build[default]是默认的。其他可以自己根据需要,选择待执行的测试类。

      注意:这些是有顺序的,可以自行调整顺序。

    3. 选好之后,Run.

    第四步:

    查看Run结束的结果。

    1. 在工程下会生成一个junit的文件夹,下面有一系列的文件。

    其中index.html文件->open with->web browser,可以看到所有测试类的执行结果。

     TestsErrorsFailuresSkippedTime(s)Time StampHost
    a 27 0 0 0 205.845 2014-11-14T06:37:36 **
    b 24 0 0 0 107.019 2014-11-14T06:37:19 **
    c 23 0 0 0 1.610 2014-11-14T06:36:41 **
    d 56 0 0 0 230.640 2014-11-14T06:32:51 **
    e 41 0 0 0 171.714 2014-11-14T06:34:20 **
    f 9 0 0 0 1.214 2014-11-14T06:37:35 **
    g 124 0 0 0 1.946 2014-11-14T06:38:10 **

    可能遇到的问题:

     junitreport:

    [junitreport] Processing *junitTESTS-TestSuites.xml to C:Users*AppDataLocalTemp ull2128665787

    [junitreport] Loading stylesheet jar:file:/D:/soft/eclipse_kepler/plugins/org.apache.ant_1.8.4.v201303080030/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! Could not compile stylesheet

    [junitreport] : Fatal Error! Cannot convert data-type 'void' to 'reference'. Cause: Cannot convert data-type 'void' to 'reference'.

    [junitreport] Failed to process D:workplace-Ecworkspace_kepler able2kjunitTESTS-TestSuites.xml

    BUILD FAILED

    D:workplace-Ecworkspace_kepler able2kuild.xml:233: Errors while applying transformations: Fatal error during transformation

      

    问题描述: 

    Eclipse:kepler 

    jdk:1.7.0_75 

    junit:4.11.0.v201303080030 

    ant:1.8.4.v20130303080030 

    解决方案: 

    将ant升级。(org.apache.ant_1.9.2.v201404171502) 

    Window->Preferences->Ant->Runtime:classpath-> 

    ant home entries:D:soft*pluginsorg.apache.ant_1.9.2.v201404171502

    参考:

    http://stackoverflow.com/questions/10607151/error-the-first-argument-to-the-non-static-java-function-replace-is-not-a-val

    http://blog.csdn.net/zerozxg/article/details/8613034

  • 相关阅读:
    算法-转
    单页 SEO-转
    浅谈MVVM设计模式
    iOS-UIView动画
    iOS 核心动画(下)
    iOS开发-核心动画(Core Animation)
    iOS-CALayer的介绍
    SVN Xcode不能提交.a文件
    iOS 毛玻璃效果
    Quartz2D学习总结
  • 原文地址:https://www.cnblogs.com/201dom/p/5163655.html
Copyright © 2011-2022 走看看