0
votes

I have below problems with SonarRunner.

SonarQube along with Sonar runner unable to pull junit format xml reports

Unit Tests or Test Coverage widget doesn't show up. It says No Data. I am following instructions described here

I manually created report file in XML format as described, but still no luck.

Below is the XML file - TEST-Firefox_210_Mac_OS.com.company.BarTest.xml,

<testsuite name="Firefox_210_Mac_OS.com.company.BarTest" errors="0" failures="0" tests="3" time="0.0">
  <testcase classname="Firefox_210_Mac_OS.com.company.BarTest" name="testfullName" time="0.0"/>
</testsuite>

To pull the Unit Test execution report to show on sonar dashboard. I have used sample git project from here

and below is my sonar-project.properties,

# project metadata (required)
sonar.projectKey=org.codehaus.sonar:javascript-sonar-runner-jstestdriver
sonar.projectName=JavaScript project with Sonar Runner reusing reports generated by JsTestDriver
sonar.projectVersion=1.0

# path to source directories (required)
sonar.sources=C:/Sonar/sonar-runner-dist-2.4/sonar-runner-2.4/projects/sources

# path to tests source directories (required)
sonar.tests=C:/Sonar/sonar-runner-dist-2.4/sonar-runner-2.4/projects/tests

sonar.javascript.jstestdriver.reportsPath=C:/Sonar/sonar-runner-dist-2.4/sonar-runner-2.4/projects/target/TEST-Firefox_210_Mac_OS.com.company.BarTest.xml


sonar.sourceEncoding=UTF-8

below is my jsTestDriver.conf

server: http://localhost:9876

load:
 - C:/Sonar/sonar-runner-dist-2.4/sonar-runner-2.4/projects/sources/*.js
 - C:/Sonar/sonar-runner-dist-2.4/sonar-runner-2.4/projects/sources/com/company/*.js
test:
 - C:/Sonar/sonar-runner-dist-2.4/sonar-runner-2.4/projects/tests/*.js
 - C:/Sonar/sonar-runner-dist-2.4/sonar-runner-2.4/projects/tests/com/company/*.js

plugin:
 - name: "coverage"
   jar: "coverage-1.3.5.jar"
   module: "com.google.jstestdriver.coverage.CoverageModule"

My sonarqube is running on port : 9000 and below is the screen shot. As you see SonarRunner and jsTestDriver just doing a code analysis and not showing any unit tests.

enter image description here

1
The SonarQube docs site says nothing of the kind about js-test-driver. It merely says that it will import js-test-driver's reports.G. Ann - SonarSource Team
Thanks. Edited my post.rajcool111
Am I missing any plugins? What plugin will need to read this report?rajcool111

1 Answers

0
votes

SonarQube doc website says jsTestDriver will run the javascript unit tests and copy the results in target folder in XML format

SonarQube doesnt run your Unit Tests, it just gathers the reports generated from your manuall run or other tools automatic run (like: Jenkins).

From SonarQube doc:

Prior to the SonarQube analysis, execute your unit tests in order to generate XML report. The JUnit like XML format supported is the one generated by js-test-driver


Then I manually created report file in XML format as described, but still no luck.

If you created manually the report files and reports are still not showing, check your paths if ok.Check if sonar is really reading data from C:/Sonar/sonar-runner-dist-2.4/sonar-runner-2.4/projects/ path