-
Notifications
You must be signed in to change notification settings - Fork 11
/
options.go
71 lines (62 loc) · 2.1 KB
/
options.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
package gunit
type option func(*configuration)
var Options singleton
type singleton struct{}
// SkipAll is an option meant to be passed to gunit.Run(...)
// and causes each and every "Test" method in the corresponding
// fixture to be skipped (as if each had been prefixed with
// "Skip"). Even "Test" methods marked with the "Focus" prefix
// will be skipped.
func (singleton) SkipAll() option {
return func(this *configuration) {
this.SkippedTestCases = true
}
}
// LongRunning is an option meant to be passed to
// gunit.Run(...) and, in the case that the -short testing
// flag has been passed at the command line, it causes each
// and every "Test" method in the corresponding fixture to
// be skipped (as if each had been prefixed with "Skip").
func (singleton) LongRunning() option {
return func(this *configuration) {
this.LongRunningTestCases = true
}
}
// SequentialFixture is an option meant to be passed to
// gunit.Run(...) and signals that the corresponding fixture
// is not to be run in parallel with any tests (by not calling
// t.Parallel() on the provided *testing.T).
func (singleton) SequentialFixture() option {
return func(this *configuration) {
this.SequentialFixture = true
}
}
// SequentialTestCases is an option meant to be passed to
// gunit.Run(...) and prevents gunit from calling t.Parallel()
// on the inner instances of *testing.T passed to the 'subtests'
// corresponding to "Test" methods which are created during
// the natural course of the corresponding invocation of
// gunit.Run(...).
func (singleton) SequentialTestCases() option {
return func(this *configuration) {
this.SequentialTestCases = true
}
}
// AllSequential has the combined effect of passing the
// following options to gunit.Run(...):
// 1. SequentialFixture
// 2. SequentialTestCases
func (singleton) AllSequential() option {
return Options.composite(
Options.SequentialFixture(),
Options.SequentialTestCases(),
)
}
// composite allows graceful chaining of options.
func (singleton) composite(options ...option) option {
return func(this *configuration) {
for _, option := range options {
option(this)
}
}
}