2.0.0 • Published 2 years ago

mocha-qube-reporter v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

mocha-sonarqube-reporter

Disclaimer

This package is a fork of mocha-sonarqube-reporter. We decide to fork and publish this package because it seems all the open Pull Requests does not have activity in the last years. We acknowledgement the great job of the contributors of mocha-sonarqube-reporter <3.

mocha unit test reporter for sonar (>6.2)

inspired from :

According to this page, Sonar (> 6.2) not longer use 'generic test coverage', but 'generic Test Data'. This reporter provides the new compliant XML structure.

Usage

Install and save to your devDependencies

npm install --save-dev mocha-sonarqube-reporter
mocha --reporter mocha-sonarqube-reporter testFolder --reporter-options output=xunit.xml

On mocha-test for use with grunt

mochaTest: {
	sonar: {
		options: {
			reporter: 'mocha-sonarqube-reporter',
			quiet: true,
			reporterOptions:{
			  output : 'unit-tests.xml' // default to ./xunit.xml
			  useFullFilePath: 'true' // default to 'false'. Uses full test file paths in the report.
			}
		},
		src: [
			'app/**/*.spec.js'
		]
	}
}

Output example

<testExecutions version="1">
  <file path="testx/ClassOneTest.xoo">
    <testCase name="test1" duration="5"/>
    <testCase name="test2" duration="500">
      <skipped message="short message">other</skipped>
    </testCase>
    <testCase name="test3" duration="100">
      <failure message="short">stacktrace</failure>
    </testCase>
    <testCase name="test4" duration="500">
      <error message="short">stacktrace</error>
    </testCase>
  </file>
</testExecutions>

LICENSE

Licensed under the MIT license.