1

I am trying to import Unit Test results into Sonarqube for AngularJS code using Jasmine framework and Karma.

I have tried with multiple reporter like karma-junit-reporter, karma-sonarqube-unit-reporter and able to produce the results.

However, i am not able to import the unit test results into Sonarqube using "sonar-scanner". Other reports like Bug, Code Smell, Coverage are being showed in the dashboard but Unit Test reports aren't.

Can someone guide me on how to import and display Unit Test results in Sonarqube.

Sonarqube 6.5
SonarQube Scanner 3.0.3.778
Java 1.8.0_121 Oracle Corporation (64-bit)
Windows 7 6.1 amd64

Sonar-Scanner properties

sonar.projectKey=unit_test
sonar.projectName=js
sonar.projectVersion=1.0
sonar.sources=public/js
sonar.javascript.lcov.reportPaths=reports/coverage/lcov.info
sonar.javascript.karmajstestdriver.reportsPath=reports/junit/

Stefan Birkner
  • 24,059
  • 12
  • 57
  • 72
Raghav
  • 13
  • 3

2 Answers2

1

Import of unit tests is not provided by SonarJS anymore, and it's provided by SonarQube itself (since 6.2). Here is documentation about it.

Elena Vilchik
  • 1,085
  • 6
  • 11
  • I tried with the test execution sample and used "sonar.testExecutionReportPaths" in the sonar property file. Sonar scanner was executed successfully but in Sonarqube Dashboard i am not able to see test report. The sonar property file content is below. sonar.testExecutionReportPaths=reports/junit/TESTS-results.x‌​ml sonar.sourceEncoding=UTF-8 Can you please suggest is there anything else needs to be taken care? – Raghav Oct 23 '17 at 14:18
  • 1
    I found the solution and able to import and Display Unit Test report successfully to Sonarqube – Raghav Oct 23 '17 at 16:18
  • 1
    Raghav can you please provide the solution that you found – abhishek saatal Mar 28 '18 at 10:08
  • @Raghav What's the solution that you found – ben rhouma moez May 21 '21 at 12:32
0

Just set this property sonar.ts.coverage.lcovReportPath=coverage/lcov.info

sonar.projectKey=DEMO-FORM
sonar.projectName=DEMO-FORM
sonar.projectVersion=1.0
sonar.sourceEncoding=UTF-8
sonar.sources=src
sonar.host.url=http://localhost:9000
sonar.login=e41e6e5cdc17b412e76d0c3c6a6cca77e5517910
sonar.exclusions=**/node_modules/**
sonar.inclusions=src/**/*
sonar.tests=src
sonar.test.inclusions=**/*.spec.ts
sonar.ts.tslintconfigpath=tslint.json
sonar.typescript.lcov.reportPaths=coverage/lcov.info
Raj N
  • 249
  • 1
  • 18