Import AngularJS Unit Test results into Sonarqube

1.7k views Asked by At

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/

2

There are 2 answers

4
Elena Vilchik On BEST ANSWER

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.

1
Raj N On

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