I am trying to collect my code coverage for my .net core 6 project, I have written some tests and I am planning to upload the results to sonarqube.
I read this documentation and decided to go with the dotnet-coverage tool, for some reason I can't get the code coverage, running the command
dotnet tool run dotnet-coverage collect 'dotnet test' -f xml -o 'tests/TestResults/coverage.xml'
gives me the following message No code coverage data available. Profiler was not initialized. and creates an empty coverage.xml file, I am using a macos with m1 processor, not sure if that makes any difference.
I am aware of other ways of generating code coverage but I am curious as to what that message means.
I was able to run the command from the question on windows but I needed to add the following to my steps to be able to run it successfully in a Linux environment.
apt-get update && apt-get install libxml2
It works perfectly for me. just few changes.
I ran cmd:
dotnet-coverage collect dotnet test -f xml -o coverage.xml

and it is also uploaded to sonarqube
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With