I am trying to setup code coverage on our ASP.NET Core 2.0 web application. I use dotcover (from JetBrains) to provide code coverage on all my other builds (by running dotcover from the command-line during the build process).
When I run dotcover from our build server for our .NET Core 2.0 web app I see this.
It states that it has run successfully but then just hangs there and no code coverage files are created.
dotcover analyse /TargetExecutable:"C:\Program Files\dotnet\dotnet.exe" /TargetArguments:"test MyUnitTests.csproj" /Output:report.html /ReportType:HTML /LogFile=dotcover.log
If I try and add code coverage collection I see this.
dotcover analyse /TargetExecutable:"C:\Program Files\dotnet\dotnet.exe" /TargetArguments:"test MyUnitTests.csproj --collect:coverage" /Output:report.html /ReportType:HTML /LogFile=dotcover.log
And finally if I run dotnet test on its own (without dotcover) it seems to have worked, but again no coverage output is created.
dotnet test "MyUnitTests.csproj" -- collect:coverage
I'm unsure how to generate code coverage for a .NET Core 2.0 app, and not sure how / what data collectors are and how they should be used. Is dotcover the data collector in this example?
Basically, I just want to generate code coverage for a .NET Core 2.0 application.
UPDATE:
As per the suggestion I have installed coverlet as an alternative to dotcover. I have got it working but am getting inconsistent behaviour. When I run my batch file from the server it's all fine.
But when run from TFS I get an error.
System.IO.FileNotFoundException: No test is available in . Make sure test project has a nuget reference of package "Microsoft.NET.Test.Sdk" and framework version settings are appropriate and try again.
My project does have a reference to that assembly (it's installed by default by VS itself when you create a unit test project).
Why is TFS complaining about that assembly when it's definitely there and can be run manually from the command-line without an error?
I don't know if dotcover can works with net core, but you can take a look for coverlet, also you can find an example here: Cross platform code coverage arrives for .NET Core