Code coverage extensions
This article list and explains all Microsoft Testing Platform
extensions related to the code coverage capability.
You can use the code coverage feature to determine what proportion of your project's code is being tested by coded tests such as unit tests. To effectively guard against bugs, your tests should exercise or cover a large proportion of your code.
Coverlet
There's currently no Coverlet extension, but you can use Coverlet .NET global tool.
Microsoft code coverage
Microsoft Code Coverage analysis is possible for both managed (CLR) and unmanaged (native) code. Both static and dynamic instrumentation are supported. This extension is shipped as part of Microsoft.Testing.Extensions.CodeCoverage NuGet package.
Note
Unmanaged (native) code coverage is disabled in the extension by default. Use flags EnableStaticNativeInstrumentation
and EnableDynamicNativeInstrumentation
to enable it if needed.
For more information about unmanaged code coverage, see Static and dynamic native instrumentation.
Important
The package is shipped with Microsoft .NET library closed-source free to use licensing model.
For more information about Microsoft code coverage, see its GitHub page.
Microsoft Code Coverage provides the following options:
Option | Description |
---|---|
--coverage |
Collect the code coverage using dotnet-coverage tool. |
--coverage-output |
Output file. |
--coverage-output-format |
Output file format. Supported values are: 'coverage', 'xml', and 'cobertura'. |
--coverage-settings |
XML code coverage settings. |
For more information about the available options, see settings and samples.