VSTS - 如何获得代码覆盖率结果 [英] VSTS - how to get Code Coverage results

查看:18
本文介绍了VSTS - 如何获得代码覆盖率结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 DevOps 工作的新手,我的任务是为我们的一个 .net 标准库项目设置构建.我为此使用了构建模板,效果很好!但我想在构建输出中添加代码覆盖率(解决方案中有一个测试项目).

I'm new to DevOps work and I've been tasked to setup a build for one of our .net Standard Library projects. I used the build template for this, which works great! But I want to add a code coverage into build output (there's a test project in the solution).

在VsTest - testAssemblies"任务中,我勾选了Enable Code Coverage"选项,如下图:

In the "VsTest - testAssemblies" task, I've checked the "Enable Code Coverage" option, as shown below:

我添加了一个发布代码覆盖率任务,它要求一个叫做摘要文件"的东西 - 见下文:

I added a Publish code coverage task and it's asking for something called a "Summary File" - see below:

我不知道如何设置这个选项?有人做过吗?

I'm not sure how to set this option? Has anyone done this?

我似乎在没有配置的情况下在构建结果中发布了测试结果,见下文:

I seem to get test results published in the build results without config, see below:

我希望构建结果中的代码覆盖率选项卡也是如此,该选项卡目前为空白:

And I'd like the same for the Code Coverage tab in the build results, which is currently blank:

另外(可能是一个完全独立的问题),我想知道 - 我可以添加一个质量门"来说明覆盖率低于 80% 则构建失败吗?

Also (may be a completely separate question), I was wondering - can I add a "Quality Gate" to say if Coverage is below 80% then fail the build?

提前感谢您的任何建议 - 这是一个知道我想要什么,但不知道如何实现它的情况!

Thanks for any advice in advance - it's a case of knowing what I want, but not sure how to achieve it!

推荐答案

默认情况下,VsTest 任务会直接将 Code Coverage 结果发布到 Build Summary 页面.所以我们不需要发布代码覆盖率结果任务来发布覆盖率结果.只需确保您在 VsTest 任务中选择了启用代码覆盖率"部分.

By default, the VsTest task will publish the Code Coverage result to Build Summary page directly. So we don't need Publish Code Coverage result task to publish the coverage result. Just make sure you have selected "Code Coverage enable" section in VsTest task.

>> 另外(可能是一个完全独立的问题),我想知道 - 我可以添加一个质量门"来说明覆盖率低于 80% 则构建失败吗?

在当前的 VSTS 中,如果与配置的 % 值不匹配,我们无法设置Quality Gate"来设置构建失败.还有其他社区也有这个要求并提交了用户意见.请随时添加您的评论或从以下链接投票:https://visualstudio.uservoice.com/forums/330519-visual-studio-team-services/suggestions/3817520-fail-build-on-insufficient-code-coverage

In current VSTS, we could not set "Quality Gate" to set the build failed if it doesn't match the configured % value. There has other communities also have this requirement and have submit a user voice. Please feel free to add your comments or vote it from below link: https://visualstudio.uservoice.com/forums/330519-visual-studio-team-services/suggestions/3817520-fail-build-on-insufficient-code-coverage

这篇关于VSTS - 如何获得代码覆盖率结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆