diff --git a/README.md b/README.md index aa6bf71..e522393 100644 --- a/README.md +++ b/README.md @@ -77,22 +77,22 @@ type suite struct { When you run the tests, they should fail and suggest that you add these step definitions: ```go -func (s *suite) IEat(a int64) { +func (s *suite) IHaveCukes(a int64) { panic("PENDING") } -func (s *suite) IHaveLeft(a int64) { +func (s *suite) IEat(a int64) { panic("PENDING") } -func (s *suite) IHaveCukes(a int64) { +func (s *suite) IHaveLeft(a int64) { panic("PENDING") } Steps can be manually registered with the runner for customization using this code: - Step(`^I\s+have\s+(-?\d+)\s+cukes$`, (*simpleSuite).IHaveCukes). - Step(`^I\s+eat\s+(-?\d+)$`, (*simpleSuite).IEat). - Step(`^I\s+have\s+(-?\d+)\s+left$`, (*simpleSuite).IHaveLeft) + Step(`^I\s+have\s+(-?\d+)\s+cukes$`, (*suite).IHaveCukes). + Step(`^I\s+eat\s+(-?\d+)$`, (*suite).IEat). + Step(`^I\s+have\s+(-?\d+)\s+left$`, (*suite).IHaveLeft) ``` Copy these definitions into `simple_test.go`. diff --git a/find_step.go b/find_step.go index 4fdf6e1..461275b 100644 --- a/find_step.go +++ b/find_step.go @@ -22,7 +22,10 @@ func (r *Runner) findStep(t *testing.T, step *messages.PickleStep) *stepDef { return r.addStepDef(t, sig.regex, method.Func) } - r.suggestions[sig.name] = sig + if !r.haveSuggestion[sig.name] { + r.haveSuggestion[sig.name] = true + r.suggestions = append(r.suggestions, sig) + } t.Errorf("can't find step definition for: %s", step.Text) return nil diff --git a/runner.go b/runner.go index 97bdcd1..c91cc16 100644 --- a/runner.go +++ b/runner.go @@ -17,7 +17,8 @@ type Runner struct { paths []string parallel bool stepDefs []*stepDef - suggestions map[string]methodSig + haveSuggestion map[string]bool + suggestions []methodSig supportedSpecialArgs map[reflect.Type]specialArgGetter suiteInjectors []*suiteInjector beforeHooks []*stepDef @@ -56,10 +57,10 @@ func NewRunner(t *testing.T, suiteType interface{}) *Runner { initGlobalTagExpr() r := &Runner{ - topLevelT: t, - incr: &messages.Incrementing{}, - parallel: false, - suggestions: map[string]methodSig{}, + topLevelT: t, + incr: &messages.Incrementing{}, + parallel: false, + haveSuggestion: map[string]bool{}, supportedSpecialArgs: map[reflect.Type]specialArgGetter{ // TestingT reflect.TypeOf((*TestingT)(nil)).Elem(): func(runner *scenarioRunner) interface{} {