我需要从检测和代码覆盖中跳过某些方法或代码段。这导致我 使用 Cobertura 从代码覆盖中排除方法。
然后cobertura ant 页面 http://cobertura.sourceforge.net/anttaskreference.html 说……你可以通过传入“ignore”正则表达式来告诉Cobertura 忽略某些类。忽略模式可以是任何有效的 perl 5 正则表达式。这将忽略对与忽略正则表达式匹配的任何方法的任何调用。在检测期间它不会跳过这些类。要从检测中排除类,请将它们从文件集中排除或使用下面的替代方法并指定 excludeClasses 模式。……
来自 net.sourceforge.cobertura.ant.InstrumentTask.java 的源代码
for (int i = 0; i < ignoreBranchesRegexs.size(); i++) {
IgnoreBranches ignoreBranchesRegex = (IgnoreBranches)ignoreBranchesRegexs.get(i);
builder.addArg("--ignoreBranches", ignoreBranchesRegex.getRegex());
}
“--ignoreBranches”有什么作用?预期的模式是什么?我要试试。如果您使用了上述选项,请分享您的“命令行”