From da7d4216129f9ddc43fa2754c40df341c2828d59 Mon Sep 17 00:00:00 2001 From: bryan cook <3217452+bryanbcook@users.noreply.github.com> Date: Tue, 28 May 2024 15:08:29 -0400 Subject: [PATCH] Addressed unmapped nunit top-level status #63 --- src/parsers/nunit.js | 1 + tests/data/nunit/nunit_v3_fail.xml | 12 ++++++++++++ tests/data/nunit/nunit_v3_pass.xml | 16 ++++++++++++++++ tests/parser.nunit.spec.js | 10 ++++++++++ 4 files changed, 39 insertions(+) create mode 100644 tests/data/nunit/nunit_v3_fail.xml create mode 100644 tests/data/nunit/nunit_v3_pass.xml diff --git a/src/parsers/nunit.js b/src/parsers/nunit.js index 9451fcd..dec9d2f 100644 --- a/src/parsers/nunit.js +++ b/src/parsers/nunit.js @@ -213,6 +213,7 @@ function getTestResult(json) { result.name = rawResult["@_fullname"] ?? rawResult["@_name"]; result.duration = (rawSuite["@_time"] ?? rawSuite["@_duration"]) * 1000; // in milliseconds + result.status = RESULT_MAP[rawSuite["@_result"]]; result.suites.push(...getTestSuites([rawSuite], null)); diff --git a/tests/data/nunit/nunit_v3_fail.xml b/tests/data/nunit/nunit_v3_fail.xml new file mode 100644 index 0000000..d51a89f --- /dev/null +++ b/tests/data/nunit/nunit_v3_fail.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/data/nunit/nunit_v3_pass.xml b/tests/data/nunit/nunit_v3_pass.xml new file mode 100644 index 0000000..c0f1145 --- /dev/null +++ b/tests/data/nunit/nunit_v3_pass.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/parser.nunit.spec.js b/tests/parser.nunit.spec.js index d5ef70a..54583f8 100644 --- a/tests/parser.nunit.spec.js +++ b/tests/parser.nunit.spec.js @@ -240,6 +240,16 @@ describe('Parser - NUnit', () => { assert.equal(testCaseWithAttachments.attachments[0].name, "my description") }); + it('Should report overall status as PASS if all tests pass', () => { + const result = parse({ type: 'nunit', files: [`${testDataPath}/nunit_v3_pass.xml`] }); + assert.equal(result.status, "PASS"); + }); + + it('Should report overall status as FAIL if any tests fail', () => { + const result = parse({ type: 'nunit', files: [`${testDataPath}/nunit_v3_fail.xml`] }); + assert.equal(result.status, "FAIL"); + }); + }); function sumCases(result, predicate) {