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

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