SonarQube - unity tests code coverage on new code not working

点点圈 提交于 2019-12-24 16:13:32

问题


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.


回答1:


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 .



来源:https://stackoverflow.com/questions/34993416/sonarqube-unity-tests-code-coverage-on-new-code-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!