How to tell Sonar to use my surefire reports for unit test results
Asked Answered
P

2

6

We have a Jenkins job that contains a bunch of javascript files. We build our project via grunt, and at the end of the build we run JSCover to run our unit tests and collect code coverage. It all works. We get a nice LCOV file, and we get a bunch of TEST-*.xml in the target/surefire-reports/ directory.

Sonar displays the code coverage results, but it doesn't show the number of tests that passed/failed or even executed.

How do I tell sonar to use the surefire reports? I thought by setting this property, it would consume it, but no love:

sonar.surefire.reportsPath=target/surefire-reports

Here is my project properties file:

# project metadata (required)
sonar.projectKey=pure.cloud.browser.app
sonar.projectName=Pure Cloud Browser App
sonar.projectVersion=1.0
# path to source directories (required)
sonar.sources=src
sonar.exclusions=js/lib/**,js/test/lib/**,js/test/tools/**
# The value of the property must be the key of the language.
sonar.language=js

# Advanced parameters
sonar.surefire.reportsPath=target/surefire-reports
sonar.javascript.lcov.reportPath=target/test-coverage/jscover.lcov
sonar.dynamicAnalysis=reuseReports

Thank you, Fabrice, for recommending me the following link in my previous question: https://github.com/SonarSource/sonar-examples/tree/master/projects/languages/javascript/javascript-sonar-runner-JsTestDriver but I can't find a way to tell Sonar to somehow display the unit test results (number of tests, number of failures, etc) that are stored in the surefire-reports directory.

Any ideas?

Percussive answered 2/4, 2013 at 17:53 Comment(3)
With Sonar Javascript 1.3, "sonar.surefire.reportsPath" has been replaced by "sonar.javascript.jstestdriver.reportsPath": have you tried it?Nila
You are right! I didn't know it was replaced. It works like a charm. Thank you again, Fabrice!Percussive
OK, I will add this as an answer so that you can validate it for other users.Nila
N
6

With Sonar Javascript 1.3, "sonar.surefire.reportsPath" has been replaced by "sonar.javascript.jstestdriver.reportsPath".

Nila answered 3/4, 2013 at 13:31 Comment(1)
as this property no longer exists, what is currently the proper way how to upload test reports to Sonar?Fattal
A
2

this property no longer exists. see http://jira.codehaus.org/browse/SONARJS-163

Advertisement answered 25/3, 2014 at 18:1 Comment(1)
This link no longer existsShabbygenteel

© 2022 - 2024 — McMap. All rights reserved.