mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-16 22:37:09 +01:00
Refactoring & cleanup of whole codebase
Improves report summary and annotations
This commit is contained in:
parent
07a0223ee3
commit
60b35d601a
20 changed files with 38784 additions and 33667 deletions
101
src/test-results.ts
Normal file
101
src/test-results.ts
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
export class TestRunResult {
|
||||
constructor(readonly path: string, readonly suites: TestSuiteResult[], private totalTime?: number) {}
|
||||
|
||||
get tests(): number {
|
||||
return this.suites.reduce((sum, g) => sum + g.tests, 0)
|
||||
}
|
||||
|
||||
get passed(): number {
|
||||
return this.suites.reduce((sum, g) => sum + g.passed, 0)
|
||||
}
|
||||
get failed(): number {
|
||||
return this.suites.reduce((sum, g) => sum + g.failed, 0)
|
||||
}
|
||||
get skipped(): number {
|
||||
return this.suites.reduce((sum, g) => sum + g.skipped, 0)
|
||||
}
|
||||
|
||||
get time(): number {
|
||||
return this.totalTime ?? this.suites.reduce((sum, g) => sum + g.time, 0)
|
||||
}
|
||||
|
||||
get result(): TestExecutionResult {
|
||||
return this.suites.some(t => t.result === 'failed') ? 'failed' : 'success'
|
||||
}
|
||||
|
||||
get failedSuites(): TestSuiteResult[] {
|
||||
return this.suites.filter(s => s.result === 'failed')
|
||||
}
|
||||
}
|
||||
|
||||
export class TestSuiteResult {
|
||||
constructor(readonly name: string, readonly groups: TestGroupResult[], private totalTime?: number) {}
|
||||
|
||||
get tests(): number {
|
||||
return this.groups.reduce((sum, g) => sum + g.tests.length, 0)
|
||||
}
|
||||
|
||||
get passed(): number {
|
||||
return this.groups.reduce((sum, g) => sum + g.passed, 0)
|
||||
}
|
||||
get failed(): number {
|
||||
return this.groups.reduce((sum, g) => sum + g.failed, 0)
|
||||
}
|
||||
get skipped(): number {
|
||||
return this.groups.reduce((sum, g) => sum + g.skipped, 0)
|
||||
}
|
||||
get time(): number {
|
||||
return this.totalTime ?? this.groups.reduce((sum, g) => sum + g.time, 0)
|
||||
}
|
||||
|
||||
get result(): TestExecutionResult {
|
||||
return this.groups.some(t => t.result === 'failed') ? 'failed' : 'success'
|
||||
}
|
||||
|
||||
get failedGroups(): TestGroupResult[] {
|
||||
return this.groups.filter(grp => grp.result === 'failed')
|
||||
}
|
||||
}
|
||||
|
||||
export class TestGroupResult {
|
||||
constructor(readonly name: string | undefined | null, readonly tests: TestCaseResult[]) {}
|
||||
|
||||
get passed(): number {
|
||||
return this.tests.reduce((sum, t) => (t.result === 'success' ? sum + 1 : sum), 0)
|
||||
}
|
||||
get failed(): number {
|
||||
return this.tests.reduce((sum, t) => (t.result === 'failed' ? sum + 1 : sum), 0)
|
||||
}
|
||||
get skipped(): number {
|
||||
return this.tests.reduce((sum, t) => (t.result === 'skipped' ? sum + 1 : sum), 0)
|
||||
}
|
||||
get time(): number {
|
||||
return this.tests.reduce((sum, t) => sum + t.time, 0)
|
||||
}
|
||||
|
||||
get result(): TestExecutionResult {
|
||||
return this.tests.some(t => t.result === 'failed') ? 'failed' : 'success'
|
||||
}
|
||||
|
||||
get failedTests(): TestCaseResult[] {
|
||||
return this.tests.filter(tc => tc.result === 'failed')
|
||||
}
|
||||
}
|
||||
|
||||
export class TestCaseResult {
|
||||
constructor(
|
||||
readonly name: string,
|
||||
readonly result: TestExecutionResult,
|
||||
readonly time: number,
|
||||
readonly error?: TestCaseError
|
||||
) {}
|
||||
}
|
||||
|
||||
export type TestExecutionResult = 'success' | 'skipped' | 'failed' | undefined
|
||||
|
||||
export interface TestCaseError {
|
||||
path?: string
|
||||
line?: number
|
||||
message?: string
|
||||
stackTrace: string
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue