fixes a bug, when there are undefined steps after failing step #80
Этот коммит содержится в:
родитель
865c0c18b6
коммит
f87d99d0aa
4 изменённых файлов: 85 добавлений и 11 удалений
|
@ -20,6 +20,6 @@ Feature: get version
|
||||||
And the response should match json:
|
And the response should match json:
|
||||||
"""
|
"""
|
||||||
{
|
{
|
||||||
"version": "v0.7.0"
|
"version": "v0.7.1"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -190,3 +190,75 @@ Feature: run features
|
||||||
"""
|
"""
|
||||||
I should have 1 scenario registered
|
I should have 1 scenario registered
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
Scenario: should fail suite if undefined steps follow after the failure
|
||||||
|
Given a feature "failed.feature" file:
|
||||||
|
"""
|
||||||
|
Feature: failed feature
|
||||||
|
|
||||||
|
Scenario: parse a scenario
|
||||||
|
Given a failing step
|
||||||
|
When an undefined step
|
||||||
|
Then another undefined step
|
||||||
|
"""
|
||||||
|
When I run feature suite
|
||||||
|
Then the following step should be failed:
|
||||||
|
"""
|
||||||
|
a failing step
|
||||||
|
"""
|
||||||
|
And the following steps should be undefined:
|
||||||
|
"""
|
||||||
|
an undefined step
|
||||||
|
another undefined step
|
||||||
|
"""
|
||||||
|
And the suite should have failed
|
||||||
|
|
||||||
|
Scenario: should fail suite and skip pending step after failed step
|
||||||
|
Given a feature "failed.feature" file:
|
||||||
|
"""
|
||||||
|
Feature: failed feature
|
||||||
|
|
||||||
|
Scenario: parse a scenario
|
||||||
|
Given a failing step
|
||||||
|
When pending step
|
||||||
|
Then another undefined step
|
||||||
|
"""
|
||||||
|
When I run feature suite
|
||||||
|
Then the following step should be failed:
|
||||||
|
"""
|
||||||
|
a failing step
|
||||||
|
"""
|
||||||
|
And the following steps should be skipped:
|
||||||
|
"""
|
||||||
|
pending step
|
||||||
|
"""
|
||||||
|
And the following steps should be undefined:
|
||||||
|
"""
|
||||||
|
another undefined step
|
||||||
|
"""
|
||||||
|
And the suite should have failed
|
||||||
|
|
||||||
|
Scenario: should fail suite and skip next step after failed step
|
||||||
|
Given a feature "failed.feature" file:
|
||||||
|
"""
|
||||||
|
Feature: failed feature
|
||||||
|
|
||||||
|
Scenario: parse a scenario
|
||||||
|
Given a failing step
|
||||||
|
When a failing step
|
||||||
|
Then another undefined step
|
||||||
|
"""
|
||||||
|
When I run feature suite
|
||||||
|
Then the following step should be failed:
|
||||||
|
"""
|
||||||
|
a failing step
|
||||||
|
"""
|
||||||
|
And the following steps should be skipped:
|
||||||
|
"""
|
||||||
|
a failing step
|
||||||
|
"""
|
||||||
|
And the following steps should be undefined:
|
||||||
|
"""
|
||||||
|
another undefined step
|
||||||
|
"""
|
||||||
|
And the suite should have failed
|
||||||
|
|
2
godog.go
2
godog.go
|
@ -39,4 +39,4 @@ Godog was inspired by Behat and Cucumber the above description is taken from it'
|
||||||
package godog
|
package godog
|
||||||
|
|
||||||
// Version of package - based on Semantic Versioning 2.0.0 http://semver.org/
|
// Version of package - based on Semantic Versioning 2.0.0 http://semver.org/
|
||||||
const Version = "v0.7.0"
|
const Version = "v0.7.1"
|
||||||
|
|
20
suite.go
20
suite.go
|
@ -335,13 +335,15 @@ func (s *Suite) matchStepText(text string) *StepDef {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Suite) runSteps(steps []*gherkin.Step, prevErr error) (err error) {
|
func (s *Suite) runSteps(steps []*gherkin.Step) (err error) {
|
||||||
err = prevErr
|
|
||||||
for _, step := range steps {
|
for _, step := range steps {
|
||||||
stepErr := s.runStep(step, err)
|
stepErr := s.runStep(step, err)
|
||||||
switch stepErr {
|
switch stepErr {
|
||||||
case ErrUndefined:
|
case ErrUndefined:
|
||||||
err = stepErr
|
// do not overwrite failed error
|
||||||
|
if err == ErrUndefined || err == nil {
|
||||||
|
err = stepErr
|
||||||
|
}
|
||||||
case ErrPending:
|
case ErrPending:
|
||||||
err = stepErr
|
err = stepErr
|
||||||
case nil:
|
case nil:
|
||||||
|
@ -397,12 +399,11 @@ func (s *Suite) runOutline(outline *gherkin.ScenarioOutline, b *gherkin.Backgrou
|
||||||
// run example table row
|
// run example table row
|
||||||
s.fmt.Node(group)
|
s.fmt.Node(group)
|
||||||
|
|
||||||
// run background
|
|
||||||
var err error
|
|
||||||
if b != nil {
|
if b != nil {
|
||||||
err = s.runSteps(b.Steps, err)
|
steps = append(b.Steps, steps...)
|
||||||
}
|
}
|
||||||
err = s.runSteps(steps, err)
|
|
||||||
|
err := s.runSteps(steps)
|
||||||
|
|
||||||
for _, f := range s.afterScenarioHandlers {
|
for _, f := range s.afterScenarioHandlers {
|
||||||
f(outline, err)
|
f(outline, err)
|
||||||
|
@ -464,12 +465,13 @@ func (s *Suite) runScenario(scenario *gherkin.Scenario, b *gherkin.Background) (
|
||||||
s.fmt.Node(scenario)
|
s.fmt.Node(scenario)
|
||||||
|
|
||||||
// background
|
// background
|
||||||
|
steps := scenario.Steps
|
||||||
if b != nil {
|
if b != nil {
|
||||||
err = s.runSteps(b.Steps, err)
|
steps = append(b.Steps, steps...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// scenario
|
// scenario
|
||||||
err = s.runSteps(scenario.Steps, err)
|
err = s.runSteps(steps)
|
||||||
|
|
||||||
// run after scenario handlers
|
// run after scenario handlers
|
||||||
for _, f := range s.afterScenarioHandlers {
|
for _, f := range s.afterScenarioHandlers {
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче