• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: 小 中 大 | 推荐给好友 上一篇 | 下一篇

JUnit和ant结合

发布: 2007-5-25 14:29 | 作者: 未知 | 来源: JR | 查看: 166次 | 进入软件测试论坛讨论

领测软件测试网 ant 提供了两个 target : junit 和 junitreport  
运行所有 测试用例 ,并生成 html 格式的报表 
具体操作如下: 

1.将 junit.jar 放在 ANT_HOME\lib 目录下 
2.修改 build.xml ,加入如下 内容: 

  1.     <property name="report" value="report" /> 
  2.     <target name="junitreport" depends="clean, compile"> 
  3.         <junit printsummary="on" 
  4.                 fork="true" 
  5.                 haltonfailure="false" 
  6.                 failureproperty="tests.failed" 
  7.                 showoutput="true"> 
  8.             <classpath refid="myclasspath"/> 
  9.             <formatter type="xml"/> 
  10.             <batchtest todir="${report}"> 
  11.                 <fileset dir="${build}"> 
  12.                     <include name="**/*Test.*"/> 
  13.                 </fileset> 
  14.             </batchtest> 
  15.         </junit> 
  16.         <junitreport todir="${report}"> 
  17.             <fileset dir="${report}"> 
  18.                 <include name="TEST-*.xml"/> 
  19.             </fileset> 
  20.             <report format="frames" todir="${report}"/> 
  21.         </junitreport> 
  22.         <fail if="tests.failed"> 
  23.             --------------------------------------------------------- 
  24.             One or more tests failed, check the report for detail... 
  25.             --------------------------------------------------------- 
  26.         </fail> 
  27.     </target> 

运行 这个 target ,ant 会运行每个 TestCase  
在 report 目录下就有了 很多 TEST*.xml 和 一些网页 
打开 report 目录下的 index.html 就可以看到很直观的测试运行报告,一目了然。

延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/