From 79a53767e3342c9a9cd309cfe7207d1cfc462a19 Mon Sep 17 00:00:00 2001 From: Spencer Alger Date: Mon, 30 Mar 2015 11:43:51 -0700 Subject: [PATCH] move system output into the testcase elements in junit xml --- test/utils/jenkins-reporter.js | 14 +++++++++++++- test/utils/make_j_unit_xml.js | 22 ++++++++++++++++------ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/test/utils/jenkins-reporter.js b/test/utils/jenkins-reporter.js index 4b5b9f620..64cc6a7e7 100644 --- a/test/utils/jenkins-reporter.js +++ b/test/utils/jenkins-reporter.js @@ -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 = ''; } }); diff --git a/test/utils/make_j_unit_xml.js b/test/utils/make_j_unit_xml.js index 2aaa8ad14..01cf06c04 100644 --- a/test/utils/make_j_unit_xml.js +++ b/test/utils/make_j_unit_xml.js @@ -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)); + } +} \ No newline at end of file