Maven sample does not work with JUnit 5 - Zero coverage

Starting with the sample at

Change the dependency from JUnit 4 to JUnit 5


Then, change the import for the Test annotation in every test class to

import org.junit.jupiter.api.Test;

Running the example before the change shows the correct coverage report. Running the build again “mvn clean verify sonar:sonar” will build successfully but show a coverage report of zero.

For this sample test, I used the image published on Docker Hub.

docker pull sonarqube:latest

I tried moving the sample to the latest versions of jacoco-maven-plugin and org.sonarsource.scanner.maven but the result was the same.


I am having the same problem in all my projects (different version of sonarqube), but I thought it easier to discuss by eliminating the other variables and using this sample with the latest versions.


Hello @Derek

SonarQube is not computing any coverage by itself, it only imports reports from other tools (in this case JaCoCo).

If the coverage is 0%, I can see two explanations:

  • The report is not (correctly) generated.
    I would make sure that I can see coverage report of JaCoCo, without even running any SonarQube analysis.
    I’m sure you will find plenty of information online in order to make this work correctly.

  • The report is here, but not imported.
    In this case, I advise you to have a look at this guide. In addition, logs may contain useful information.

If the report is correctly generated, imported as suggested by the guide, and logs do not contain any clues, feel free to come back to us.


Thanks @Quentin. I was reporting that the sample produced from Sonar Source would not work with JUnit 5. I traded messages with the Jacoco team, and found the issue. The sample from Sonar Source does not specify the Surefire version in the POM. Unfortunately, the default version of Surefire will not work, and needs to be updated. Please let the person or team that manages those samples know that it would be best if they included (so that the sample works with both Junit4 or Junit5):

1 Like

Thanks for letting us know how you resolve this problem, it will hopefully help others!