BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Microsoft.CodeCoverage v17.8 Released with New dotnet-coverage Tool and Other Improvements

Microsoft.CodeCoverage v17.8 Released with New dotnet-coverage Tool and Other Improvements

Microsoft recently announced an upgraded version of its developer tools, version 17.8.0, introducing significant improvements to Microsoft.CodeCoverage tools. Notably, the update includes the introduction of the dotnet-coverage tool. Additional enhancements comprise new report formats, an auto-merge tool, performance upgrades, and improved documentation.

A notable addition to the set of tools is dotnet-coverage, which carries various roles, including collecting code coverage for console and web applications, merging coverage reports, instrumenting binaries, and calculating code coverage for individual tests. This new tool significantly contributes to a more complete and efficient code coverage analysis of Microsoft.CodeCoverage.

One notable improvement is the expanded platform compatibility of the tools, achieved through the incorporation of static instrumentation. Regarding that, Microsoft's code coverage tools initially relied on dynamic instrumentation for the Windows platform.

Later versions introduced static code coverage collection, pre-instrumenting libraries on disk for universal .NET platform support. Dynamic instrumentation remains the default, but on non-Windows systems, static is activated, avoiding redundant dynamic instrumentation. Developers control the method through configuration flags.

Furthermore, the code coverage report formats have experienced a comprehensive overhaul to integrate with auxiliary tools such as ReportGenerator. While the default .coverage format remains unchanged, several new formats have been introduced, including Binary (Default) in .coverage format for Visual Studio Enterprise, Cobertura in .cobertura.xml format compatible with Visual Studio Enterprise and text editors, and XML in .xml format for use with Visual Studio Enterprise and other text editors.

A new feature introduced in this update is Auto-Merge for solutions. Executing the command dotnet test --collect 'Code Coverage' at the solution level now automatically consolidates code coverage data from all associated test projects. This process simplifies the management of code coverage across complex solutions.

Addressing a performance concern before the 16.5 release, there has been a notable improvement in the efficiency of code coverage report collection. Previously, this process substantially restrained test execution speed.

With the identified issue rectified, developers can now benefit from an impressive 80% increase in performance, making the code coverage analysis more efficient and less intrusive. The readers can take a look at benchmark results which are available at the official announcement post.

To get started with the most recent features and optimise build processes, developers need to incorporate the latest stable packages into test projects.

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Microsoft.CodeCoverage" Version="17.8.0" />

With the note that solutions without C++ code, developers can enhance speed and reliability by deactivating native code coverage using the specified flags in the runsettings configuration.

<EnableStaticNativeInstrumentation>False</EnableStaticNativeInstrumentation>
<EnableDynamicNativeInstrumentation>False</EnableDynamicNativeInstrumentation>

Lastly, the latest documentation improvements can be found in the updated GitHub repository. The repository provides users with a comprehensive information resource and samples for an improved documentation experience.

About the Author

BT