mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-16 06:17:10 +01:00
Handle test reports with no test cases
This commit is contained in:
parent
a1cbedbccb
commit
a9749e3840
13 changed files with 114 additions and 18 deletions
|
|
@ -61,6 +61,10 @@ export class DotnetTrxParser implements TestParser {
|
|||
}
|
||||
|
||||
private getTestClasses(trx: TrxReport): TestClass[] {
|
||||
if (trx.TestRun.TestDefinitions === undefined || trx.TestRun.Results === undefined) {
|
||||
return []
|
||||
}
|
||||
|
||||
const unitTests: {[id: string]: TestMethod} = {}
|
||||
for (const td of trx.TestRun.TestDefinitions) {
|
||||
for (const ut of td.UnitTest) {
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ export interface TrxReport {
|
|||
|
||||
export interface TestRun {
|
||||
Times: Times[]
|
||||
Results: Results[]
|
||||
TestDefinitions: TestDefinitions[]
|
||||
Results?: Results[]
|
||||
TestDefinitions?: TestDefinitions[]
|
||||
}
|
||||
|
||||
export interface Times {
|
||||
|
|
|
|||
|
|
@ -32,12 +32,15 @@ export class JestJunitParser implements TestParser {
|
|||
}
|
||||
|
||||
private getTestRunResult(path: string, junit: JunitReport): TestRunResult {
|
||||
const suites = junit.testsuites.testsuite.map(ts => {
|
||||
const name = ts.$.name.trim()
|
||||
const time = parseFloat(ts.$.time) * 1000
|
||||
const sr = new TestSuiteResult(name, this.getGroups(ts), time)
|
||||
return sr
|
||||
})
|
||||
const suites =
|
||||
junit.testsuites.testsuite === undefined
|
||||
? []
|
||||
: junit.testsuites.testsuite.map(ts => {
|
||||
const name = ts.$.name.trim()
|
||||
const time = parseFloat(ts.$.time) * 1000
|
||||
const sr = new TestSuiteResult(name, this.getGroups(ts), time)
|
||||
return sr
|
||||
})
|
||||
|
||||
const time = parseFloat(junit.testsuites.$.time) * 1000
|
||||
return new TestRunResult(path, suites, time)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export interface TestSuites {
|
|||
errors: string // unhandled exception during test execution
|
||||
time: string
|
||||
}
|
||||
testsuite: TestSuite[]
|
||||
testsuite?: TestSuite[]
|
||||
}
|
||||
|
||||
export interface TestSuite {
|
||||
|
|
|
|||
|
|
@ -148,7 +148,10 @@ function getSuitesReport(tr: TestRunResult, runIndex: number, options: ReportOpt
|
|||
sections.push(`## ${nameLink} ${icon}`)
|
||||
|
||||
const time = formatTime(tr.time)
|
||||
const headingLine2 = `**${tr.tests}** tests were completed in **${time}** with **${tr.passed}** passed, **${tr.failed}** failed and **${tr.skipped}** skipped.`
|
||||
const headingLine2 =
|
||||
tr.tests > 0
|
||||
? `**${tr.tests}** tests were completed in **${time}** with **${tr.passed}** passed, **${tr.failed}** failed and **${tr.skipped}** skipped.`
|
||||
: 'No tests found'
|
||||
sections.push(headingLine2)
|
||||
|
||||
const suites = options.listSuites === 'failed' ? tr.failedSuites : tr.suites
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue