当前位置: 动力学知识库 > 问答 > 编程问答 >

git - SonarQube - unity tests code coverage on new code not working

问题描述:

I am trying to do Sonar analysis with the unit tests code coverage on new code. When I do code coverage analysis with cobertura and do Sonar analysis the overall code coverage of the code is displayed correctly, however the code coverage of new code is not displayed.

Settings:

  • scm = Git
  • sonar.scm.disabled = false

I did following

  1. checked out earlier version of source code
  2. set Sonar project version to 1.0
  3. created Cobertura report (xml file)
  4. executed analysis and checked that the analysis was uploaded, the overal code coverage by unit tests was displayed correctly
  5. checked out latest version of source code
  6. set Sonar project version to 2.0
  7. executed analysis and checked that the analysis was uploaded, the overal code coverage by unit tests was displayed correctly

The overall code coverage of the code by unit tests got increased as I have implemented some unit tests on a code that was changed. The On New Code item in the widget however stays hidden and the code coverage of new code is not displayed.

Does any of you have any tips that could bring more light to this?

Thank you all.

网友答案:

You're observing this behaviour because Coverage on new code currently identifies new code based on the date of the previous analysis (and not the commit date of the code previously analyzed), see SONAR-7085 .

For your scenario to work you have to force a past date for the analysis of the old code, using -Dsonar.projectDate. Good article on this right here: Sonar Time Machine : replaying the past .

分享给朋友:
您可能感兴趣的文章:
随机阅读: