Search code examples
azure-devopscode-coverage

VSTS build agent on local machine doesn't provide code coverage data


I have an issue with VSTS build agent as I can't seem to produce code coverage info out of it when I run it locally. The build plan is the default one: get the source, build, execute test assemblies, create build artifact, etc. In the Test assemblies step, the Code coverage enabled checkbox is checked.

When I execute it using the Hosted VS2017 agent, the Code coverage tab shows a link to download the result and also the related charts can display that data.

I downloaded and installed the build agent from VSTS main page -- Project settings -- Agent pools. After installation, I queued a build using that. It builds fine, but the Code coverage tab shows the following message:

No code coverage data is available.
Enable code coverage via the test framework used in your build pipeline, such as JUnit, Visual Studio Test, or xUnit.

In case it matters, I use xUnit, the xunit.runner.visualstudio package is referenced in the test projects.

My question is: what should I modify in my setup to enable code coverage info for the local build agent?


Solution

  • The Hosted Agent has Visual Studio Enterprise installed. Visual Studio Enterprise is a prerequisite for gathering Code Coverage using VsTest.

    Visual Studio feature matrix: enter image description here https://visualstudio.microsoft.com/vs/compare/

    If your local system doesn't have Visual Studio Enterprise installed, then you don't have the required bits nor the required licenses on that machine to gather Code Coverage using the Visual Studio tooling (even if you put the bits on the machine through other means, such as test agent installation).

    You're free to use other coverage tools such as dotCover, Clover etc. but you'll need to configure these yourself.

    I doublechecked with Microsoft. The Visual Studio Test Agent is an addon for Visual Studio Test Professional and Visual Studio Enterprise and is licensed under these two SKUs/Subscriptions.

    Visual Studio Enterprise is the only supported SKU/Subscription which allows you to drill down into the test results and make sense of them, other than the aggregate numbers.