使用cobertura来测量单元测试的代码覆盖情况

发表于:2010-3-05 13:57

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:huangtut(Javaeye)    来源:51Testing软件测试网采编

  build.properties文件:

  Java代码

  1  The source code for the examples can be found in this directory 
  2 src.dir=../src/java 
  3 src.conf.dir=../src/conf 
  4 test.dir=../test/java 
  5 test.conf.dir=../src/conf 
  6  
  7  The path to cobertura.jar 
  8 cobertura.dir=cobertura 
  9  
 10  Classes generated by the javac compiler are deposited in this directory 
 11 classes.dir=../bin 
 12  
 13  Instrumented classes are deposited into this directory 
 14 instrumented.dir=instrumented 
 15  
 16  All reports go into this directory 
 17 reports.dir=reports 
 18  
 19  Unit test reports from JUnit are deposited into this directory 
 20 reports.xml.dir=${reports.dir}/junit-xml 
 21 reports.html.dir=${reports.dir}/junit-html 
 22  
 23  Coverage reports are deposited into these directories 
 24 coverage.xml.dir=${reports.dir}/cobertura-xml 
 25 coverage.html.dir=${reports.dir}/cobertura-html 
 26 

  编写示例代码:

  Hello.java

  Java代码

  1 package com.xmatthew.practise.cobertura; 
  2  
  3 public class Hello { 
  4  
  5     public String birthday(String name) { 
  6         return "happy birthday to " + name; 
  7     } 
  8     
  9     public String christmas(String name) { 
 10         return "merry christmas " + name; 
 11     } 
 12      
 13 }

53/5<12345>
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号