我目前使用
Clover测量Java代码的代码覆盖率.我依赖的一个功能是能够从覆盖率报告中排除任意代码段:
///CLOVER:OFF because this case is simpler to verify by code read if (lFile.isFile() && lFile.getName().endsWith(FILE_EXTN) && !lFile.delete()) { throw new IOException("delete() Failed for: " + lFile); } ///CLOVER:ON
我发现这种排除使得更容易专注于测试有趣的逻辑,同时仍然实现100%的代码覆盖率.
解决方法
以下是开源的java代码覆盖工具.这些可能会帮助你
NoUnit
InsECT
Jester
JVMDI Code Coverage Analyser
GroboCodeCoverage
jcoverage/gpl
JBlanket
Cobertura
Coverlipse
Hansel
CodeCover
EMMA
PIT
NoUnit
InsECT
Jester
JVMDI Code Coverage Analyser
GroboCodeCoverage
jcoverage/gpl
JBlanket
Cobertura
Coverlipse
Hansel
CodeCover
EMMA
PIT