配置 cobertura 以忽略某些代码块
是否可以使用 Cobertura 告诉它忽略由开始和结束注释标识的某些代码位?
例如,
public class Foo {
public void static doSomething() {
...
// Cobertura-Ignore-Start
...
// Cobertura-Ignore-End
}
会导致 Cobertura 在计算覆盖率统计数据时不包括开始注释和结束注释之间的代码。
编辑:我正在使用 cobertura Ant 任务。
Is it possible using Cobertura to tell it to ignore certain bits of code that are identified by start and end comments?
For example,
public class Foo {
public void static doSomething() {
...
// Cobertura-Ignore-Start
...
// Cobertura-Ignore-End
}
would result in Cobertura not including the code in between the start and end comments when calculating coverage statistics.
Edit: I am using the cobertura Ant task.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不,这是不可能的。 Cobertura 没有让它跳过代码的功能。您唯一可以忽略的是对某些包和/或类的方法调用。
您可能必须深入研究代码,看看是否可以以忽略块的方式扩展它。
No, it's not possible. Cobertura does not have a feature that lets it skip over code. The only thing you can ignore is method calls to certain packages and/or classes.
You'd probably have to dig into the code and see whether it's possible to extend it in such a way as to ignore blocks.
据我所知,您只能在类级别忽略(这意味着被忽略的类中的任何方法都不会被计算在内,但它会被检测到,因此这样做不会加快速度)。
You can ignore at the class level only as far as I know (which means any method from the ignored classes is not counted, it is instrumented though so no speed up by doing so).