Publish test coverage of multiple .NET Core Projects from Azure DevOps to SonarQube server

后端 未结 2 451
耶瑟儿~
耶瑟儿~ 2021-01-16 20:34

I have a .net core solution with two xunit test projects. The build runs on Azure DevOps pipeline and I want to publish the test coverage to a SonarQube (Community) server.<

2条回答
  •  情书的邮戳
    2021-01-16 20:45

    I finally found the issue. You don't need to merge the .coveragexml files, the last version of the SonarScanner.MSBuild.exe actually finds all the .coveragexml files. I looked more closely in the logs and found multiple lines like these:

    INFO: Sensor C# Tests Coverage Report Import [csharp]
    INFO: Parsing the Visual Studio coverage XML report [...]
    INFO: Adding this code coverage report to the cache [...]
    INFO: Parsing the Visual Studio coverage XML report [...]
    INFO: Adding this code coverage report to the cache [...]
    

    So the .coveragexml files were found and published to sonar.

    The reported coverage was false because I needed to add a

    Full
    

    In a project. The odd thing is that the other projects reported some code coverage without this property set in the .csproj so I thought I didn't need it.

    So if the reported coverage seems false, try adding this property in the csproj.

提交回复
热议问题