-
Notifications
You must be signed in to change notification settings - Fork 4
/
gosuite_test.go
55 lines (44 loc) · 1.05 KB
/
gosuite_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
package gosuite
import (
"testing"
"gopkg.in/tylerb/is.v1"
)
func TestIt(t *testing.T) {
s := &Suite{Is: is.New(t)}
Run(t, s)
s.Equal(1, s.setUpSuiteCalledTimes)
s.Equal(1, s.tearDownSuiteCalledTimes)
s.Equal(2, s.setUpCalledTimes)
s.Equal(2, s.tearDownUpCalledTimes)
}
type Suite struct {
*is.Is
setUpSuiteCalledTimes int
tearDownSuiteCalledTimes int
setUpCalledTimes int
tearDownUpCalledTimes int
}
func (s *Suite) SetUpSuite() {
s.setUpSuiteCalledTimes++
}
func (s *Suite) TearDownSuite() {
s.tearDownSuiteCalledTimes++
}
func (s *Suite) SetUp() {
s.setUpCalledTimes++
}
func (s *Suite) TearDown() {
s.tearDownUpCalledTimes++
}
func (s *Suite) TestFirstTestMethod(t *testing.T) {
s.Equal(1, s.setUpSuiteCalledTimes)
s.Equal(0, s.tearDownSuiteCalledTimes)
s.Equal(1, s.setUpCalledTimes)
s.Equal(0, s.tearDownUpCalledTimes)
}
func (s *Suite) TestSecondTestMethod(t *testing.T) {
s.Equal(1, s.setUpSuiteCalledTimes)
s.Equal(0, s.tearDownSuiteCalledTimes)
s.Equal(2, s.setUpCalledTimes)
s.Equal(1, s.tearDownUpCalledTimes)
}