-
Notifications
You must be signed in to change notification settings - Fork 9
/
options.go
50 lines (42 loc) · 1.49 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
package gocuke
import "reflect"
// Path specifies glob paths for the runner to look up .feature files.
// The default is `features/*.feature`.
func (r *Runner) Path(paths ...string) *Runner {
r.paths = append(r.paths, paths...)
return r
}
// NonParallel instructs the runner not to run tests in parallel (which is the default).
func (r *Runner) NonParallel() *Runner {
r.parallel = false
return r
}
// Before registers a before hook function which can take special step arguments.
func (r *Runner) Before(hook interface{}) *Runner {
r.addHook(&r.beforeHooks, reflect.ValueOf(hook))
return r
}
// After registers an after hook function which can take special step arguments.
// This hook will be called even when the test fails.
func (r *Runner) After(hook interface{}) *Runner {
r.addHook(&r.afterHooks, reflect.ValueOf(hook))
return r
}
// BeforeStep registers a before step hook function which can take special step arguments.
func (r *Runner) BeforeStep(hook interface{}) *Runner {
r.addHook(&r.beforeStepHooks, reflect.ValueOf(hook))
return r
}
// AfterStep registers an after step hook function which can take special step arguments.
// This hook will be called even when the test fails.
func (r *Runner) AfterStep(hook interface{}) *Runner {
r.addHook(&r.afterStepHooks, reflect.ValueOf(hook))
return r
}
func (r *Runner) addHook(hooks *[]*stepDef, f reflect.Value) {
def := r.newStepDefOrHook(r.topLevelT, nil, f)
if def.usesRapid() {
r.suiteUsesRapid = true
}
*hooks = append(*hooks, def)
}