move system output into the testcase elements in junit xml

This commit is contained in:
Spencer Alger
2015-03-30 11:43:51 -07:00
parent 7d837f704c
commit 79a53767e3
2 changed files with 29 additions and 7 deletions

View File

@ -136,8 +136,20 @@ function JenkinsReporter(runner) {
name: test.title,
time: test.duration,
pass: test.state === 'passed',
test: test
test: test,
stdout: stack[0].stdout,
stderr: stack[0].stderr
});
stack[0].stdout = stack[0].stderr = '';
}
});
runner.on('hook end', function (hook) {
if (hook.title.indexOf('"after each"') > -1 && stack[0] && stack[0].results.length) {
var result = _.last(stack[0].results);
result.stdout += stack[0].stdout;
result.stderr += stack[0].stderr;
stack[0].stdout = stack[0].stderr = '';
}
});

View File

@ -78,19 +78,29 @@ function makeJUnitXml(runnerName, testDetails) {
type: 'TestError'
});
}
giveOutput(testcase, testInfo);
});
if (suiteInfo.suites) {
_.each(suiteInfo.suites, serializeSuite);
}
if (suiteInfo.stdout.trim()) {
suite.ele('system-out', {}).cdata(chalk.stripColor(suiteInfo.stdout));
}
if (suiteInfo.stderr.trim()) {
suite.ele('system-err', {}).cdata(chalk.stripColor(suiteInfo.stderr));
}
giveOutput(suite, suiteInfo);
});
return suites.toString({ pretty: true});
}
function giveOutput(el, info) {
var out = info.stdout.trim();
var err = info.stderr.trim();
if (out) {
el.ele('system-out', {}).cdata(chalk.stripColor(out));
}
if (err) {
el.ele('system-err', {}).cdata(chalk.stripColor(err));
}
}