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

查看:91
本文介绍了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"任务中,我检查了启用代码覆盖率"选项,如下所示:

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任务会将代码覆盖率结果直接发布到构建摘要"页面.因此,我们不需要发布代码覆盖率"结果任务来发布覆盖率结果.只需确保在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天全站免登陆