forked from mloo3/testify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package_test.go
79 lines (71 loc) · 2.36 KB
/
package_test.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package testify
import (
"testing"
"github.com/denist-huma/testify/v2/suite"
)
type Suite struct{}
func (s *Suite) TearDownSuite(t *suite.T) {
t.Log(">> suite tear down")
}
func (s *Suite) TearDownTest(t *suite.T) {
t.Log(">> single test tear down")
}
func (s *Suite) TestOne(t *suite.T) {
for _, v := range []string{"sub1", "sub2", "sub3"} {
t.Run(v, func(t *suite.T) {
t.Parallel()
})
}
}
func (s *Suite) TestTwo(t *suite.T) {
for _, v := range []string{"sub1", "sub2", "sub3"} {
t.Run(v, func(t *suite.T) {
t.Parallel()
})
}
}
// TestSuiteParallelSubTests shows that the issue with the parallel test is solved.
// https://github.com/stretchr/testify/issues/934
func TestSuiteParallelSubTests(t *testing.T) {
suite.Run(t, &Suite{})
// Output:
// === RUN TestLogic
// === RUN TestLogic/All
// === RUN TestLogic/All/TestOne
// === RUN TestLogic/All/TestOne/sub1
// === PAUSE TestLogic/All/TestOne/sub1
// === RUN TestLogic/All/TestOne/sub2
// === PAUSE TestLogic/All/TestOne/sub2
// === RUN TestLogic/All/TestOne/sub3
// === PAUSE TestLogic/All/TestOne/sub3
// === NAME TestLogic/All/TestOne
// suite.go:64: >> single test tear down
// === CONT TestLogic/All/TestOne/sub1
// === CONT TestLogic/All/TestOne/sub3
// === CONT TestLogic/All/TestOne/sub2
// === RUN TestLogic/All/TestTwo
// === RUN TestLogic/All/TestTwo/sub1
// === PAUSE TestLogic/All/TestTwo/sub1
// === RUN TestLogic/All/TestTwo/sub2
// === PAUSE TestLogic/All/TestTwo/sub2
// === RUN TestLogic/All/TestTwo/sub3
// === PAUSE TestLogic/All/TestTwo/sub3
// === NAME TestLogic/All/TestTwo
// suite.go:64: >> single test tear down
// === CONT TestLogic/All/TestTwo/sub1
// === CONT TestLogic/All/TestTwo/sub2
// === CONT TestLogic/All/TestTwo/sub3
// === NAME TestLogic
// suite.go:64: >> suite tear down
// --- PASS: TestLogic (0.00s)
// --- PASS: TestLogic/All (0.00s)
// --- PASS: TestLogic/All/TestOne (0.00s)
// --- PASS: TestLogic/All/TestOne/sub1 (0.00s)
// --- PASS: TestLogic/All/TestOne/sub3 (0.00s)
// --- PASS: TestLogic/All/TestOne/sub2 (0.00s)
// --- PASS: TestLogic/All/TestTwo (0.00s)
// --- PASS: TestLogic/All/TestTwo/sub1 (0.00s)
// --- PASS: TestLogic/All/TestTwo/sub2 (0.00s)
// --- PASS: TestLogic/All/TestTwo/sub3 (0.00s)
// PASS
}