网站大量收购闲置独家精品文档,联系QQ:2885784924

Cobertura测试代码覆盖率.ppt

  1. 1、本文档共35页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Cobertura测试代码覆盖率

Command line方式: Ser文件合并: Cobertura支持将不同测试环境的cobertura.ser统计文件进行合并。如:同一版本的项目在不同的环境下(或集群环境中)进行测试后,代码覆盖率需要合并报告。合并cobertura.ser统计文件就能够满足该要求: cobertura-merge.bat --datafile D:\cobertura\datafile\cobertura.ser D:\cobertura\uat03\cobertura.ser D:\cobertura\uat04\cobertura.ser 总结 覆盖率数据只能代表你测试过哪些代码,不能代表你是否测试好这些代码 不要一味的追求数据,为了提高代码测试覆盖率而去设计测试案例; There Two One 要以代码测试覆盖率为参考,让它来帮助我们设计更加有意义,高效的测试用例; ? ? ? 问题探讨 例如: int?foo(int?a,?int?b) { ????int?nReturn?=?0; ????if?(a??10) ????{//?分支一 ????????nReturn?+= 1; ????} ????if?(b??10) ????{//?分支二 ????????nReturn?+= 10; ????} ????return?nReturn; } 语句覆盖(覆盖率100%) TestCase?a?=?5,?b?=?5?? nReturn = 11 b. 判定覆盖(覆盖率100%) TestCase1 a?=?5,?? b?=?5???? nReturn = 11 TestCase2 a?=?15,?b?=?15?? nReturn = 0 c. 条件覆盖(覆盖率100%) TestCase1 a?=?5,?? b?=?15?? nReturn = 1 TestCase2 a?=?15,?b?=?5?? ? nReturn = 10 d. 路径覆盖(覆盖率100%) TestCase1 a?=?5,? ? b?=?5???? nReturn = 0 TestCase2 a?=?15,? b?=?5???? nReturn = 1 TestCase3 a?=?5,??? b?=?15?? nReturn = 10 TestCase4 a?=?15,? b?=?15?? nReturn = 11 McCabe方法包括若干项度量指标。常用的有如下几项: (1)圈复杂度:圈复杂度是用来衡量一个模块判定结构的复杂程度。在程序控制流程图中,节点是程序中代码的最小单元,边代表节点间的程序流。一个有e条边和n个节点的流程图F,其圈复杂度为:VF =e-n+2。圈复杂度越高,程序中的控制路径越复杂。McCabe指出,典型的程序模块的圈复杂度为10。 (2)基本复杂度:基本复杂度是用来衡量程序结构化程度的。如果流程图G中的结构化子图的数量是m,则其基本复杂度为:EVF =V ? F -m。当基本复杂度为1,这个模块是充分结构化的;当基本复杂度大于1而小于循环复杂度,这个模块是部分结构化的;当基本复杂度等于循环复杂度时,这个模块是完全非结构化的。 (3)模块复杂度:模块设计复杂度用来衡量模块判定结构,即衡量模块与模块的调用关系。从模块流程图中移取那些不包含调用子模块的判定和循环结构时求得的循环复杂度就是模块设计复杂度。 Line Coverage: The percent of lines executed by this test run. Branch Coverage: The percent of branches executed by this test run. Complexity: Average McCabes cyclomatic code complexity for all methods. This is basically a count of the number of different code paths in a method (incremented by 1 for each if statement, while loop, etc.) N/A: Line coverage and branch coverage will appear as Not Applicable when Cobertura can not find line number information in the .class file. This happens for stub and skeleton classes, interfaces, or when the c

文档评论(0)

yan698698 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档