We are using:
- Azure DevOps extension v1.10
- SonarCloud (paid plan/private projects)
- yaml build pipelines
- .NET core
- xUnit tests
We would like to exclude source code in a certain folder from code coverage, and understand that we can do this; either using the SonarCloud UI or specifying extraProperties to the prepare task in yaml, similar to the following:
- task: SonarCloudPrepare@1
However, we would like to know if we can get this to work using a “.runsettings” file instead. See also:
We have a “.runsettings” file and refer to it when running the “dotnet test” command. On the build report we get the expected “.coverage” file and can see the source files in the specified folder was excluded. The benefit of this is that developers can download the “.coverage” file and open it directly in Visual Studio to get the details about coverage, close to their code.
But in SonarCloud the files are not excluded. Is this the expected behavior, or is it possible to get SonarCloud to “respect” the “.runsettings” file? I guess it should not actually respect the “.runsettings” file, but maybe it could look at the “.coverage” file and only “include” files that are part of that and have any coverage calculated.
The benefit, as I see it (but I might overlook something), would be that we only configure this in the “.runsettings” file and hence the “code coverage” report on the build, and what you would see in the SonarCloud UI, would be perfectly aligned.