Skip to content

Commit

Permalink
Addressed time/duration mismatch for nunit3 #63
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanbcook committed May 28, 2024
1 parent 0e0c789 commit 343fed2
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 39 deletions.
6 changes: 3 additions & 3 deletions src/parsers/nunit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -212,7 +212,7 @@ 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.suites.push(...getTestSuites([rawSuite], null));

Expand Down
4 changes: 2 additions & 2 deletions tests/data/nunit/nunit_v2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<failure>
<message><![CDATA[Intentional failure]]></message>
<stack-trace><![CDATA[at NUnit.Tests.Assemblies.MockTestFixture.FailingTest () [0x00000] in /home/charlie/Dev/NUnit/nunit-2.5/work/src/tests/mock-assembly/MockAssembly.cs:121
]]> </stack-trace>
]]></stack-trace>
</failure>
</test-case>
<test-case name="NUnit.Tests.Assemblies.MockTestFixture.InconclusiveTest" executed="True" result="Inconclusive" success="False" time="0.001" asserts="0">
Expand Down Expand Up @@ -68,7 +68,7 @@
<failure>
<message><![CDATA[System.ApplicationException : Intentional Exception]]></message>
<stack-trace><![CDATA[at NUnit.Tests.Assemblies.MockTestFixture.TestWithException () [0x00000] in /home/charlie/Dev/NUnit/nunit-2.5/work/src/tests/mock-assembly/MockAssembly.cs:153
]]> </stack-trace>
]]></stack-trace>
</failure>
</test-case>
<test-case name="NUnit.Tests.Assemblies.MockTestFixture.TestWithManyProperties" executed="True" result="Success" success="True" time="0.000" asserts="0">
Expand Down
Loading

0 comments on commit 343fed2

Please sign in to comment.