Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run Test Analyze Code Coverage for a specific project in Visual Studio 2012?

Currently in Visual Studio 2012, when getting code coverage of my unit tests, all I can see is the options for selected tests and all tests

I want to get coverage from one project only. How can I do that?

enter image description here

like image 561
Nam G VU Avatar asked Oct 25 '13 07:10

Nam G VU


People also ask

How do you test code coverage in Visual Studio code?

On the Test menu, select Analyze Code Coverage for All Tests. You can also run code coverage from the Test Explorer tool window. Show Code Coverage Coloring in the Code Coverage Results window. By default, code that is covered by tests is highlighted in light blue.

How do I run a specific test in Visual Studio?

Run tests in Test Explorer If Test Explorer is not visible, choose Test on the Visual Studio menu, choose Windows, and then choose Test Explorer (or press Ctrl + E, T). As you run, write, and rerun your tests, the Test Explorer displays the results in a default grouping of Project, Namespace, and Class.

How do you run tests with coverage?

Run a test with code coverageOpen the desired file in the Project tool window and choose Run <name> with Coverage from the context menu. You can also select a directory with test files and choose the corresponding command from the context menu to run several tests with coverage.

How do I test a Project in Visual Studio?

Select the test project in Solution Explorer. On the Project menu, select Add Reference. In Reference Manager, select the Solution node under Projects. Select the code project you want to test, and then select OK.


1 Answers

use the "Test Explorer" window to filter the tests by project enter image description here

  • Then you can use CTRL+A to select all of the tests.

  • Now when you execute "Selected Tests" on the Analyze Code Coverage (or right-click the tests and select "Analyse coverage for selected tests"), you will get coverage only for those tests

  • When you look in the code coverage results, you will see that Covered % will only include non-zero figures for the classes covered by the test.

  • afaik there is no way to hide the 0% coverage (i.e non-tested) classes from a project in the results which is a shame as it means you have to sort by Covered% and ignore everything that's 0. So all of the classes from the project(s) that the selected tests reference will be shown but if the selected tests didn't touch them, then the coverage for those will show as 0.

like image 110
Stephen Byrne Avatar answered Sep 30 '22 07:09

Stephen Byrne