Sonar Scanner 4.0.2
Dotnet SDK 2.1.401
Dotnet Core 2.0
what are you trying to achieve: Test coverage for all projects with corresponding unit tests
what have you tried so far to achieve this: So far, we have tried using various cli arguments, as well as different configurations in the csproj files
Our project is structured like this:
--src --main --ProjectA --ProjectB --ProjectC --test --ProjectATests --ProjectBTests --ProjectCTests abc.sln
our test csproj files have the following in the PropertyGroup header
Through bamboo we are running with the following arguments with the Sonar Begin task
We are using
dotnet test -c Release -l "trx;LogFileName=test-results.trx" $proj /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutputDirectory=TestResults
to run our tests
We have tried to structure our pipeline to do this as well
but there was no success there.
We are trying to get our coverage to be reported accurately across the entire project. Currently it appears to be getting coverage for ProjectB, for one or two classes in Project A and then not picking up any tests at all in Project C. With adding in the vstest trx files, we can see total number of unit tests. But we cannot see the individual test names or any other information about the tests. Without that argument and only using the opencover argument, we can only see coverage with no information about the unit tests. That doesn’t make any change to the coverage.
If it helps, our pipeline goes like this:
dotnet build-server shutdown source control checkout -- clean sonar scanner for msbuild begin dotnet restore dotnet build dotnet test mstest parser sonar end
We have also tried with NUnit parser between mstest parser and sonar end, but could not find a way to get sonar to pick up the output
Any help would be great!