Sonar C# 插件不考虑 100% 覆盖的文件
我们使用以下套件来分析我们的.Net4项目:
- Maven 2.2.1
- Gallio 3.2.750
- PartCover 4.0.20626
- Sonar 2.9
- Sonar C# Plugins Ecosystem 1.0
当我们在 PartCover Explorer 中打开覆盖率报告文件(使用 Maven/Gallio/Partcover 构建)时我们有一些文件的覆盖率为 100%,因此全球覆盖率为 97%。
但在声纳覆盖浏览器中我们看不到这些文件,然后全局覆盖的计算下降到65%。
我们尝试使用 Nover3 并得到相同的行为。
这是正常行为吗?有什么参数需要配置吗?
更新为问题添加OP答案
我们对问题进行了更多分析。事实上,这并不是100%覆盖的文件,而是接口。事实上,它们不会被 PartCover 或 NCover 分析(xml 输出中没有信息),但它们包含在 Sonar 的总覆盖范围计算中。有没有办法参数化这个?
we use the following suite to analyse our .Net4 project:
- Maven 2.2.1
- Gallio 3.2.750
- PartCover 4.0.20626
- Sonar 2.9
- Sonar C# Plugins Ecosystem 1.0
When we open the coverage report file (build with Maven/Gallio/Partcover) in PartCover Explorer we have some files with 100% of coverage and so a global coverage of 97%.
But in the sonar coverage browser we cannot see these files and then the calculation of global coverage is downed to 65%.
We try with NCover3 and we have the same behaviour.
Is it the normal behaviour? Is there any parameters to configure?
Updated to add OPs answer into question
We analyze the problem a little more. And in fact, it is not due to the 100% covered files, but the interfaces. Indeed, they are not analyzed by PartCover or NCover (no information present in the xml output) but they are included in the calculation of total coverage with Sonar. Is there a way to parameter this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
接口没有可检测的代码,因此您将无法获得它们的任何覆盖率数据,这适用于 NCover、< a href="https://github.com/sawilde/partcover.net4" rel="nofollow">PartCover 和 OpenCover AFAIK。您只有在实际实施时才能获得覆盖范围信息。
声纳覆盖浏览器可能正在处理实际的代码行,而不是最终转换为代码的内容;通过序列点的数量(以及 NCover/OpenCover 的分支点)来衡量。
要排除接口、枚举和抽象方法、自动实现的属性等代码,需要进行大量的解析,并且是特定于语言的。
如果您正在寻找代码覆盖率指标,请使用您的覆盖率工具为您提供的内容,并解释其余的内容
Interfaces have no code to instrument and as such you will not get any coverage data for them this applies to NCover, PartCover and OpenCover AFAIK. You only get coverage information when they are actually implemented.
The Sonar coverage browser is probably working on actual lines of code and not what was eventually turned into code; measured by number of sequence points (and branch points for NCover/OpenCover).
To exclude code like interfaces, enums and abstract methods, auto implemented properties etc etc - would require some hefty parsing and it would be language specific.
If you are after a code coverage metric go with what your coverage tool gives you and explain away the rest