.NET Core Code Coverage

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • coverlet

    Discontinued Cross platform code coverage for .NET [Moved to: https://github.com/coverlet-coverage/coverlet] (by tonerdo)

  • Code coverage tools are a great way to improve the code quality, but there are a lot of tools that require a paid license to use it like dotCover, the Enterprise version of Visual Studio or Visual Studio extensions. After some research, I found out that two free tools combined can generate code coverage reports. The first tool is called Coverlet which generates the code coverage as I wanted and it's also working with .NET Framework. Essentially is creating an XML report file that covers the lines, branches, and methods. And the second tool is ReportGenerator which is used for parsing the generated XML and expose the data in a friendly format.

  • NUnit

    NUnit Framework

  • NUnit

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • Let's take a look at the code coverage report. When the index.html file is open, the first page contains an overview of the ran tests, it offers a brief summary of the report and a grouping feature, that can be used to view the files on different layers (i.e. No grouping, By assembly, By namespace, Level: 1 and By namespace, Level: 2). The test report for the UserService class looks something like this: The color code is the same as in the other tools, but what I like is that it also has branch coverage, which in the above picture is the yellow area. In conclusion, these two tools are great and don't cost anything, also can be configured to run through all test projects and generate more comprehensive code coverage. Here is the repository link with all the code from this article: https://github.com/StefanescuEduard/NetCoreCodeCoverage. I kept the Coverage folder on the repository just for testing purposes. Thanks for reading this article, if you find it interesting please share it with your colleagues and friends. Or if you find something that can be improved please let me know.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts