Skip to content

Commit

Permalink
Use fatal in the internal code to stop executing code when not needed (
Browse files Browse the repository at this point in the history
…#124)

* Use fatal in the internal code to stop executing code when not needed

* fix issue

* fix tests

Co-authored-by: Bartłomiej Klimczak <bartlomiej.klimczak@g2a.com>
  • Loading branch information
Bartłomiej Klimczak and Bartłomiej Klimczak authored Sep 29, 2020
1 parent 409b719 commit 565ba3b
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions gobdd.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,7 @@ func (s *Suite) executeFeature(file string) error {

doc, err := gherkin.ParseGherkinDocument(fileIO, (&msgs.Incrementing{}).NewId)
if err != nil {
s.t.Fail()
s.t.Errorf("error while loading document: %s\n", err)

return fmt.Errorf("error while loading document: %s", err)
s.t.Fatalf("error while loading document: %s\n", err)
}

if doc.Feature == nil {
Expand Down Expand Up @@ -493,9 +490,7 @@ func (s *Suite) runStep(ctx Context, t *testing.T, step *msgs.GherkinDocument_Fe

def, err := s.findStepDef(step.Text)
if err != nil {
t.Errorf("cannot find step definition for step: %s%s", step.Keyword, step.Text)

return
t.Fatalf("cannot find step definition for step: %s%s", step.Keyword, step.Text)
}

params := def.expr.FindSubmatch([]byte(step.Text))[1:]
Expand All @@ -520,7 +515,7 @@ func (def *stepDef) run(ctx Context, t TestingT, params [][]byte) { // nolint:in

d := reflect.ValueOf(def.f)
if len(params)+2 != d.Type().NumIn() {
t.Errorf("the step function %s accepts %d arguments but %d received", d.String(), d.Type().NumIn(), len(params)+2)
t.Fatalf("the step function %s accepts %d arguments but %d received", d.String(), d.Type().NumIn(), len(params)+2)

return
}
Expand Down

0 comments on commit 565ba3b

Please sign in to comment.