1

We are try to integrate sonarcloud with circleci, for each commit our circleci will trigger a build with test cases and project is based on Nodejs. Once the execution is completed, still the dashboard shows code coverage % as 0.

sonar-project.properties

sonar.projectName=test sonar.language=js sonar.sources=src
sonar.tests=src/app/client/src/app/
sonar.javascript.lcov.reportPaths=src/app/client/coverage/lcov.info
sonar.projectKey=harshavardhanc_test 
sonar.organization=harshavardhanc
sonar.host.url=https://sonarcloud.io sonar.login=xxxxxxxxx

In the end of circleci build we are calling sonar scanner command and the execution says successfull.

Please help me how to get coverage value in dashboard.

philnash
  • 70,667
  • 10
  • 60
  • 88
Harsha
  • 153
  • 1
  • 10
  • You need to verify if the coverage info file is generated in the correct format. Then you have to investigate the SonarQube logs (raise the log level if needed). After doing that, update your question also adding some version information. Be sure you use a [LTS version](https://www.sonarqube.org/downloads/). – Jeroen Heier Aug 10 '19 at 06:22
  • I'm also having the same problem. Before updating to the 6.7.7 LTS version, my projects were showing the coverage report. After updation, the coeverage reports are not there! I double checked everything and no configs are changed from project side. Is this a migration bug from sonarqube? – Vighnesh Pai Aug 12 '19 at 11:34
  • Please include the output of the scanner run. It probably mentions something about the coverage. (Btw, is your project on SonarCloud public or private?) – janos Oct 05 '19 at 18:41

1 Answers1

0

Sonarqube and sonar scanner do not provide tooling to generate code coverage reports. Sonarqube is used to analyse the outcome of a coverage report and translate this to a human readable format with severity etc.

To get a coverage report you need to pick a tool that can generate this for you. A good place to start would be the Test Coverage & Execution page. They seem to say that LCOV could generate a report for javascript that Sonarqube can process.

You can then point the sonar scanner to the output of the LCOV coverage report files with the sonar.javascript.lcov.reportPaths property.

so you will basically need the following steps for your analysis:

  1. Sonar scanner begin
  2. Restore packages
  3. Build application
  4. Use code coverage tool to test and calculate the coverage for your application
  5. Sonar scanner end
Ebbelink
  • 574
  • 3
  • 16
  • I believe the questioner as mentioned in the snippet has already done this: sonar.javascript.lcov.reportPaths=src/app/client/coverage/lcov.info – Vighnesh Pai Aug 13 '19 at 03:48
  • For me, it is for the Java spring boot projects as well. So I'm guessing either something is deprecated or there is a bug on sonarqube (highly unlikely since this will be P0) – Vighnesh Pai Aug 13 '19 at 03:49
  • 1
    From the snippet given I cannot come to the conclusion that the code coverage is actually calculated. The snippet only implies the use but nowhere is an explicit statement that this is done. – Ebbelink Aug 13 '19 at 06:32
  • yeah I have report which is already generated through our test cases, facing the while reporting this coverage report to sonarcloud. – Harsha Aug 13 '19 at 07:10
  • BTW, which version of the Sonarqube is being used? And were there any updates to server? Not much aware about sonar cloud. I' facing this issue after the sonarqube server update so asking. – Vighnesh Pai Aug 13 '19 at 07:43
  • @harsha do you see a new Project Analysis in the administration -> Background Tasks for the project? – Ebbelink Aug 13 '19 at 08:09