|
Hi Users@Sonar,
As the pull request is not integrated (yet?), here is a short description on how use Sonar with the JavaScript plugin on your favorite JavaScript project. The full example-project can be found at https://github.com/StevenLooman/mco.
The JavaScript plugin expects test results in the xUnit format, with filenames using the convention TEST-<name>.xml. Mocha has an xUnit reporter, which we should use. Getting coverage data requires a bit more work. First, be sure to install the new LCOV reporter, currently available here: https://raw.github.com/StevenLooman/mocha/master/lib/reporters/lcov.js. I use the following script to get the test results in the xUnit format, and coverage data in the LCOV format: rm -rf lib-cov--- snip --- #!/usr/bin/env bash rm -rf coverage mkdir coverage echo Running mocha node-jscoverage lib lib-cov mv lib lib-orig mv lib-cov lib mocha -R lcov > coverage/coverage.lcov mocha -R xunit > coverage/TEST-all.xml rm -rf libmv lib-orig lib --- snip --- Finally, the Sonar/JavaScript plugin needs to know where to get the test/coverage data. This is done by setting the following properties:
sonar.javascript.jstestdriver.reportsfolder=coverage sonar.javascript.jstestdriver.coveragefile=coverage.lcov sonar.dynamicAnalysis=reuseReports If all is set right, the JavaScript plugin will pick up the TEST-all.xml file for the test results, and the coverage.lcov file for the coverage data.
Regards, Steven Looman |
|
FYI,
The pull request was not integrated, but TJ Holowaychuck proposed a different solution: reporters can be loaded from other modules as well. At the moment the version of Mocha in Npm does not support this, but HEAD (GitHub) does.
I have put the LCOV reporter in a seperate module. Npm package: mocha-lcov-reporter. See https://github.com/StevenLooman/mocha-lcov-reporter. Replace the line:
mocha -R lcov > coverage/coverage.lcov by mocha -R mocha-lcov-reporter > coverage/coverage.lcov Regards, Steven
On Mon, Jul 2, 2012 at 10:37 PM, Steven Looman <[hidden email]> wrote: Hi Users@Sonar, |
| Powered by Nabble | Edit this page |
