Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow customization of testsuite name attribute #173

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ module.exports = function(config) {
useBrowserName: true, // add browser name to report and classes names
nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element
classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element
suiteNameFormatter: undefined, // function (browser) to customize the name attribute in xml testsuite element
properties: {}, // key value pair of properties to add to the <properties> section of the report
xmlVersion: null // use '1' if reporting to be per SonarQube 6.2 XML format
}
Expand Down
10 changes: 9 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ function defaultNameFormatter (browser, result) {
return result.suite.join(' ') + ' ' + result.description
}

function defaultSuiteNameFormatter (browser) {
return browser.name
}

var JUnitReporter = function (baseReporterDecorator, config, logger, helper, formatError) {
var log = logger.create('reporter.junit')
var reporterConfig = config.junitReporter || {}
Expand All @@ -25,6 +29,7 @@ var JUnitReporter = function (baseReporterDecorator, config, logger, helper, for
var useBrowserName = reporterConfig.useBrowserName
var nameFormatter = reporterConfig.nameFormatter || defaultNameFormatter
var classNameFormatter = reporterConfig.classNameFormatter
var suiteNameFormatter = reporterConfig.suiteNameFormatter || defaultSuiteNameFormatter
var properties = reporterConfig.properties
// The below two variables have to do with adding support for new SonarQube XML format
var XMLconfigValue = reporterConfig.xmlVersion
Expand Down Expand Up @@ -75,11 +80,14 @@ var JUnitReporter = function (baseReporterDecorator, config, logger, helper, for
exposee = suite.ele('file', {'path': 'fixedString'})
} else {
suite = suites[browser.id] = builder.create('testsuite')
suite.att('name', browser.name)
suite.att('name', suiteNameFormatter(browser))
.att('package', pkgName)
.att('timestamp', timestamp)
.att('id', 0)
.att('hostname', os.hostname())

suite.att('browser', browser.name)

var propertiesElement = suite.ele('properties')
propertiesElement.ele('property', {name: 'browser.fullName', value: browser.fullName})

Expand Down