diff --git a/src/parsers/nunit.js b/src/parsers/nunit.js
index b6c0769..dec9d2f 100644
--- a/src/parsers/nunit.js
+++ b/src/parsers/nunit.js
@@ -127,7 +127,7 @@ function getTestCases(rawSuite, parent_meta) {
let result = rawCase["@_result"]
testCase.id = rawCase["@_id"] ?? "";
testCase.name = rawCase["@_fullname"] ?? rawCase["@_name"];
- testCase.duration = rawCase["@_time"] * 1000; // in milliseconds
+ testCase.duration = (rawCase["@_time"] ?? rawCase["@_duration"]) * 1000; // in milliseconds
testCase.status = RESULT_MAP[result];
// v2 : non-executed should be tests should be Ignored
@@ -177,7 +177,7 @@ function getTestSuites(rawSuites, assembly_meta) {
let suite = new TestSuite();
suite.id = rawSuite["@_id"] ?? '';
suite.name = rawSuite["@_fullname"] ?? rawSuite["@_name"];
- suite.duration = rawSuite["@_time"] * 1000; // in milliseconds
+ suite.duration = (rawSuite["@_time"] ?? rawSuite["@_duration"]) * 1000; // in milliseconds
suite.status = RESULT_MAP[rawSuite["@_result"]];
const meta_data = new Map();
@@ -212,7 +212,8 @@ function getTestResult(json) {
const rawSuite = rawResult["test-suite"][0];
result.name = rawResult["@_fullname"] ?? rawResult["@_name"];
- result.duration = rawSuite["@_time"] * 1000; // in milliseconds
+ 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_v2.xml b/tests/data/nunit/nunit_v2.xml
index 7a645c6..83534c3 100644
--- a/tests/data/nunit/nunit_v2.xml
+++ b/tests/data/nunit/nunit_v2.xml
@@ -20,7 +20,7 @@
+]]>
@@ -68,7 +68,7 @@
+]]>
diff --git a/tests/data/nunit/nunit_v3.xml b/tests/data/nunit/nunit_v3.xml
index b273cee..39ee4f2 100644
--- a/tests/data/nunit/nunit_v3.xml
+++ b/tests/data/nunit/nunit_v3.xml
@@ -1,7 +1,8 @@
-
-
-
+
+
+
+
@@ -9,7 +10,7 @@
-
+
@@ -17,7 +18,7 @@
-
+
-
-
+
+
-
+
-
+
-
+
@@ -53,7 +54,7 @@
-
+
@@ -61,7 +62,7 @@
-
+
@@ -69,21 +70,21 @@
-
+
-
+
-
+
@@ -91,13 +92,13 @@
-
-
-
-
+
+
+
+
-
+
@@ -105,24 +106,24 @@
-
-
-
-
+
+
+
+
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
c:\absolute\filepath\dummy.txt
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 b4c471d..54583f8 100644
--- a/tests/parser.nunit.spec.js
+++ b/tests/parser.nunit.spec.js
@@ -113,7 +113,8 @@ describe('Parser - NUnit', () => {
assert.equal(result.total, 19);
assert.equal(result.passed, 13);
assert.equal(result.failed, 2);
- assert.equal(result.errors, 1);
+ assert.equal(result.errors, 1);
+ assert.equal(result.skipped, 3);
// compare sum of suite totals to testresult
assert.equal( result.suites.reduce( (total, suite) => { return total + suite.total},0), result.total);
@@ -239,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) {