Solution Coverage
As seen in the screenshot below, the Solution Coverage window consists of three columns:
• Name – the project’s name.
• Sequence Coverage – shows the percentage of lines of code covered by tests.
• Branch Coverage –if/else statements create branches. Branch Coverage shows the percentage of branches that are covered by tests.
For example, the following method contains two branches
Now, consider the following unit test:
The coverage information for the above example is shown below:
The unit test covers only one branch of the method “division,” namely the one with y different than 0. Therefore, Branch Coverage is only 50%.
The Sequence Coverage shows 80% since there are 5 lines of code under the method statement (curly braces included, “else” statement not included) out of which 4 are covered by the test (only the exception is not covered).
Codebase project/Test project/Solution coverage
Codebase project coverage – shows the percentage of methods in your codebase project (named ConsoleApplication in the above example) being covered by unit tests.
Test project coverage – shows the percentage of unit tests in your test project (named TestProject in the above example) that were passed and not ignored (tests that are ignored are marked with the [Ignore] attribute).
Solution Coverage –shows the weighted average between the Test project coverage and the Codebase project coverage in the upper left corner of the window.
Test project example:
In the screenshot above there are only 4 tests which were all passed. Therefore, 100% is displayed in both the Sequence Coverage column and the Branch Coverage column next to the test project (named UnitTest).
Applying the [Ignore] attribute to one of the unit tests will cause the percentage displayed in the Sequence Coverage column to decrease to 75%:
Coverage information
The same result would apply if this particular test was failed.
•
To exclude code from the solution coverage use ExcludeFromCodeCoverage attribute: