Skip to content

Commit

Permalink
fixed collecting duration for JUnit reports (#475)
Browse files Browse the repository at this point in the history
Co-authored-by: DavertMik <davert@testomat.io>
  • Loading branch information
DavertMik and DavertMik authored Jan 8, 2025
1 parent f6c132a commit 80954e1
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/xmlReader.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,16 @@ class XmlReader {
}

processJUnit(jsonSuite) {
const { testsuite, name, tests, failures, errors, time } = jsonSuite;
const { testsuite, name, tests, failures, errors } = jsonSuite;

reduceOptions.preferClassname = this.stats.language === 'python';
const resultTests = processTestSuite(testsuite);

const hasFailures = resultTests.filter(t => t.status === 'failed').length > 0;
const status = failures > 0 || errors > 0 || hasFailures ? 'failed' : 'passed';

const time = testsuite.time || 0;
// debug('time', jsonSuite, time)
if (time) {
if (!this.stats.duration) this.stats.duration = 0;
this.stats.duration += parseFloat(time);
Expand Down Expand Up @@ -419,19 +421,18 @@ class XmlReader {
this.formatErrors();
this.formatTests();

debug('Uploading data', {
...this.stats,
tests: this.tests,
});

const dataString = {
...this.stats,
detach: this.requestParams.detach,
api_key: this.requestParams.apiKey,
status: 'finished',
duration: this.stats.duration,
tests: this.tests,
};

debug('Uploading data', dataString);

return Promise.all(this.pipes.map(p => p.finishRun(dataString)));
}

Expand Down

0 comments on commit 80954e1

Please sign in to comment.