-
Notifications
You must be signed in to change notification settings - Fork 50
/
suite.go
59 lines (46 loc) · 1.08 KB
/
suite.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
package suite
import (
"testing"
"github.com/justtrackio/gosoline/pkg/test/env"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
type TestingSuite interface {
Env() *env.Environment
SetEnv(environment *env.Environment)
SetT(t *testing.T)
T() *testing.T
SetupSuite() []Option
}
type TestingSuiteSetupTestAware interface {
SetupTest() error
}
type TestingSuiteTearDownTestAware interface {
TearDownTest() error
}
type TestingSuiteApplicationAware interface {
SetupApplication() error
}
type Suite struct {
*assert.Assertions
require *require.Assertions
t *testing.T
env *env.Environment
}
func (s *Suite) Env() *env.Environment {
if s.env == nil {
assert.FailNow(s.t, "test environment not running yet", "to setup your test environment, use the WithEnvSetup option instead of accessing the env directly")
}
return s.env
}
func (s *Suite) SetEnv(env *env.Environment) {
s.env = env
}
func (s *Suite) SetT(t *testing.T) {
s.t = t
s.Assertions = assert.New(t)
s.require = require.New(t)
}
func (s *Suite) T() *testing.T {
return s.t
}