-
Notifications
You must be signed in to change notification settings - Fork 18
/
after.go
51 lines (44 loc) · 1.37 KB
/
after.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package allure
import (
"github.com/jtolds/gls"
"log"
"testing"
)
// AfterTest executes a teardown phase of the test and adds parameters to the Allure container object
func AfterTest(t *testing.T, testOptions ...Option) {
after := newAfter()
afterSubContainer := after.Afters[0]
after.UUID = generateUUID()
afterSubContainer.Start = getTimestampMs()
afterSubContainer.Steps = make([]stepObject, 0)
for _, option := range testOptions {
option(afterSubContainer)
}
defer func() {
afterSubContainer.Stop = getTimestampMs()
afterSubContainer.Status = getTestStatus(t)
afterSubContainer.Stage = "finished"
testPhaseObject := getCurrentTestPhaseObject(t)
if testPhaseObject.Test.UUID == "" {
log.Printf("Test's \"%s\" allure teardщwn is being executed before allure test!\n", t.Name())
}
after.Children = append(after.Children, testPhaseObject.Test.UUID)
testPhaseObject.Afters = append(testPhaseObject.Afters, after)
err := after.writeResultsFile()
if err != nil {
log.Println("Failed to write content of result to json file", err)
}
}()
ctxMgr.SetValues(gls.Values{
testResultKey: afterSubContainer,
nodeKey: afterSubContainer,
testInstanceKey: t,
}, afterSubContainer.Action)
}
func newAfter() *container {
return &container{
Children: make([]string, 0),
Links: make([]string, 0),
Afters: []*subContainer{newHelper()},
}
}