Fixed so every test isnt in a seperate group, but its per suite.

This commit is contained in:
Simen Sandvaer 2022-11-06 20:27:49 +01:00
parent a97564ca53
commit b44d5ae60b
5 changed files with 36 additions and 129 deletions

View file

@ -16,57 +16,45 @@
|[    MockTestFixture](#r0s10)|1✔|||NaNms| |[    MockTestFixture](#r0s10)|1✔|||NaNms|
### ❌ <a id="user-content-r0s1" href="#r0s1">MockTestFixture</a> ### ❌ <a id="user-content-r0s1" href="#r0s1">MockTestFixture</a>
``` ```
FailingTest MockTestFixture
❌ FailingTest ❌ FailingTest
Intentional failure Intentional failure
InconclusiveTest
✔️ InconclusiveTest ✔️ InconclusiveTest
MockTest1
✔️ MockTest1 ✔️ MockTest1
MockTest2
✔️ MockTest2 ✔️ MockTest2
MockTest3
✔️ MockTest3 ✔️ MockTest3
MockTest4
✖️ MockTest4 ✖️ MockTest4
MockTest5
✖️ MockTest5 ✖️ MockTest5
NotRunnableTest
✖️ NotRunnableTest ✖️ NotRunnableTest
TestWithException
❌ TestWithException ❌ TestWithException
System.ApplicationException : Intentional Exception System.ApplicationException : Intentional Exception
TestWithManyProperties
✔️ TestWithManyProperties ✔️ TestWithManyProperties
``` ```
### ✔️ <a id="user-content-r0s4" href="#r0s4">MethodWithParameters</a> ### ✔️ <a id="user-content-r0s4" href="#r0s4">MethodWithParameters</a>
``` ```
MethodWithParameters(2,2) MethodWithParameters
✔️ MethodWithParameters(2,2) ✔️ MethodWithParameters(2,2)
MethodWithParameters(9,11)
✔️ MethodWithParameters(9,11) ✔️ MethodWithParameters(9,11)
``` ```
### ✔️ <a id="user-content-r0s7" href="#r0s7">ParameterizedFixture(42)</a> ### ✔️ <a id="user-content-r0s7" href="#r0s7">ParameterizedFixture(42)</a>
``` ```
Test1 ParameterizedFixture(42)
✔️ Test1 ✔️ Test1
Test2
✔️ Test2 ✔️ Test2
``` ```
### ✔️ <a id="user-content-r0s8" href="#r0s8">ParameterizedFixture(5)</a> ### ✔️ <a id="user-content-r0s8" href="#r0s8">ParameterizedFixture(5)</a>
``` ```
Test1 ParameterizedFixture(5)
✔️ Test1 ✔️ Test1
Test2
✔️ Test2 ✔️ Test2
``` ```
### ✔️ <a id="user-content-r0s9" href="#r0s9">OneTestCase</a> ### ✔️ <a id="user-content-r0s9" href="#r0s9">OneTestCase</a>
``` ```
TestCase OneTestCase
✔️ TestCase ✔️ TestCase
``` ```
### ✔️ <a id="user-content-r0s10" href="#r0s10">MockTestFixture</a> ### ✔️ <a id="user-content-r0s10" href="#r0s10">MockTestFixture</a>
``` ```
MyTest MockTestFixture
✔️ MyTest ✔️ MyTest
``` ```

View file

@ -13,7 +13,7 @@ TestRunResult {
TestSuiteResult { TestSuiteResult {
"groups": Array [ "groups": Array [
TestGroupResult { TestGroupResult {
"name": "FailingTest", "name": "MockTestFixture",
"tests": Array [ "tests": Array [
TestCaseResult { TestCaseResult {
"error": Object { "error": Object {
@ -28,88 +28,48 @@ TestRunResult {
"result": "failed", "result": "failed",
"time": 23, "time": 23,
}, },
],
},
TestGroupResult {
"name": "InconclusiveTest",
"tests": Array [
TestCaseResult { TestCaseResult {
"error": undefined, "error": undefined,
"name": "InconclusiveTest", "name": "InconclusiveTest",
"result": "success", "result": "success",
"time": 1, "time": 1,
}, },
],
},
TestGroupResult {
"name": "MockTest1",
"tests": Array [
TestCaseResult { TestCaseResult {
"error": undefined, "error": undefined,
"name": "MockTest1", "name": "MockTest1",
"result": "success", "result": "success",
"time": 0, "time": 0,
}, },
],
},
TestGroupResult {
"name": "MockTest2",
"tests": Array [
TestCaseResult { TestCaseResult {
"error": undefined, "error": undefined,
"name": "MockTest2", "name": "MockTest2",
"result": "success", "result": "success",
"time": 0, "time": 0,
}, },
],
},
TestGroupResult {
"name": "MockTest3",
"tests": Array [
TestCaseResult { TestCaseResult {
"error": undefined, "error": undefined,
"name": "MockTest3", "name": "MockTest3",
"result": "success", "result": "success",
"time": 0, "time": 0,
}, },
],
},
TestGroupResult {
"name": "MockTest4",
"tests": Array [
TestCaseResult { TestCaseResult {
"error": undefined, "error": undefined,
"name": "MockTest4", "name": "MockTest4",
"result": "skipped", "result": "skipped",
"time": 0, "time": 0,
}, },
],
},
TestGroupResult {
"name": "MockTest5",
"tests": Array [
TestCaseResult { TestCaseResult {
"error": undefined, "error": undefined,
"name": "MockTest5", "name": "MockTest5",
"result": "skipped", "result": "skipped",
"time": 0, "time": 0,
}, },
],
},
TestGroupResult {
"name": "NotRunnableTest",
"tests": Array [
TestCaseResult { TestCaseResult {
"error": undefined, "error": undefined,
"name": "NotRunnableTest", "name": "NotRunnableTest",
"result": "skipped", "result": "skipped",
"time": 0, "time": 0,
}, },
],
},
TestGroupResult {
"name": "TestWithException",
"tests": Array [
TestCaseResult { TestCaseResult {
"error": Object { "error": Object {
"details": " at NUnit.Tests.Assemblies.MockTestFixture.MethodThrowsException() in D:\\\\Dev\\\\NUnit\\\\nunit-3.0\\\\work\\\\NUnitFramework\\\\src\\\\mock-assembly\\\\MockAssembly.cs:line 158 "details": " at NUnit.Tests.Assemblies.MockTestFixture.MethodThrowsException() in D:\\\\Dev\\\\NUnit\\\\nunit-3.0\\\\work\\\\NUnitFramework\\\\src\\\\mock-assembly\\\\MockAssembly.cs:line 158
@ -122,11 +82,6 @@ TestRunResult {
"result": "failed", "result": "failed",
"time": 2, "time": 2,
}, },
],
},
TestGroupResult {
"name": "TestWithManyProperties",
"tests": Array [
TestCaseResult { TestCaseResult {
"error": undefined, "error": undefined,
"name": "TestWithManyProperties", "name": "TestWithManyProperties",
@ -155,7 +110,7 @@ TestRunResult {
TestSuiteResult { TestSuiteResult {
"groups": Array [ "groups": Array [
TestGroupResult { TestGroupResult {
"name": "MethodWithParameters(2,2)", "name": "MethodWithParameters",
"tests": Array [ "tests": Array [
TestCaseResult { TestCaseResult {
"error": undefined, "error": undefined,
@ -163,11 +118,6 @@ TestRunResult {
"result": "success", "result": "success",
"time": 6, "time": 6,
}, },
],
},
TestGroupResult {
"name": "MethodWithParameters(9,11)",
"tests": Array [
TestCaseResult { TestCaseResult {
"error": undefined, "error": undefined,
"name": "MethodWithParameters(9,11)", "name": "MethodWithParameters(9,11)",
@ -196,7 +146,7 @@ TestRunResult {
TestSuiteResult { TestSuiteResult {
"groups": Array [ "groups": Array [
TestGroupResult { TestGroupResult {
"name": "Test1", "name": "ParameterizedFixture(42)",
"tests": Array [ "tests": Array [
TestCaseResult { TestCaseResult {
"error": undefined, "error": undefined,
@ -204,11 +154,6 @@ TestRunResult {
"result": "success", "result": "success",
"time": 0, "time": 0,
}, },
],
},
TestGroupResult {
"name": "Test2",
"tests": Array [
TestCaseResult { TestCaseResult {
"error": undefined, "error": undefined,
"name": "Test2", "name": "Test2",
@ -225,7 +170,7 @@ TestRunResult {
TestSuiteResult { TestSuiteResult {
"groups": Array [ "groups": Array [
TestGroupResult { TestGroupResult {
"name": "Test1", "name": "ParameterizedFixture(5)",
"tests": Array [ "tests": Array [
TestCaseResult { TestCaseResult {
"error": undefined, "error": undefined,
@ -233,11 +178,6 @@ TestRunResult {
"result": "success", "result": "success",
"time": 0, "time": 0,
}, },
],
},
TestGroupResult {
"name": "Test2",
"tests": Array [
TestCaseResult { TestCaseResult {
"error": undefined, "error": undefined,
"name": "Test2", "name": "Test2",
@ -254,7 +194,7 @@ TestRunResult {
TestSuiteResult { TestSuiteResult {
"groups": Array [ "groups": Array [
TestGroupResult { TestGroupResult {
"name": "TestCase", "name": "OneTestCase",
"tests": Array [ "tests": Array [
TestCaseResult { TestCaseResult {
"error": undefined, "error": undefined,
@ -272,7 +212,7 @@ TestRunResult {
TestSuiteResult { TestSuiteResult {
"groups": Array [ "groups": Array [
TestGroupResult { TestGroupResult {
"name": "MyTest", "name": "MockTestFixture",
"tests": Array [ "tests": Array [
TestCaseResult { TestCaseResult {
"error": undefined, "error": undefined,

23
dist/index.js generated vendored
View file

@ -784,10 +784,10 @@ class DotnetNunitParser {
testSuites.map(ts => { testSuites.map(ts => {
const name = ts.$.name.trim(); const name = ts.$.name.trim();
const time = parseFloat(ts.$.duration) * 1000; const time = parseFloat(ts.$.duration) * 1000;
const groups = this.getGroups(ts); const group = this.getGroup(ts);
const sr = new test_results_1.TestSuiteResult(name, groups, time, depth); const sr = new test_results_1.TestSuiteResult(name, group, time, depth);
suiteResults.push(sr); suiteResults.push(sr);
if (groups.length === 0) { if (group.length === 0) {
const nestedTestSuites = ts['test-suite']; const nestedTestSuites = ts['test-suite'];
if (nestedTestSuites !== undefined) { if (nestedTestSuites !== undefined) {
this.getTestSuiteResultRecursive(nestedTestSuites, suiteResults, depth + 1); this.getTestSuiteResultRecursive(nestedTestSuites, suiteResults, depth + 1);
@ -805,29 +805,18 @@ class DotnetNunitParser {
const time = isNaN(seconds) ? undefined : seconds * 1000; const time = isNaN(seconds) ? undefined : seconds * 1000;
return new test_results_1.TestRunResult(filePath, suites, time); return new test_results_1.TestRunResult(filePath, suites, time);
} }
getGroups(suite) { getGroup(suite) {
const groups = [];
if (suite['test-case'] === undefined) { if (suite['test-case'] === undefined) {
return []; return [];
} }
for (const tc of suite['test-case']) { const tests = suite['test-case'].map(tc => {
let grp = groups.find(g => g.describe === tc.$.name);
if (grp === undefined) {
grp = { describe: tc.$.name, tests: [] };
groups.push(grp);
}
grp.tests.push(tc);
}
return groups.map(grp => {
const tests = grp.tests.map(tc => {
const name = tc.$.name.trim(); const name = tc.$.name.trim();
const result = this.getTestCaseResult(tc); const result = this.getTestCaseResult(tc);
const time = parseFloat(tc.$.time) * 1000; const time = parseFloat(tc.$.time) * 1000;
const error = this.getTestCaseError(tc); const error = this.getTestCaseError(tc);
return new test_results_1.TestCaseResult(name, result, time, error); return new test_results_1.TestCaseResult(name, result, time, error);
}); });
return new test_results_1.TestGroupResult(grp.describe, tests); return [new test_results_1.TestGroupResult(suite.$.name, tests)];
});
} }
getTestCaseResult(test) { getTestCaseResult(test) {
if (test.failure) if (test.failure)

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View file

@ -48,11 +48,11 @@ export class DotnetNunitParser implements TestParser {
testSuites.map(ts => { testSuites.map(ts => {
const name = ts.$.name.trim() const name = ts.$.name.trim()
const time = parseFloat(ts.$.duration) * 1000 const time = parseFloat(ts.$.duration) * 1000
const groups = this.getGroups(ts) const group = this.getGroup(ts)
const sr = new TestSuiteResult(name, groups, time, depth) const sr = new TestSuiteResult(name, group, time, depth)
suiteResults.push(sr) suiteResults.push(sr)
if (groups.length === 0) { if (group.length === 0) {
const nestedTestSuites = ts['test-suite'] const nestedTestSuites = ts['test-suite']
if (nestedTestSuites !== undefined) { if (nestedTestSuites !== undefined) {
this.getTestSuiteResultRecursive(nestedTestSuites, suiteResults, depth + 1) this.getTestSuiteResultRecursive(nestedTestSuites, suiteResults, depth + 1)
@ -73,30 +73,20 @@ export class DotnetNunitParser implements TestParser {
return new TestRunResult(filePath, suites, time) return new TestRunResult(filePath, suites, time)
} }
private getGroups(suite: TestSuite): TestGroupResult[] { private getGroup(suite: TestSuite): TestGroupResult[] {
const groups: {describe: string; tests: TestCase[]}[] = []
if (suite['test-case'] === undefined) { if (suite['test-case'] === undefined) {
return [] return []
} }
for (const tc of suite['test-case']) {
let grp = groups.find(g => g.describe === tc.$.name)
if (grp === undefined) {
grp = {describe: tc.$.name, tests: []}
groups.push(grp)
}
grp.tests.push(tc)
}
return groups.map(grp => { const tests = suite['test-case'].map(tc => {
const tests = grp.tests.map(tc => {
const name = tc.$.name.trim() const name = tc.$.name.trim()
const result = this.getTestCaseResult(tc) const result = this.getTestCaseResult(tc)
const time = parseFloat(tc.$.time) * 1000 const time = parseFloat(tc.$.time) * 1000
const error = this.getTestCaseError(tc) const error = this.getTestCaseError(tc)
return new TestCaseResult(name, result, time, error) return new TestCaseResult(name, result, time, error)
}) })
return new TestGroupResult(grp.describe, tests)
}) return [new TestGroupResult(suite.$.name, tests)]
} }
private getTestCaseResult(test: TestCase): TestExecutionResult { private getTestCaseResult(test: TestCase): TestExecutionResult {