What's New in Our Code Coverage Tooling? - .NET Blog
source link: https://devblogs.microsoft.com/dotnet/whats-new-in-our-code-coverage-tooling/?WT_mc_id=dotnet-35129-website
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
What’s New in Our Code Coverage Tooling?
Jakub Chocholowicz
Exciting news for developers! We’ve enhanced our code coverage tools, Microsoft.CodeCoverage and dotnet-coverage, with some fantastic features. If you’re new to our tools, check out our Get Started guide. Let’s dive into the changes that will simplify your coding experience.
Support for All Platforms
Our tools can run on any platform supported by .NET, thanks to the addition of static instrumentation. Learn more about static and dynamic instrumentation, and discover supported platforms.
Fresh Report Formats
We’ve revamped our code coverage report formats to integrate smoothly with tools like ReportGenerator. While the default remains the familiar .coverage
format, we’ve introduced some new ones:
- Binary (Default): .coverage (Microsoft’s special format) – Open it in Visual Studio Enterprise. Example
- Cobertura: .cobertura.xml (Open-source XML format) – Open it in Visual Studio Enterprise, any text editor, or generate an HTML report with ReportGenerator. Example
- XML: .xml (Microsoft’s XML Format) – Open it in Visual Studio Enterprise and any text editor. Example
Meet dotnet-coverage
Introducing our new tool, dotnet-coverage! It performs following tasks:
- Collects code coverage for console applications. Example
- Collects code coverage for web applications. Example
- Merges coverage reports. Example
- Instruments binaries. Example
- Calculates code coverage for each test separately. Example
Visit dotnet-coverage documentation to learn more.
Auto-Merge for solutions
Running dotnet test --collect "Code Coverage"
at the solution level now automatically merges code coverage for all your test projects. Visit Scenario 24 Code coverage for solution to see full example.
Improved Documentation
Explore our fresh GitHub repository at microsoft/codecoverage for all the info and samples you need.
Faster Performance
Prior to the 16.5 release, the collection of code coverage report significantly slowed down test execution. We addressed this issue, resulting in an impressive 80% performance gain. See performance section for detailed results and logs.
Package | Time | Ratio |
---|---|---|
Microsoft.CodeCoverage 16.5 | 03:52:53 | 1.00 |
Microsoft.CodeCoverage 17.0 | 02:25:49 | 0.63 |
Microsoft.CodeCoverage 17.5 | 01:27:52 | 0.38 |
Microsoft.CodeCoverage 17.9 | 00:50:00 | 0.21 |
What You Need to Do
To enjoy the latest features and speed up your builds, make sure to use our latest stable packages in your test projects:
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Microsoft.CodeCoverage" Version="17.8.0" />
If your solution doesn’t have any C++ code, make it faster and more reliable by turning off native code coverage with these flags in runsettings:
<EnableStaticNativeInstrumentation>False</EnableStaticNativeInstrumentation>
<EnableDynamicNativeInstrumentation>False</EnableDynamicNativeInstrumentation>
Visit configuration documenation to see other options and full example of our settings.
Special Thanks
A big thank you to Faisal Hafeez, Marco Rossignoli, Mariam Abdullah, Codrin-Victor Poienaru and Pavel Horak for their exceptional contributions to this project!
Jakub Chocholowicz Principal Software Engineer, .NET
Follow
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK