1

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).

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

enter image description here

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

enter image description here

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:

enter image description here

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

enter image description here

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!

Rob
  • 6,819
  • 17
  • 71
  • 131
  • The "Summary file" is required field, what value did you give? – Shayki Abramczyk Aug 23 '18 at 12:06
  • I realise that :) and I haven't given a value... as I don't know what to enter :( – Rob Aug 23 '18 at 12:48
  • If you didn't enter anything in this field how did you manage to run the build? – Shayki Abramczyk Aug 26 '18 at 14:18
  • 1
    If you want an HTML report to show up on the Code Coverage tab, [this answer](https://stackoverflow.com/a/54738732/4629442) may help, not to mention that the tool mentioned coverlet allows for a threshold value that coverage must meet. – Josh Gust Feb 22 '19 at 14:48

2 Answers2

2

Hurrah!!! There is a solution for it. :)

You have to install a an Add-on to your organization in VSTS (Azure DevOps). The name of the addon is Build Quality Checks

Here is the link: https://marketplace.visualstudio.com/items?itemName=mspremier.BuildQualityChecks

It works perfectly. And this is what you want

György Gulyás
  • 1,290
  • 11
  • 37
1

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.

>> 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?

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

Weiwei
  • 3,674
  • 1
  • 10
  • 13
  • NOTE: This is available in the market place - see here: https://marketplace.visualstudio.com/items?itemName=mspremier.BuildQualityChecks – Rob Oct 04 '18 at 10:07