从 cobertura 的代码覆盖率中排除特定方法?
我试图使用以下配置忽略仪器中的所有 toString() 方法。这真的没起作用吗?这是使用 cobertura 作为 Maven 插件。这是基于之前的答案使用 Cobertura 从代码覆盖率中排除方法 。
<instrumentation>
<ignores>
<ignore>toString</ignore>
</ignores>
</instrumentation>
你认为我做错了什么。我无法在 cobertura 文档中找到这方面的示例。
I was trying to ignore all the toString() methods from instrumentation using following configuration. This wasn't really working? This is using cobertura as maven plugin. This was based on a previous answer Exclude methods from code coverage with Cobertura.
<instrumentation>
<ignores>
<ignore>toString</ignore>
</ignores>
</instrumentation>
What do you think I'm doing wrong. I wasn't able to find an example for this on the cobertura documentation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
cobertura-ant 参考
“忽略模式可以是任何有效的 perl 5 正则表达式。这将忽略任何调用与忽略正则表达式匹配的任何方法。要在检测过程中排除这些类,请将它们从文件集中排除,或者使用下面的替代方法并指定一个排除类模式。”
我相信您必须将“ignores”更改为“ignore”,并使用正则表达式在方法之前定义整个类名称(或者在您的情况下仅使用 * 来从任何类中排除
toString
)。cobertura-ant reference
"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."
I believe you have to change "ignores" to "ignore" and use a regular expression to define the whole class name before the method (or just an * in you case to exclude
toString
from any class).