Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Commit

Permalink
[junit] only include stdout in report for failures (elastic#60530)
Browse files Browse the repository at this point in the history
* [junit] only include stdout in report for failures

* fix assertion

Co-authored-by: spalger <[email protected]>
  • Loading branch information
Spencer and spalger committed Mar 19, 2020
1 parent 053da12 commit da7192b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/dev/mocha/__tests__/junit_report_generation.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ describe('dev/mocha/junit report generation', () => {
name: 'SUITE SUB_SUITE never runs',
'metadata-json': '{}',
},
'system-out': testFail['system-out'],
'system-out': ['-- logs are only reported for failed tests --'],
skipped: [''],
});
});
Expand Down
4 changes: 3 additions & 1 deletion src/dev/mocha/junit_report_generation.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,15 @@ export function setupJUnitReportGeneration(runner, options = {}) {

[...results, ...skippedResults].forEach(result => {
const el = addTestcaseEl(result.node);
el.ele('system-out').dat(escapeCdata(getSnapshotOfRunnableLogs(result.node) || ''));

if (result.failed) {
el.ele('system-out').dat(escapeCdata(getSnapshotOfRunnableLogs(result.node) || ''));
el.ele('failure').dat(escapeCdata(inspect(result.error)));
return;
}

el.ele('system-out').dat('-- logs are only reported for failed tests --');

if (result.skipped) {
el.ele('skipped');
}
Expand Down

0 comments on commit da7192b

Please sign in to comment.