I'm trying to get Code Coverage for a Asp.Net Core application(DebugType - Full) running on IIS Express using OpenCover.
As specified here I tried setting the environment variable and then run the OpenConsole. Only difference being that I'm trying to open using iisexpress.exe instead of VSIISExeLauncher.exe
set LAUNCHER_ARGS=-p "C:\Program Files\dotnet\dotnet.exe" -a "exec \"C:\CoreWebApp\CoreWebApp\bin\Debug\netcoreapp2.0\CoreWebApp.dll\"" -pidFile $([System.IO.Path]::GetTempFileName()) -wd "C:\CoreWebApp\CoreWebApp"
set LAUNCHER_PATH=C:\Program Files\IIS Express\iisexpress.exe
OpenCover.Console.exe -target:"C:\Program Files\IIS Express\iisexpress.exe" -targetargs:"/config:""C:\CoreWebApp\.vs\config\applicationhost.config"" /site:CoreWebApp" -output:"Coverage.results.xml" -register:user –targetdir:"C:\CoreWebApp\CoreWebApp\bin\Debug\netcoreapp2.0"
I get 'HTTP Error 502.5 - Process Failure' when I hit any URL in the application.
Alternatively, if I try to run the application directly as below. When I press CTRL+C to stop the server, the OpenCover also stops.
OpenCover.Console.exe -target:"C:\Program Files\dotnet\dotnet.exe" -targetargs:"C:\CoreWebApp\CoreWebApp\bin\Debug\netcoreapp2.0\CoreWebApp.dll" -output:"Coverage.results.xml" -register:user -oldStyle
Any idea how to use OpenCover with a Asp.Net Core application?
The below worked.
Set the environment variables.
Below command can be used if you want to just run the dot net core application in IIS express.
To get code coverage using OpenCover,
To generate the html report