SonarQube: Multiple unit test and code coverage re

2019-07-14 07:39发布

问题:

we have the following structure in our project:

  • maven project 1
  • maven project 2
    • module 1
    • module 2
    • module 3
  • maven project 3

Project 1 and 3 have each one unit test and code coverage result file. They are no problem. Project 2 has three unit test and code coverage result files, one for each module.

Now I want to show the unit test and code coverage in SonarQube. But I can only configure one result file (sonar.surefire.reportsPath and sonar.emma.reportPath).

How can I configure the three files, or do I have to merge the files?

回答1:

You have to configure sonar.surefire.reportsPath and sonar.emma.reportPath for each module. This can't be done from command line, so you have to do it in pom.xml of each module.

Please note that if you are using default Maven settings I'm quite sure you don't need to specify sonar.surefire.reportsPath and sonar.emma.reportPath at all because SonarQube will look at standard location by default.