protractor-junit-xml-plugin
Advanced tools
Comparing version 1.0.1 to 1.1.0
35
index.js
@@ -10,2 +10,3 @@ 'use strict' | ||
let outputFile, | ||
OUTDIR_FINAL, | ||
xml, | ||
@@ -34,4 +35,9 @@ suites, | ||
let resolveCompleteFileName = (givenFileName, givenDir) => { | ||
const OUTDIR_FINAL = (givenDir || '_test-reports/e2e-test-results') + '/browser-based-results' | ||
let resolveCompleteFileName = (givenFileName, givenDir, uniqueFolder) => { | ||
// let OUTDIR_FINAL = '' | ||
if(uniqueFolder){ | ||
OUTDIR_FINAL = (givenDir || '_test-reports/e2e-test-results') + '/browser-based-results_' + browser.timeTillMinuteStamp; | ||
} else { | ||
OUTDIR_FINAL = (givenDir || '_test-reports/e2e-test-results') + '/browser-based-results'; | ||
} | ||
const FILE_NAME = currentCapabilities.get('browserName') + '-' + (givenFileName || 'test-results.xml') | ||
@@ -115,4 +121,4 @@ | ||
var pluginConfig = this.config; | ||
if(pluginConfig.uniqueName && pluginConfig.appendToFile) { | ||
throw new Error('You can not have a unique name every time as well as appending results to the same file') | ||
if(pluginConfig.uniqueName && pluginConfig.appendToFile || pluginConfig.uniqueFolder && pluginConfig.appendToFile) { | ||
throw new Error('You can not have a unique name or folder every time as well as appending results to the same file') | ||
} | ||
@@ -122,5 +128,5 @@ currentCapabilities = await browser.getCapabilities(); | ||
if (pluginConfig.uniqueName === false){ | ||
outputFile = resolveCompleteFileName(pluginConfig.filename, pluginConfig.outdir); | ||
outputFile = resolveCompleteFileName(pluginConfig.filename, pluginConfig.outdir, pluginConfig.uniqueFolder); | ||
} else { | ||
outputFile = resolveCompleteFileName(Math.round((new Date()).getTime() / 1000) + '.xml', pluginConfig.outdir); | ||
outputFile = resolveCompleteFileName(Math.round((new Date()).getTime() / 1000) + '.xml', pluginConfig.outdir, pluginConfig.uniqueFolder); | ||
} | ||
@@ -174,3 +180,18 @@ // console.log('OUTPUT FILE: ' +outputFile); | ||
JUnitXmlPlugin.prototype.teardown = async function () { | ||
console.log(JUNITXMLPLUGIN + 'inside Teardown') | ||
let pluginConfig = this.config; | ||
let vcsVersion = ' '; | ||
if(pluginConfig.useSapphireVCSBuildNumber) { | ||
vcsVersion = await browser.executeScript('return sapphireWebAppConfig.appVersion'); | ||
console.log('VCSVersion: ' + vcsVersion) | ||
} else if (pluginConfig.buildNumber !== 'Default') { | ||
vcsVersion = plugin.buildNumber; | ||
} | ||
let metaDataContents = '{buildNumber: ' + vcsVersion + '},\n{summary + ' + browser.params.metadataFile.summary + '}' | ||
fs.writeFile(OUTDIR_FINAL + "/Metadata.properties", metaDataContents, function (err) { | ||
if (err) { | ||
console.warn('Cannot write Metadata file xml\n\t' + err.message); | ||
} else { | ||
console.debug('Metadata file results written to Metadata.properties'); | ||
}}); | ||
let suite = suites[getBrowserId()]; | ||
@@ -177,0 +198,0 @@ |
{ | ||
"name": "protractor-junit-xml-plugin", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "A Protracotor plugin. Report results in junit xml format including requirement ids if available.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -44,5 +44,19 @@ # protractor-junit-xml-plugin | ||
appendToFile: If set to true, it will append xml data to the bottom of the file instead of creating a new file or overwriting the file. This can not be true if uniqueName is set to true. Default is false | ||
appendToFile: If set to true, it will append xml data to the bottom of the file instead of creating a new file or overwriting the file. This can not be true if uniqueName or uniqueFolder is set to true. Default is false | ||
uniqueFolder: If set to true, it will create a new directory for each time the test suite is run. | ||
useSapphireVCSBuildNumber: If set to true, this value will look for the sapphire vcs build number from the application and use it in the metadata file | ||
``` | ||
The following are the configureable params | ||
``` | ||
metadataFile.buildNumber: This is an optional value that can be set. If set it will create a Metadata.properties file in the test directory that will contain this and the summary value. | ||
metadataFile.summary: This is an optional value that can be set. If buildNumber is set, this value is placed in the created Metadata.properties file. | ||
``` | ||
## Usage | ||
@@ -49,0 +63,0 @@ |
14468
172
95