2

I've added a Visual Studio Test task to my build definition and enabled code coverage. It works, but it also included dependencies when counting the blocks, which makes the result useless. I'm using the Visual Studio test runner for xUnit.net

For example, when analysing code coverage in Visual Studio, I have the following result:

  • summary: 13 blocks not covered, 38 blocks covered
  • foo.dll: 13 blocks not covered, 20 blocks covered
  • foo.test.dll: 0 blocks not covered, 18 blocks covered

When downloading the code coverage report from VSTS, I have the following result:

  • summary: 6769 blocks not covered, 205 blocks covered
  • fluentassertions.core.dll: 5639 blocks not covered, 155 blocks covered
  • fluentassertions.dll: 1117 blocks not covered, 12 blocks covered
  • foo.dll: 13 blocks not covered, 20 blocks covered
  • foo.test.dll: 0 blocks not covered, 18 blocks covered

This is shown on VSTS:

screenshot of code coverage report

FluentAssertions is only referenced and used in my test project. How can I exclude it (and other future dependencies) from the code coverage?

user247702
  • 23,641
  • 15
  • 110
  • 157
  • Have you checked the documentation? https://msdn.microsoft.com/en-us/library/jj159530.aspx and https://stackoverflow.com/questions/36853340/excluding-assemblies-from-code-coverage-in-visual-studio-team-services – Jacob Bruinsma Oct 20 '17 at 12:34
  • @Jacob that's an option, but I'd rather have a "set and forget" method within VSTS instead of creating a `.runsettings` file that needs to be maintained. (Perhaps I should just create a bug report instead, because I doubt this is how it's supposed to function.) – user247702 Oct 20 '17 at 12:54

1 Answers1

0

It is the expect result if running test through VSTest.Console.exe, you can run the test through VSTest.Console.exe on your local machine manually and check the result.

The Visual Studio Test task calls VSTest.Console.exe to run test, so it collects the code coverage for additional assemblies. There isn’t the option to configure it except specify the runsetting file.

starian chen-MSFT
  • 33,174
  • 2
  • 29
  • 53