从检测 cobertura 中排除方法/分支

发布于 2024-11-15 22:06:16 字数 941 浏览 3 评论 0原文

我需要从检测和代码覆盖率中跳过某些方法或代码段。这导致我使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

哭泣的笑容 2024-11-22 22:06:17

请参阅此链接。 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!

终难遇 2024-11-22 22:06:17

这不是问题的直接答案,但我的看法是:“掩盖它。”不要从报道报告中排除某些内容。修复覆盖范围。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文