SonarQube Test Coverage with MsTest

后端 未结 2 1056
长情又很酷
长情又很酷 2020-12-20 14:41

I have been trying to get SonarQube working with a simple dot net app. I have had some success getting it up and running but code coverage is not working.

2条回答
  •  南方客
    南方客 (楼主)
    2020-12-20 15:44

    Please ensure below things:

    1) Do you have the coverage file being generated by the build process?

    If this is not generated, then possibly build script needs to be updated to generate one or else need to add an explicit step in build automation tool to generate it.

    For e.g. "C:\Program Files\dotnet\dotnet.exe" test .csproj --logger:trx --collect:"Code Coverage"
    

    2) Ensure that an xml version of the CodeCoverage file is generated.

    So there will be two files:

    CodeCoverage (generated using dotnet command)
    
    CodeCoverageXml (This is generated by using "CodeCoverage.exe analyze /output: newfilename Your_CodeCoverage_file" )
    

    3) Is the correct path of Coveragefile provided while invoking SonarQube?

    4) Does your build server have correct version of 'Dotnet' installed and ensure that same version of dotnet is executed?

    Sometimes build server has multiple versions of Dotnet (e.g. v2.0.3 and v2.1.0)

    To generate the coverage report, it is very important to use the correct version or else it will show as zero or wont generate the Coverage file itself.

提交回复
热议问题