我可以从 OpenCover 获取代码覆盖率吗
我正在使用 OpenCover(和 ReportGenerator)来检查我的代码覆盖率,作为 CI 构建过程的一部分。
如果覆盖范围未达到给定阈值,OpenCover 是否有可能导致我的构建失败?
我环顾四周,但找不到任何方法来实现这一目标。我可以查看生成的报告吗?
编辑:抱歉,我应该提到我正在使用 Nant 构建脚本。
I am using OpenCover (and ReportGenerator) to examine my code coverage as part of my CI build process.
Is it somehow possible to have OpenCover fail my build if the coverage doesn't meet a given threshold?
I have looked around but can't find any way to achieve this. Could I peek into the generated report?
EDIT: Sorry, I should have mentioned I am using Nant build scripts.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于您没有提到您拥有什么 CI 服务器或它用于编写脚本,我将使用 nant 为例。
如果 CI 服务器能够对 XML 文档执行 XPath 查询,例如在 nant 中,您可以使用 xmlpeek 任务。然后,您可以使用以下查询来获取序列点的数量
,并使用此查询来获取访问过的序列点的数量
,从这两个数字中,您可以得出百分比,然后您可以根据该百分比使构建失败,例如在 nant 中可以使用失败任务。
As you haven't mentioned what CI server you have or what it uses for scripting I'll respond in a general manner using nant as an example.
If the CI server has the ability to execute XPath queries against an XML document e.g. in nant you can use the xmlpeek task. Then you can use the following query to get the number of sequence points
and this query to get the number of visited sequence points
and from those two numbers you can derive a percentage and then you can then fail the build based on that e.g. in nant you can use the fail task.