diff --git a/package-lock.json b/package-lock.json index de6608e..21cae88 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "test-results-parser", - "version": "0.1.1", + "version": "0.1.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 4dbfb59..51e0356 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "test-results-parser", - "version": "0.1.1", + "version": "0.1.2", "description": "Parse test results from JUnit, TestNG, xUnit, cucumber and many more", "main": "src/index.js", "types": "./src/index.d.ts", diff --git a/src/parsers/junit.js b/src/parsers/junit.js index 2fd89e4..1e299e5 100644 --- a/src/parsers/junit.js +++ b/src/parsers/junit.js @@ -39,11 +39,13 @@ function getTestSuite(rawSuite) { */ function setAggregateResults(result) { if (Number.isNaN(result.passed) || Number.isNaN(result.failed)) { + let total = 0; let passed = 0; let failed = 0; let errors = 0; let skipped = 0; result.suites.forEach(_suite => { + total = _suite.total + total; passed = _suite.passed + passed; failed = _suite.failed + failed; errors = _suite.errors + errors; @@ -53,6 +55,7 @@ function setAggregateResults(result) { result.failed = failed; result.errors = errors; result.skipped = skipped; + result.total = total; } } diff --git a/tests/data/junit/newman-failures.xml b/tests/data/junit/newman-failures.xml new file mode 100644 index 0000000..5dab956 --- /dev/null +++ b/tests/data/junit/newman-failures.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/parser.junit.spec.js b/tests/parser.junit.spec.js index 0cd488f..53d54c8 100644 --- a/tests/parser.junit.spec.js +++ b/tests/parser.junit.spec.js @@ -327,4 +327,91 @@ describe('Parser - JUnit', () => { }); }); + it('parse newman with failures', () => { + const result = parse({ type: 'junit', files: ['tests/data/junit/newman-failures.xml'] }); + console.log(JSON.stringify(result, null, 2)) + assert.deepEqual(result, { + "id": "", + "name": "MainApi", + "total": 3, + "passed": 1, + "failed": 2, + "errors": 0, + "skipped": 0, + "retried": 0, + "duration": 37506, + "status": "FAIL", + "suites": [ + { + "id": "", + "name": "Main / GetSectors", + "total": 2, + "passed": 0, + "failed": 2, + "errors": 0, + "skipped": 0, + "duration": 446, + "status": "FAIL", + "cases": [ + { + "id": "", + "name": "Sectors - Verify 'Residential' is in list", + "total": 0, + "passed": 0, + "failed": 0, + "errors": 0, + "skipped": 0, + "duration": 446, + "status": "FAIL", + "failure": "expected to include 'Residntial'", + "stack_trace": "", + "steps": [] + }, + { + "id": "", + "name": "Sectors EndPoint - returns a JSON response", + "total": 0, + "passed": 0, + "failed": 0, + "errors": 0, + "skipped": 0, + "duration": 446, + "status": "PASS", + "failure": "", + "stack_trace": "", + "steps": [] + } + ] + }, + { + "id": "", + "name": "Main / Verifyresponsedata-MarketAsset", + "total": 1, + "passed": 1, + "failed": 0, + "errors": 0, + "skipped": 0, + "duration": 634, + "status": "PASS", + "cases": [ + { + "id": "", + "name": "Market Asset(id-387) response - data is as expected", + "total": 0, + "passed": 0, + "failed": 0, + "errors": 0, + "skipped": 0, + "duration": 634, + "status": "PASS", + "failure": "", + "stack_trace": "", + "steps": [] + } + ] + } + ] + }); + }); + }); \ No newline at end of file