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?
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.
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.
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.
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.
use the "Test Explorer" window to filter the tests by project
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With