{"id":49643,"date":"2023-12-21T10:05:00","date_gmt":"2023-12-21T18:05:00","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/dotnet\/?p=49643"},"modified":"2024-12-13T14:02:47","modified_gmt":"2024-12-13T22:02:47","slug":"whats-new-in-our-code-coverage-tooling","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/dotnet\/whats-new-in-our-code-coverage-tooling\/","title":{"rendered":"What&#8217;s New in Our Code Coverage Tooling?"},"content":{"rendered":"<p>Exciting news for developers! We&#8217;ve enhanced our code coverage tools, <a href=\"https:\/\/www.nuget.org\/packages\/Microsoft.CodeCoverage\">Microsoft.CodeCoverage<\/a> and <a href=\"https:\/\/aka.ms\/dotnet-coverage\">dotnet-coverage<\/a>, with some fantastic features. If you&#8217;re new to our tools, check out our <a href=\"https:\/\/github.com\/microsoft\/codecoverage#get-started\">Get Started<\/a> guide. Let&#8217;s dive into the changes that will simplify your coding experience.<\/p>\n<h2>Support for All Platforms<\/h2>\n<p>Our tools can run on any platform supported by .NET, thanks to the addition of static instrumentation. Learn more about <a href=\"https:\/\/github.com\/microsoft\/codecoverage\/blob\/main\/docs\/instrumentation.md\">static and dynamic instrumentation<\/a>, and discover <a href=\"https:\/\/github.com\/microsoft\/codecoverage\/blob\/main\/docs\/supported-os.md\">supported platforms<\/a>.<\/p>\n<h2>Fresh Report Formats<\/h2>\n<p>We&#8217;ve revamped our code coverage report formats to integrate smoothly with tools like ReportGenerator. While the default remains the familiar <code>.coverage<\/code> format, we&#8217;ve introduced some new ones:<\/p>\n<ul>\n<li><strong>Binary (Default):<\/strong> .coverage (Microsoft&#8217;s special format) &#8211; Open it in Visual Studio Enterprise. <a href=\"https:\/\/github.com\/microsoft\/codecoverage\/blob\/main\/samples\/Calculator\/scenarios\/scenario01\/README.md\">Example<\/a><\/li>\n<li><strong>Cobertura:<\/strong> .cobertura.xml (Open-source XML format) &#8211; Open it in Visual Studio Enterprise, any text editor, or generate an HTML report with ReportGenerator. <a href=\"https:\/\/github.com\/microsoft\/codecoverage\/blob\/main\/samples\/Calculator\/scenarios\/scenario02\/README.md\">Example<\/a><\/li>\n<li><strong>XML:<\/strong> .xml (Microsoft&#8217;s XML Format) &#8211; Open it in Visual Studio Enterprise and any text editor. <a href=\"https:\/\/github.com\/microsoft\/codecoverage\/blob\/main\/samples\/Calculator\/scenarios\/scenario04\/README.md\">Example<\/a><\/li>\n<\/ul>\n<h2>Meet dotnet-coverage<\/h2>\n<p>Introducing our new tool, dotnet-coverage! It performs following tasks:<\/p>\n<ul>\n<li>Collects code coverage for console applications. <a href=\"https:\/\/github.com\/microsoft\/codecoverage\/blob\/main\/samples\/Calculator\/scenarios\/scenario08\/README.md\">Example<\/a><\/li>\n<li>Collects code coverage for web applications. <a href=\"https:\/\/github.com\/microsoft\/codecoverage\/blob\/main\/samples\/Calculator\/scenarios\/scenario14\/README.md\">Example<\/a><\/li>\n<li>Merges coverage reports. <a href=\"https:\/\/github.com\/microsoft\/codecoverage\/blob\/main\/samples\/Calculator\/scenarios\/scenario18\/README.md\">Example<\/a><\/li>\n<li>Instruments binaries. <a href=\"https:\/\/github.com\/microsoft\/codecoverage\/blob\/main\/samples\/Calculator\/scenarios\/scenario10\/README.md\">Example<\/a><\/li>\n<li>Calculates code coverage for each test separately. <a href=\"https:\/\/github.com\/microsoft\/codecoverage\/blob\/main\/samples\/Calculator\/scenarios\/scenario16\/README.md\">Example<\/a><\/li>\n<\/ul>\n<p>Visit <a href=\"https:\/\/aka.ms\/dotnet-coverage\">dotnet-coverage<\/a> documentation to learn more.<\/p>\n<h2>Auto-Merge for solutions<\/h2>\n<p>Running <code>dotnet test --collect \"Code Coverage\"<\/code> at the solution level now automatically merges code coverage for all your test projects. Visit <a href=\"https:\/\/github.com\/microsoft\/codecoverage\/blob\/main\/samples\/Calculator\/scenarios\/scenario24\/README.md\">Scenario 24 Code coverage for solution<\/a> to see full example.<\/p>\n<h2>Improved Documentation<\/h2>\n<p>Explore our fresh GitHub repository at <a href=\"https:\/\/github.com\/microsoft\/codecoverage\">microsoft\/codecoverage<\/a> for all the <a href=\"https:\/\/github.com\/microsoft\/codecoverage#readme\">info<\/a> and <a href=\"https:\/\/github.com\/microsoft\/codecoverage\/tree\/main\/samples\/Calculator#readme\">samples<\/a> you need.<\/p>\n<h2>Faster Performance<\/h2>\n<p>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 <a href=\"https:\/\/github.com\/microsoft\/codecoverage\/tree\/main\/docs\/performance\">performance<\/a> section for detailed results and logs.<\/p>\n<table>\n<thead>\n<tr>\n<th>Package<\/th>\n<th>Time<\/th>\n<th>Ratio<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Microsoft.CodeCoverage 16.5<\/td>\n<td>03:52:53<\/td>\n<td>1.00<\/td>\n<\/tr>\n<tr>\n<td>Microsoft.CodeCoverage 17.0<\/td>\n<td>02:25:49<\/td>\n<td>0.63<\/td>\n<\/tr>\n<tr>\n<td>Microsoft.CodeCoverage 17.5<\/td>\n<td>01:27:52<\/td>\n<td>0.38<\/td>\n<\/tr>\n<tr>\n<td>Microsoft.CodeCoverage 17.9<\/td>\n<td>00:50:00<\/td>\n<td>0.21<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>What You Need to Do<\/h2>\n<p>To enjoy the latest features and speed up your builds, make sure to use our latest stable packages in your test projects:<\/p>\n<pre><code class=\"language-xml\">&lt;PackageReference Include=\"Microsoft.NET.Test.Sdk\" Version=\"17.8.0\" \/&gt;\n&lt;PackageReference Include=\"Microsoft.CodeCoverage\" Version=\"17.8.0\" \/&gt;<\/code><\/pre>\n<p>If your solution doesn&#8217;t have any C++ code, make it faster and more reliable by turning off native code coverage with these flags in runsettings:<\/p>\n<pre><code class=\"language-xml\">&lt;EnableStaticNativeInstrumentation&gt;False&lt;\/EnableStaticNativeInstrumentation&gt;\n&lt;EnableDynamicNativeInstrumentation&gt;False&lt;\/EnableDynamicNativeInstrumentation&gt;<\/code><\/pre>\n<p>Visit <a href=\"https:\/\/github.com\/microsoft\/codecoverage\/blob\/main\/docs\/configuration.md\">configuration<\/a> documenation to see other options and full example of our settings.<\/p>\n<h2>Special Thanks<\/h2>\n<p>A big thank you to <a href=\"https:\/\/github.com\/fhnaseer\">Faisal Hafeez<\/a>, <a href=\"https:\/\/twitter.com\/MarcoRossignoli\">Marco Rossignoli<\/a>, <a href=\"https:\/\/github.com\/mariam-abdulla\">Mariam Abdullah<\/a>, <a href=\"https:\/\/github.com\/cvpoienaru\">Codrin-Victor Poienaru<\/a> and <a href=\"https:\/\/twitter.com\/pavelhorak0\">Pavel Horak<\/a> for their exceptional contributions to this project! \ud83d\ude4c\ud83d\ude80<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Discover enhanced code coverage tools with better platform support, new report formats and improved performance.<\/p>\n","protected":false},"author":137380,"featured_media":49660,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[685,195,3009],"tags":[4,9,11,108],"class_list":["post-49643","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dotnet","category-dotnet-framework","category-performance","tag-net","tag-net-core","tag-net-framework","tag-performance"],"acf":[],"blog_post_summary":"<p>Discover enhanced code coverage tools with better platform support, new report formats and improved performance.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/49643","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/users\/137380"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/comments?post=49643"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/49643\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media\/49660"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media?parent=49643"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/categories?post=49643"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/tags?post=49643"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}