Is there a karma reporter which can be used to generate a results.xml
file which is compatible with the sonar Generic Test Coverage plugin? Or alternatively a parser for the junit file which is output by karma-junit-reporter
and which will work with the generic plugin?
I am using SonarQube 5.3 and Karma / Jasmine
I want to import the junit reports that come from karma into SonarQube but cannot see a way to do this easily. Something like https://www.npmjs.com/package/mocha-sonar-generic-test-coverage for karma
FYI I have seen
karma-junit-sonarqube-reporter
(https://www.npmjs.com/package/karma-junit-sonarqube-reporter) but that seems to expect the name of the test to match the path to the file which is too restrictive for me.
karma-sonarqube-unit-reporter
seems to be unfinished
grunt-karma-sonar
seems to rely on jstestdriver
which is deprecated
I managed to achieve this by doing the following.
To get javascript junit reports into sonar
sonar-karma-test-report-plugin-1.0.0.4.jar
which is not available via the update center/usr/local/Cellar/sonar/5.3/libexec/extensions/plugins
and restart sonarTell karma to omit the name of the browser
junitReporter: {
useBrowserName: false
}
Get Karma to create a junit xml file via the normal karma-junit-reporter and have it call the file TESTS-xunit.xml
(I had the file called test-results.xml
and sonar would not detect it WTF)
In the sonar-project.properties
file set sonar.javascript.karmajstestdriver.reportsPath=reports/js/unit-components/results/
sonar-runner
Sonar requires the path to the test file in order to process the report. Jasmine does not make this available to the reporter. My understanding is the sonar plugin iterates over xml file and finds the classname for each test which has the test name (ie my cool tests
) and does a string replace to change that to the location of the file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With