I am trying to use .NET code coverage analysis to check coverage on my unit tests, but I keep getting a warning message when running "dotnet coverage collect -f cobertura dotnet test"
The message says: No code coverage data available. Profiler was not initialized.
The .xml file is created but it does not have any data. When I run reportgenerator "-reports:./output.cobertura.xml" "-targetdir:./coverage_report", it creates an html file in 0.0 seconds. When I open it, it does not provide any branch data, just a bunch of NA.
I am using .net8.0.
Here is what the terminal looks like.
My html file ends up looking like this.
It should look more like this.
I have had several troubles with .NET on my Mac, but this seems to be the final issue. Is there a way to make sure that the Profiler is initialized so that the .xml file is properly filled with data?
I was able to get my report to work! Instead of the command that I was previously running to generate the .xml report, I ran the following:
dotnet test --collect "Code Coverage;Format=cobertura"
That created a filled .xml file that I was able to create a proper .html report from!