Junit testing with ``sonarscanner cli``

  • I am using sonarqube 7.9.3-community version.

  • For scanner, I am using docker sonar-scanner-cli , running in GitLab CI job to scan my code.

  • Now I want to include unit testing as well. For this what I have understood is:
    Sonarqube does not generate unit test reports. Instead it relies on test report generated by tools such as Jacoco.

  • How can I generate Junit test report with sonar-scanner -cli? I am using this sonarscaner-cli file to scan the code in GitLab CI job.

Hi,

You can’t. The two have nothing to do with each other.

 
HTH,
Ann

So if I need to generate a Junit test report, I need to use maven scanner?
and that maven scanner will generate code quality report as the sonar-scanner-cli is generating?

Hi,

Your JUnit test report will be generated before analysis. Generating such a report has nothing to do with which scanner you’re using.

 
Ann

Thank you for being so patient. Okay so if I generate a unit test report by using jacoco, will the scanner-cli will pick up the jacoco html report?

Hi,

Once you’ve generated your test report, you’ll need to explicitly feed it into analysis (just like you do your source code, & test code &…). You should find the relevant parameter in the docs.

 
Ann