Microsoft has enhanced its code coverage tools, adding new features to Microsoft.CodeCoverage and introducing dotnet-coverage. The enhancements include fresh report formats that integrate smoothly with tools such as ReportGenerator.
Microsoft posted a bulletin about its enhanced code coverage tools on December 21. Both Microsoft.CodeCoverage and dotnet-coverage can run on any platform supported by .NET, due to the addition of static instrumentation. While the default remains the familiar coverage
format, other report formats include Cobertura and XML. Cobertura is an open source XML format that can be opened in Visual Studio Enterprise or any text editor. Microsoft’s XML format also can be opened in Visual Studio Enterprise or a text editor.
Mirosoft’s new dotnet-coverage tool collects code coverage for console and web applications, merges coverage reports, instruments binaries, and calculates code coverage for each test separately. Running dotnet test --collect "Code Coverage"
at the solution level automatically merges code coverage for all test projects (see a full example).
Microsoft also has improved documentation for code coverage at GitHub, while noting code coverage functionality is closed-source. Code coverage performance has been made faster as well. Microsoft has published a Get Started guide for collecting code coverage for a .NET test project.