@intuit/judo
Version:
Test command line interfaces.
33 lines (30 loc) • 1.31 kB
JavaScript
;Object.defineProperty(exports, "__esModule", { value: true });exports.XunitReporter = void 0;var _ReporterInterface = require("./ReporterInterface");
var _numberUtil = require("../common/number-util");
class XunitReporter extends _ReporterInterface.ReporterInterface {
constructor({ stepResults }) {
super({
stepResults,
type: 'XUnit',
outputFile: './junit.xml' });
}
generateReport() {
let previousStepFilePath = '';
let xml = '';
xml += `<testsuites name="Judo Tests">\n`;
this.stepResults.forEach(stepResult => {
if (stepResult.getStepFilePath() !== previousStepFilePath) {
if (previousStepFilePath !== '') {
xml += ` </testsuite>\n`;
}
xml += ` <testsuite name="${stepResult.getStepFilePath()}">\n`;
previousStepFilePath = stepResult.getStepFilePath();
}
xml += ` <testcase name="${stepResult.getStepName()}" time="${(0, _numberUtil.truncateAfterDecimal)(stepResult.getDuration() / 1000, 5)}">\n`;
if (!stepResult.getPassed()) {
xml += ` <failure message="${stepResult.getErrorMessage()}"></failure>\n`;
}
xml += ` </testcase>\n`;
});
xml += ` </testsuite>\n</testsuites>`;
return xml;
}}exports.XunitReporter = XunitReporter;