Reputation: 1163
I am using SonarQube Version 8.9.2 (build 46101) and I want to export the test results to the SonarQube portal under my project.
I was able to push the result of the scan including the code coverage to the SonarQube portal but I am not able to push\export the Unit test result of my Angular code. The build is successful but still the Unit test result are not exported. I still see - above Unit Tests like below,
I am able to generate the XML file in Generic Test Execution format as mentioned in SonarQube documentation like below,
I am using the below Sonar properties in my Azure DevOps Classic UI pipeline,
sonar.sourceEncoding=UTF-8
sonar.sources=$(Build.SourcesDirectory)/NextGen
sonar.exclusions=**/node_modules/**,**/*.spec.ts,NextGen/src/Tools/**
sonar.tests=$(Build.SourcesDirectory)/NextGen/src
sonar.verbose=true
sonar.test.inclusions=**/*.spec.ts
sonar.ts.tslint.configpath=tslint.json
sonar.typescript.exclusions=**/node_modules/**,**/typings.d.ts,**/main.ts,**/environments/environment*.ts,**/*routing.module.ts
sonar.javascript.lcov.reportPaths=NextGen/coverage/lcov.info
sonar.testExecutionReportPaths=NextGen\src\testresults\unittest\unit-test-result.xml
sonar.buildbreaker.skip=true
Would appreciate if anyone could help me to resolve this last thing pending for me on how to export the unit test result to SonarQube.
Upvotes: 1
Views: 3472
Reputation: 1463
Your sonar-project.properties
seems to be good. You may add :
If you use Karma, you have to add karma-sonarqube-unit-reporter
dependency in package.json
and to add something in karma.config.js
:
...
plugins: [
...
require("karma-sonarqube-unit-reporter"),
...
],
sonarQubeUnitReporter: {
sonarQubeVersion: "LATEST",
outputFile: "NextGen\src\testresults\unittest\unit-test-result.xml",
overrideTestDescription: true,
testPaths: ["$(Build.SourcesDirectory)/NextGen/src"],
testFilePattern: ".spec.ts",
useBrowserName: false,
},
reporters: ["sonarqubeUnit"],
...
Upvotes: 1
Reputation: 765
On the official community site for JS/TS languages following can be found:
JavaScript/TypeScript
Test Data Converters to Generic Test Data format
for Jest jest-sonar-reporter
for Karma karma-sonarqube-unit-reporter
Upvotes: 1