Skip to content

Commit

Permalink
Addressed unmapped nunit top-level status #63
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanbcook committed May 28, 2024
1 parent 343fed2 commit da7d421
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/parsers/nunit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
12 changes: 12 additions & 0 deletions tests/data/nunit/nunit_v3_fail.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<test-run id="2" testcasecount="1" result="Failed" duration="0.154" total="1" passed="0" failed="1" inconclusive="0" skipped="0" asserts="0" start-time="2024-05-28 17:06:00Z" end-time="2024-05-28 17:06:01Z">
<test-suite type="Assembly" id="1036" name="mock-assembly.dll" fullname="D:\Dev\NUnit\nunit-3.0\work\bin\vs2008\Debug\mock-assembly.dll" testcasecount="25" runstate="Runnable" result="Failed" duration="0.154" total="1" passed="1" failed="0" inconclusive="0" skipped="0" asserts="0">
<test-suite type="TestFixture" id="1000" name="MockTestFixture" fullname="NUnit.Tests.Assemblies.MockTestFixture" testcasecount="1" result="Failed" duration="0.119" total="1" passed="0" failed="1" inconclusive="0" skipped="0" asserts="0">
<test-case id="1001" name="MockTest1" fullname="NUnit.Tests.Assemblies.MockTestFixture.MockTest1" result="Failed" duration="0.000" asserts="0">
<properties>
<property name="Description" value="Mock Test #1" />
</properties>
</test-case>
</test-suite>
</test-suite>
</test-run>
16 changes: 16 additions & 0 deletions tests/data/nunit/nunit_v3_pass.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<test-run id="2" testcasecount="1" result="Passed" duration="0.154" total="1" passed="1" failed="0" inconclusive="0" skipped="0" asserts="0" start-time="2024-05-28 17:06:00Z" end-time="2024-05-28 17:06:01Z">
<test-suite type="Assembly" id="1036" name="mock-assembly.dll" fullname="D:\Dev\NUnit\nunit-3.0\work\bin\vs2008\Debug\mock-assembly.dll" testcasecount="25" runstate="Runnable" result="Passed" duration="0.154" total="1" passed="1" failed="0" inconclusive="0" skipped="0" asserts="0">
<properties>
<property name="_PID" value="11928" />
<property name="_APPDOMAIN" value="test-domain-mock-assembly.dll" />
</properties>
<test-suite type="TestFixture" id="1000" name="MockTestFixture" fullname="NUnit.Tests.Assemblies.MockTestFixture" testcasecount="1" result="Passed" duration="0.119" total="1" passed="1" failed="0" inconclusive="0" skipped="0" asserts="0">
<test-case id="1001" name="MockTest1" fullname="NUnit.Tests.Assemblies.MockTestFixture.MockTest1" result="Passed" duration="0.000" asserts="0">
<properties>
<property name="Description" value="Mock Test #1" />
</properties>
</test-case>
</test-suite>
</test-suite>
</test-run>
10 changes: 10 additions & 0 deletions tests/parser.nunit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit da7d421

Please sign in to comment.