import { AllureRuntime } from "./AllureRuntime" ; import { AllureTest } from "./AllureTest" ; import { fixtureResult , testResultContainer } from "./constructors" ; import { ExecutableItemWrapper } from "./ExecutableItemWrapper" ; import { TestResultContainer } from "./model" ; export class AllureGroup { private testResultContainer : TestResultContainer = testResultContainer ( ) ; constructor ( private readonly runtime ) { } startGroup ( name ? ) { const group = new AllureGroup ( this . runtime ) ; this . testResultContainer . children . push ( group . uuid ) ; group . name = name || "Unnamed" ; return group ; } startTest ( name ? , start ? ) { const test = new AllureTest ( this . runtime , start ) ; this . testResultContainer . children . push ( test . uuid ) ; test . name = name || "Unnamed" ; return test ; } endGroup ( ) { this . runtime . writeGroup ( this . testResultContainer ) ; } get uuid ( ) : string { return this . testResultContainer . uuid ; } get name ( ) : string { return this . testResultContainer . name || "" ; } set name ( name ) { this . testResultContainer . name = name ; } addBefore ( ) { const result = fixtureResult ( ) ; this . testResultContainer . befores . push ( result ) ; return new ExecutableItemWrapper ( result ) ; } addAfter ( ) { const result = fixtureResult ( ) ; this . testResultContainer . afters . push ( result ) ; return new ExecutableItemWrapper ( result ) ; } }