Search code examples
c#asp.net-core.net-corepester

Code coverage of ASP.NET core app with test done in Pester


I have a REST service that is being tested using Pester and our PowerShell REST client (implemented using PowerShell's Invoke-RestMethod and friends).

How would I generate code coverage for it ?

Test is initiated using:

  1. dotnet run to start the service in the background
  2. invoke-pester that runs integration test

Since we don't have by the book testing here using dot net test project, nor dotnet test command is used, how would I generate code coverage in such scenario ?

I tried with OpenCover and it starts up the app this way and tests run trough it, but its results.xml is almost empty (checked debug mode and presence of PDB files)

$env:ASPNETCORE_URLS = 'http://localhost:3001'
OpenCover -target:"c:\program files\dotnet\dotnet.exe" -targetargs:"run --no-build --no-restore --no-launch-profile --configuration Debug"

Solution

  • I made it working like a charm with dotCover CLI