Java 中的代码覆盖工具

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1518362/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 16:52:21  来源:igfitidea点击:

Code coverage tools in Java

javacode-coverage

提问by emkrish

Are there any such code coverage tools in Java that give the different paths in the program. Basically the idea is to ensure that all loops and nested loops are covered during execution. That is to be able to ascertain if all the loops in a code base have been executed at least through one iteration.

Java中是否有任何此类代码覆盖工具可以提供程序中的不同路径。基本上这个想法是确保在执行过程中覆盖所有循环和嵌套循环。那是为了能够确定代码库中的所有循环是否已经至少通过一次迭代执行。

回答by Rogério

Cobertura, EMMA and even Clover only do branch/decision coverage(in addition to line/statementcoverage, of course). Clover also provides methodcoverage (which simply measures if a method was entered at all during execution).

Cobertura、EMMA 甚至 Clover 只进行分支/决策覆盖(当然,除了行/语句覆盖)。Clover 还提供方法覆盖(它只是测量在执行期间是否输入了方法)。

For pathcoverage (plus line/statement coverage), try JMockit Coverage.

对于路径覆盖(加上行/语句覆盖),请尝试JMockit Coverage

A sample report can be found here.

可以在此处找到示例报告。

Actually, as of now this is only an initial version of the new path coverage support, which I still need to improve.

实际上,到目前为止,这只是新路径覆盖支持的初始版本,我还需要改进。

回答by aberrant80

Coberturais another popularly used tool.

Cobertura是另一种常用的工具。

回答by Mike Two

Try EMMAIt's free. It is supported in eclipse and JetBrains IDEA support and also TeamCity build server.

试用EMMA它是免费的。它在 Eclipse 和 JetBrains IDEA 支持以及 TeamCity 构建服务器中受支持。

回答by DJDole

I'd go with JaCoCoIt's an open source tool (replacement for EMMA) distributed under Eclipse's public license.

我会选择JaCoCo它是一个开源工具(替代 EMMA),在 Eclipse 的公共许可下分发。

Ref (05:05, 17 July 2013?): http://en.wikipedia.org/wiki/Java_Code_Coverage_Tools

参考(2013 年 7 月 17 日 05:05?):http: //en.wikipedia.org/wiki/Java_Code_Coverage_Tools

回答by Thomas Jung

Cloveris a good tool.

三叶草是一个很好的工具。