Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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.
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 |
The name or path of the produced coverage file. By default, the file is TestResults/<guid>.coverage . |
--coverage-output-format |
Output file format. Supported values are: coverage , xml , and cobertura . Default is coverage . |
--coverage-settings |
XML code coverage settings. |
For more information about the available options, see settings and samples.
Important
The coverlet.collector
NuGet package is designed specifically for VSTest and cannot be used with Microsoft.Testing.Platform
.
There's currently no Coverlet extension, but you can use Coverlet .NET global tool.
Assuming you've already installed the Coverlet global tool, you can now run:
coverlet .\bin\Debug\net8.0\TestProject2.dll --target "dotnet" --targetargs "test .\bin\Debug\net8.0\TestProject2.dll --no-build"
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowTraining
Module
C# testing in Visual Studio - Training
Start testing your C# apps by using the testing tools in Visual Studio. Learn to write tests, use Test Explorer, create test suites, and apply the red, green, refactor pattern to write code.
Certification
Microsoft Certified: Power Platform Developer Associate - Certifications
Demonstrate how to simplify, automate, and transform business tasks and processes using Microsoft Power Platform Developer.