从检测 cobertura 中排除方法/分支
我需要从检测和代码覆盖率中跳过某些方法或代码段。这导致我使用Cobertura从代码覆盖率中排除方法。
然后是cobertura ant页面 http://cobertura.sourceforge.net/anttaskreference.html 说 ... 您可以通过传入“忽略”正则表达式来告诉 Cobertura 忽略某些类。忽略模式可以是任何有效的 perl 5 正则表达式。这将忽略对与忽略正则表达式匹配的任何方法的任何调用。 在检测过程中它不会跳过这些类。要从检测中排除类,请将它们从文件集中排除,或者使用下面的替代方法并指定 exceptClasses 模式。 ....
来自 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”有什么作用?预期的模式是什么?我要去尝试一下。如果您使用过上述选项,请分享您的“命令行”
I need to skip certain methods or code segments from instrumentation and code coverage. That lead me to Exclude methods from code coverage with Cobertura.
Then the cobertura ant page
http://cobertura.sourceforge.net/anttaskreference.html said
...
You can tell Cobertura to ignore certain classes by passing in "ignore" regular expressions. The ignore pattern can be any valid perl 5 regular expression. This will ignore any calls to any method that matches the ignore regular expression. It will NOT skip over these classes during instrumention. To exclude classes from being instrumented, either exclude them from your fileset or use the alternative method below and specify an excludeClasses pattern.
....
From the source code of 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());
}
What does the "--ignoreBranches" do? What is the pattern expected? I am going to try it. If you have used above option, please share your "command line"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请参阅此链接。 http://svnsearch.org/svnsearch/repos/COBERTURA/search?start-index=60&
显然,为此目的添加了一个 @Ignore 方法注释。至于代码块,我会尝试同样的事情。让我知道这是否有效!
Please see this link. http://svnsearch.org/svnsearch/repos/COBERTURA/search?start-index=60&
Apparently, there is an @Ignore method annotation that was added for this purpose. As for code blocks, I would try the same thing. Let me know if this works!
这不是问题的直接答案,但我的看法是:“掩盖它。”不要从报道报告中排除某些内容。修复覆盖范围。
This isn't a direct answer to the question, but my take on it would be: "Cover it." Don't exclude things from coverage reports. Fix the coverage.