1
0
Fork 0
mirror of https://github.com/dorny/test-reporter.git synced 2026-03-22 07:52:14 +01:00

NUnit Legacy: clean up suite/group names

This commit is contained in:
Shamus Taylor 2025-03-05 11:15:25 -06:00
parent 0850bc862a
commit e89b2f3e47
No known key found for this signature in database
GPG key ID: C44FC1AA547ACE39
5 changed files with 34 additions and 34 deletions

View file

@ -6,29 +6,29 @@
**10** tests were completed in **9ms** with **3** passed, **5** failed and **2** skipped.
|Test suite|Passed|Failed|Skipped|Time|
|:---|---:|---:|---:|---:|
|[C:\Users\james_t\Documents\git\test-reporter\reports\dotnet-nunit-legacy\NUnitLegacy.sln.C:\Users\james_t\Documents\git\test-reporter\reports\dotnet-nunit-legacy\NUnitLegacyTests\bin\Debug\NUnitLegacyTests.dll.NUnitLegacyTests](#r0s0)|3 ✅|5 ❌|2 ⚪|NaNms|
### ❌ <a id="user-content-r0s0" href="#r0s0">C:\Users\james_t\Documents\git\test-reporter\reports\dotnet-nunit-legacy\NUnitLegacy.sln.C:\Users\james_t\Documents\git\test-reporter\reports\dotnet-nunit-legacy\NUnitLegacyTests\bin\Debug\NUnitLegacyTests.dll.NUnitLegacyTests</a>
|[NUnitLegacyTests.CalculatorTests](#r0s0)|3 ✅|5 ❌|2 ⚪|NaNms|
### ❌ <a id="user-content-r0s0" href="#r0s0">NUnitLegacyTests.CalculatorTests</a>
```
CalculatorTests
NUnitLegacyTests.CalculatorTests.Is_Even_Number(2)
NUnitLegacyTests.CalculatorTests.Is_Even_Number(3)
✅ Is_Even_Number(2)
❌ Is_Even_Number(3)
Expected: True
But was: False
NUnitLegacyTests.CalculatorTests.Exception_In_TargetTest
❌ Exception_In_TargetTest
System.DivideByZeroException : Attempted to divide by zero.
NUnitLegacyTests.CalculatorTests.Exception_In_Test
❌ Exception_In_Test
System.Exception : Test
NUnitLegacyTests.CalculatorTests.Failing_Test
❌ Failing_Test
Expected: 3
But was: 2
NUnitLegacyTests.CalculatorTests.Inconclusive_Test
⚪ Inconclusive_Test
couldn't run test for some reason
NUnitLegacyTests.CalculatorTests.Passing_Test
NUnitLegacyTests.CalculatorTests.Passing_Test_With_Description
NUnitLegacyTests.CalculatorTests.Skipped_Test
✅ Passing_Test
✅ Passing_Test_With_Description
⚪ Skipped_Test
Skipped
NUnitLegacyTests.CalculatorTests.Timeout_Test
❌ Timeout_Test
Test exceeded Timeout value of 1ms
```

View file

@ -11,7 +11,7 @@ TestRunResult {
"tests": [
TestCaseResult {
"error": undefined,
"name": "NUnitLegacyTests.CalculatorTests.Is_Even_Number(2)",
"name": "Is_Even_Number(2)",
"result": "success",
"time": 0.001,
},
@ -25,9 +25,9 @@ TestRunResult {
",
"path": undefined,
},
"name": "NUnitLegacyTests.CalculatorTests.Is_Even_Number(3)",
"name": "Is_Even_Number(3)",
"result": "failed",
"time": 0.002,
"time": 0.001,
},
TestCaseResult {
"error": {
@ -38,9 +38,9 @@ at NUnitLegacyTests.CalculatorTests.Exception_In_TargetTest() in C:\\Users\\jame
"message": "System.DivideByZeroException : Attempted to divide by zero.",
"path": undefined,
},
"name": "NUnitLegacyTests.CalculatorTests.Exception_In_TargetTest",
"name": "Exception_In_TargetTest",
"result": "failed",
"time": 0.028,
"time": 0.026,
},
TestCaseResult {
"error": {
@ -50,7 +50,7 @@ at NUnitLegacyTests.CalculatorTests.Exception_In_TargetTest() in C:\\Users\\jame
"message": "System.Exception : Test",
"path": undefined,
},
"name": "NUnitLegacyTests.CalculatorTests.Exception_In_Test",
"name": "Exception_In_Test",
"result": "failed",
"time": 0.002,
},
@ -64,9 +64,9 @@ at NUnitLegacyTests.CalculatorTests.Exception_In_TargetTest() in C:\\Users\\jame
",
"path": undefined,
},
"name": "NUnitLegacyTests.CalculatorTests.Failing_Test",
"name": "Failing_Test",
"result": "failed",
"time": 0.016,
"time": 0.014,
},
TestCaseResult {
"error": {
@ -75,19 +75,19 @@ at NUnitLegacyTests.CalculatorTests.Exception_In_TargetTest() in C:\\Users\\jame
"message": "couldn't run test for some reason",
"path": undefined,
},
"name": "NUnitLegacyTests.CalculatorTests.Inconclusive_Test",
"name": "Inconclusive_Test",
"result": "skipped",
"time": 0.002,
"time": 0.001,
},
TestCaseResult {
"error": undefined,
"name": "NUnitLegacyTests.CalculatorTests.Passing_Test",
"name": "Passing_Test",
"result": "success",
"time": 0,
},
TestCaseResult {
"error": undefined,
"name": "NUnitLegacyTests.CalculatorTests.Passing_Test_With_Description",
"name": "Passing_Test_With_Description",
"result": "success",
"time": 0,
},
@ -98,7 +98,7 @@ at NUnitLegacyTests.CalculatorTests.Exception_In_TargetTest() in C:\\Users\\jame
"message": "Skipped",
"path": undefined,
},
"name": "NUnitLegacyTests.CalculatorTests.Skipped_Test",
"name": "Skipped_Test",
"result": "skipped",
"time": NaN,
},
@ -109,17 +109,17 @@ at NUnitLegacyTests.CalculatorTests.Exception_In_TargetTest() in C:\\Users\\jame
"message": "Test exceeded Timeout value of 1ms",
"path": undefined,
},
"name": "NUnitLegacyTests.CalculatorTests.Timeout_Test",
"name": "Timeout_Test",
"result": "failed",
"time": 0.027,
"time": 0.028,
},
],
},
],
"name": "C:\\Users\\james_t\\source\\repos\\NUnitLegacy\\NUnitLegacy.sln.C:\\Users\\james_t\\source\\repos\\NUnitLegacy\\NUnitLegacyTests\\bin\\Debug\\NUnitLegacyTests.dll.NUnitLegacyTests",
"name": "NUnitLegacyTests.CalculatorTests",
"totalTime": undefined,
},
],
"totalTime": 0,
"totalTime": 9,
}
`;

View file

@ -15,7 +15,7 @@ describe('dotnet-nunit-legacy tests', () => {
const opts: ParseOptions = {
parseErrors: true,
trackedFiles: ['DotnetTests.Unit/Calculator.cs', 'DotnetTests.NUnitLegacyTests/CalculatorTests.cs']
trackedFiles: ['MyLibrary/Calculator.cs', 'NUnitLegacyTests/CalculatorTests.cs']
}
const parser = new DotnetNunitLegacyParser(opts)

4
dist/index.js generated vendored
View file

@ -789,7 +789,7 @@ class DotnetNunitLegacyParser {
// But ignore "Theory" suites.
const suitesWithoutTheories = suitePath.filter(suite => suite.$.type !== 'Theory');
const suiteName = suitesWithoutTheories
.slice(0, suitesWithoutTheories.length - 1)
.filter(suite => suite.$.type !== 'Assembly' && suite.$.type !== 'Project')
.map(suite => suite.$.name)
.join('.');
const groupName = suitesWithoutTheories[suitesWithoutTheories.length - 1].$.name;
@ -803,7 +803,7 @@ class DotnetNunitLegacyParser {
existingGroup = new test_results_1.TestGroupResult(groupName, []);
existingSuite.groups.push(existingGroup);
}
existingGroup.tests.push(new test_results_1.TestCaseResult(testCase.$.name, this.getTestExecutionResult(testCase), parseFloat(testCase.$.time), this.getTestCaseError(testCase)));
existingGroup.tests.push(new test_results_1.TestCaseResult(testCase.$.name.startsWith(suiteName + '.') ? testCase.$.name.substring(suiteName.length + 1) : testCase.$.name, this.getTestExecutionResult(testCase), parseFloat(testCase.$.time), this.getTestCaseError(testCase)));
}
getTestExecutionResult(test) {
if (test.$.result === 'Failed' || test.failure)

View file

@ -78,7 +78,7 @@ export class DotnetNunitLegacyParser implements TestParser {
// But ignore "Theory" suites.
const suitesWithoutTheories = suitePath.filter(suite => suite.$.type !== 'Theory')
const suiteName = suitesWithoutTheories
.slice(0, suitesWithoutTheories.length - 1)
.filter(suite => suite.$.type !== 'Assembly' && suite.$.type !== 'Project')
.map(suite => suite.$.name)
.join('.')
const groupName = suitesWithoutTheories[suitesWithoutTheories.length - 1].$.name
@ -97,7 +97,7 @@ export class DotnetNunitLegacyParser implements TestParser {
existingGroup.tests.push(
new TestCaseResult(
testCase.$.name,
testCase.$.name.startsWith(suiteName + '.') ? testCase.$.name.substring(suiteName.length + 1) : testCase.$.name,
this.getTestExecutionResult(testCase),
parseFloat(testCase.$.time),
this.getTestCaseError(testCase)