Skip to content

Commit 4128d36

Browse files
committed
Use "Unclassified" when no class name is available
Fixes #556
1 parent d1504ea commit 4128d36

File tree

4 files changed

+98
-2
lines changed

4 files changed

+98
-2
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
![Tests failed](https://img.shields.io/badge/tests-1%20passed%2C%203%20failed-critical)
2+
|Report|Passed|Failed|Skipped|Time|
3+
|:---|---:|---:|---:|---:|
4+
|[fixtures/dotnet-xunitv3.trx](#user-content-r0)|1 ✅|3 ❌||267ms|
5+
## ❌ <a id="user-content-r0" href="#user-content-r0">fixtures/dotnet-xunitv3.trx</a>
6+
**4** tests were completed in **267ms** with **1** passed, **3** failed and **0** skipped.
7+
|Test suite|Passed|Failed|Skipped|Time|
8+
|:---|---:|---:|---:|---:|
9+
|[DotnetTests.XUnitV3Tests.FixtureTests](#user-content-r0s0)|1 ✅|1 ❌||18ms|
10+
|[Unclassified](#user-content-r0s1)||2 ❌||0ms|
11+
### ❌ <a id="user-content-r0s0" href="#user-content-r0s0">DotnetTests.XUnitV3Tests.FixtureTests</a>
12+
```
13+
❌ Failing_Test
14+
Assert.Null() Failure: Value is not null
15+
Expected: null
16+
Actual: Fixture { }
17+
at DotnetTests.XUnitV3Tests.FixtureTests.Failing_Test() in /_/reports/dotnet/DotnetTests.XUnitV3Tests/FixtureTests.cs:line 25
18+
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
19+
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
20+
✅ Passing_Test
21+
```
22+
### ❌ <a id="user-content-r0s1" href="#user-content-r0s1">Unclassified</a>
23+
```
24+
❌ [Test Class Cleanup Failure (DotnetTests.XUnitV3Tests.FixtureTests.Failing_Test)]
25+
❌ [Test Class Cleanup Failure (DotnetTests.XUnitV3Tests.FixtureTests.Passing_Test)]
26+
```

__tests__/__snapshots__/dotnet-trx.test.ts.snap

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,76 @@ Actual: False
135135
}
136136
`;
137137

138+
exports[`dotnet-trx tests matches dotnet-xunitv3 report snapshot 1`] = `
139+
TestRunResult {
140+
"path": "fixtures/dotnet-xunitv3.trx",
141+
"suites": [
142+
TestSuiteResult {
143+
"groups": [
144+
TestGroupResult {
145+
"name": null,
146+
"tests": [
147+
TestCaseResult {
148+
"error": {
149+
"details": "Assert.Null() Failure: Value is not null
150+
Expected: null
151+
Actual: Fixture { }
152+
at DotnetTests.XUnitV3Tests.FixtureTests.Failing_Test() in /_/reports/dotnet/DotnetTests.XUnitV3Tests/FixtureTests.cs:line 25
153+
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
154+
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)",
155+
"line": 25,
156+
"message": "Assert.Null() Failure: Value is not null
157+
Expected: null
158+
Actual: Fixture { }
159+
at DotnetTests.XUnitV3Tests.FixtureTests.Failing_Test() in /_/reports/dotnet/DotnetTests.XUnitV3Tests/FixtureTests.cs:line 25
160+
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
161+
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)",
162+
"path": "DotnetTests.XUnitV3Tests/FixtureTests.cs",
163+
},
164+
"name": "Failing_Test",
165+
"result": "failed",
166+
"time": 17.0545,
167+
},
168+
TestCaseResult {
169+
"error": undefined,
170+
"name": "Passing_Test",
171+
"result": "success",
172+
"time": 0.8786,
173+
},
174+
],
175+
},
176+
],
177+
"name": "DotnetTests.XUnitV3Tests.FixtureTests",
178+
"totalTime": undefined,
179+
},
180+
TestSuiteResult {
181+
"groups": [
182+
TestGroupResult {
183+
"name": null,
184+
"tests": [
185+
TestCaseResult {
186+
"error": undefined,
187+
"name": "[Test Class Cleanup Failure (DotnetTests.XUnitV3Tests.FixtureTests.Failing_Test)]",
188+
"result": "failed",
189+
"time": 0,
190+
},
191+
TestCaseResult {
192+
"error": undefined,
193+
"name": "[Test Class Cleanup Failure (DotnetTests.XUnitV3Tests.FixtureTests.Passing_Test)]",
194+
"result": "failed",
195+
"time": 0,
196+
},
197+
],
198+
},
199+
],
200+
"name": "Unclassified",
201+
"totalTime": undefined,
202+
},
203+
],
204+
"totalTime": 267,
205+
}
206+
`;
207+
138208
exports[`dotnet-trx tests matches report snapshot (only failed tests) 1`] = `
139209
TestRunResult {
140210
"path": "fixtures/dotnet-trx.trx",

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/parsers/dotnet-trx/dotnet-trx-parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export class DotnetTrxParser implements TestParser {
8181

8282
const testClasses: {[name: string]: TestClass} = {}
8383
for (const r of unitTestsResults) {
84-
const className = r.test.TestMethod[0].$.className
84+
const className = r.test.TestMethod[0].$.className ?? "Unclassified"
8585
let tc = testClasses[className]
8686
if (tc === undefined) {
8787
tc = new TestClass(className)

0 commit comments

Comments
 (0)