Skip to content

Dot Net Core Test Coverage

clydeu edited this page Jun 6, 2019 · 2 revisions

Pre-Requisites:

  • Install NuGet CLI.

  • Make sure you test project is using NuGet Package References:

    Right-click the References node in Solution Explorer and select Migrate packages.config to PackageReference�.

  • Install NuGet packages

    You need to run the following command, in a temporary folder that can be removed once it is installed, to install both packages in NuGet cache:

    • nuget install OpenCover
    • nuget install ReportGenerator
  • Install dotnet testx

    dotnet tool install --global dotnet-testx

  • Enable full PDB generation for all projects you want included in the coverage report (no longer needed for net standard projects):

    Project->Properties->Build->Advanced->Debugging information

Generate Reports

  1. Open Powershell/CMD/Git Bash in test project folder.
  2. Run dotnet testx --html --browser.
  3. Or if need to run multiple tests, dotnet testx --html --browser --discover-projects *tests.csproj in the solution folder.
  4. Optionally, dotnet watch testx --html can be used to watch test file changes.

For UI coverage: https://github.com/ppumkin/PrestoCoverage

Clone this wiki locally