0.0.3 • Published 7 years ago

mocha-sonar-generic-reporter v0.0.3

Weekly downloads
72
License
MIT
Repository
github
Last release
7 years ago

Introduction

This is a mocha reporter project to integrate mocha unit tests to sonar Generic Test coverage unit tests execution results

It is a fork of mocha-sonar-generic-test-coverage that adds support for using the reporter alongside others with mocha-multi-reporters

This reporter is only for unit test success/failures verification, to unit test line coverage take a look on istanbul reporter

Installation

npm install mocha-sonar-generic-reporter --save-dev

On pure mocha

mocha --reporter mocha-sonar-generic-reporter testFolder

On mocha-test for use with grunt

mochaTest: {
	coverage: {
		options: {
			reporter: 'mocha-sonar-generic-reporter',
			quiet: false,
			captureFile: null, // default mocha test capture file variable
			reporterOptions: {
				outputFile: null, // relative path file to capture instead append to captureFile (this file will not get prints at stdout) 
				useFileFullPath: false // generate report for the files using fullpath
			}
		}
		},
		src: [
			'test.js'
		]
	}
}

Testing

$ npm install && npm test

Report demo sample

$ npm install && \
cd demo && \
npm install && \
npm start

Output example

<unitTest version="1">
	<file path="src/main/java/com/example/MyClass.java">
		<testCase name="test1" duration="500"/>
		<testCase name="test2" duration="600"/>
		<testCase name="test3" duration="600">
			<failure message="sort message">long stacktrace</failure>
		</testCase>
		<testCase name="test4" duration="600">
			<error message="sort message">long stacktrace</error>
		</testCase>
		<testCase name="test5" duration="600">
			<skipped message="sort message">long stacktrace</skipped>
		</testCase>
	</file>
</unitTest>