How to force code coverage to Zero?

元气小坏坏 提交于 2019-12-11 16:38:32

问题


I have several java projects with no unit test cases. When I try to analyse these projects using SonarQube I am unable to get unit test code coverage because it doesn't have any test cases. As per my research I saw that I can force it to show it as zero if there are no unit test cases. The official Jacoco Java documentation mentions sonar.jacoco.reportMissing.force.zero=true.

My SonarQube analysis will be done using maven builds and SonarQube 5.6.6 and sonar-java 4.11.0.10660.

How can I set this parameter in maven so that it can show as zero unit test cases in my coverage?


回答1:


From version 6.2 SonarQube does this automatically where the behavior is supported by the analyzers. Before that version, availability of the feature is spotty and not entirely reliable. For best results you should upgrade SonarQube.

That said, you can set that property on the analysis command line like so:

mvn sonar:sonar -Dsonar.jacoco.reportMissing.force.zero=true

Or by setting a property in your pom, as shown in the docs



来源:https://stackoverflow.com/questions/46119730/how-to-force-code-coverage-to-zero

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