Add details to "step is undefined" error (#669)
* Add details to "step is undefined" error * Update changelog
Этот коммит содержится в:
родитель
da4633a421
коммит
e55eab64f7
4 изменённых файлов: 22 добавлений и 18 удалений
|
@ -8,6 +8,10 @@ This document is formatted according to the principles of [Keep A CHANGELOG](htt
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Step text is added to "step is undefined" error - ([669](https://github.com/cucumber/godog/pull/669) - [vearutop](https://github.com/vearutop))
|
||||||
|
|
||||||
|
### Fixed
|
||||||
- fix(formatter): On concurrent execution, execute formatter at end of Scenario - ([645](https://github.com/cucumber/godog/pull/645) - [tigh-latte](https://github.com/tigh-latte))
|
- fix(formatter): On concurrent execution, execute formatter at end of Scenario - ([645](https://github.com/cucumber/godog/pull/645) - [tigh-latte](https://github.com/tigh-latte))
|
||||||
|
|
||||||
## [v0.15.0]
|
## [v0.15.0]
|
||||||
|
|
|
@ -42,7 +42,7 @@ And step failed f2s3:4
|
||||||
|
|
||||||
Scenario: f2s4
|
Scenario: f2s4
|
||||||
When step passed f2s4:1
|
When step passed f2s4:1
|
||||||
Then step is undefined f2s4:2
|
Then something unknown happens f2s4:2
|
||||||
And step passed f2s4:3
|
And step passed f2s4:3
|
||||||
`)},
|
`)},
|
||||||
)
|
)
|
||||||
|
@ -116,8 +116,8 @@ scenario "f2s3" passed
|
||||||
|
|
||||||
step invoked: "f2s4:1", passed
|
step invoked: "f2s4:1", passed
|
||||||
step "step passed f2s4:1" finished with status passed
|
step "step passed f2s4:1" finished with status passed
|
||||||
.Ustep "step is undefined f2s4:2" finished with status undefined
|
.Ustep "something unknown happens f2s4:2" finished with status undefined
|
||||||
scenario "f2s4" ended with error "step is undefined"
|
scenario "f2s4" ended with error "step is undefined: something unknown happens f2s4:2"
|
||||||
-step "step passed f2s4:3" finished with status skipped
|
-step "step passed f2s4:3" finished with status skipped
|
||||||
13
|
13
|
||||||
|
|
||||||
|
@ -139,12 +139,12 @@ scenario "f2s4" ended with error "step is undefined"
|
||||||
|
|
||||||
You can implement step definitions for undefined steps with these snippets:
|
You can implement step definitions for undefined steps with these snippets:
|
||||||
|
|
||||||
func stepIsUndefinedFS(arg1, arg2, arg3 int) error {
|
func somethingUnknownHappensFS(arg1, arg2, arg3 int) error {
|
||||||
return godog.ErrPending
|
return godog.ErrPending
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitializeScenario(ctx *godog.ScenarioContext) {
|
func InitializeScenario(ctx *godog.ScenarioContext) {
|
||||||
ctx.Step(`+"`"+`^step is undefined f(\d+)s(\d+):(\d+)$`+"`"+`, stepIsUndefinedFS)
|
ctx.Step(`+"`"+`^something unknown happens f(\d+)s(\d+):(\d+)$`+"`"+`, somethingUnknownHappensFS)
|
||||||
}
|
}
|
||||||
|
|
||||||
`, out.String())
|
`, out.String())
|
||||||
|
|
6
suite.go
6
suite.go
|
@ -270,7 +270,7 @@ func (s *suite) runStep(ctx context.Context, pickle *Scenario, step *Step, scena
|
||||||
s.storage.MustInsertPickleStepResult(sr)
|
s.storage.MustInsertPickleStepResult(sr)
|
||||||
|
|
||||||
s.fmt.Undefined(pickle, step, match.GetInternalStepDefinition())
|
s.fmt.Undefined(pickle, step, match.GetInternalStepDefinition())
|
||||||
return ctx, ErrUndefined
|
return ctx, fmt.Errorf("%w: %s", ErrUndefined, step.Text)
|
||||||
}
|
}
|
||||||
|
|
||||||
if scenarioErr != nil {
|
if scenarioErr != nil {
|
||||||
|
@ -461,7 +461,7 @@ func (s *suite) maybeSubSteps(ctx context.Context, result interface{}) (context.
|
||||||
}
|
}
|
||||||
|
|
||||||
if def == nil {
|
if def == nil {
|
||||||
return ctx, ErrUndefined
|
return ctx, fmt.Errorf("%w: %s", ErrUndefined, text)
|
||||||
} else {
|
} else {
|
||||||
ctx, err = s.runSubStep(ctx, text, def)
|
ctx, err = s.runSubStep(ctx, text, def)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -609,7 +609,7 @@ func (s *suite) runPickle(pickle *messages.Pickle) (err error) {
|
||||||
s.storage.MustInsertPickleResult(pr)
|
s.storage.MustInsertPickleResult(pr)
|
||||||
|
|
||||||
s.fmt.Pickle(pickle)
|
s.fmt.Pickle(pickle)
|
||||||
return ErrUndefined
|
return fmt.Errorf("%w: no steps in scenario", ErrUndefined)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Before scenario hooks are called in context of first evaluated step
|
// Before scenario hooks are called in context of first evaluated step
|
||||||
|
|
|
@ -1008,13 +1008,13 @@ func TestTestSuite_Run(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "undefined_then_pass_no_strict_doesnt_fail_scenario", afterStepCnt: 2, beforeStepCnt: 2, noStrict: true, suitePasses: true,
|
name: "undefined_then_pass_no_strict_doesnt_fail_scenario", afterStepCnt: 2, beforeStepCnt: 2, noStrict: true, suitePasses: true,
|
||||||
body: `
|
body: `
|
||||||
When step is undefined
|
When something unknown happens
|
||||||
Then step passes`,
|
Then step passes`,
|
||||||
log: `
|
log: `
|
||||||
>>>> Before suite
|
>>>> Before suite
|
||||||
>> Before scenario "test"
|
>> Before scenario "test"
|
||||||
Before step "step is undefined"
|
Before step "something unknown happens"
|
||||||
After step "step is undefined", error: step is undefined, status: undefined
|
After step "something unknown happens", error: step is undefined: something unknown happens, status: undefined
|
||||||
Before step "step passes"
|
Before step "step passes"
|
||||||
After step "step passes", error: <nil>, status: skipped
|
After step "step passes", error: <nil>, status: skipped
|
||||||
<< After scenario "test", error: <nil>
|
<< After scenario "test", error: <nil>
|
||||||
|
@ -1023,14 +1023,14 @@ func TestTestSuite_Run(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "undefined_then_pass_fails_scenario", afterStepCnt: 2, beforeStepCnt: 2,
|
name: "undefined_then_pass_fails_scenario", afterStepCnt: 2, beforeStepCnt: 2,
|
||||||
body: `
|
body: `
|
||||||
When step is undefined
|
When something unknown happens
|
||||||
Then step passes`,
|
Then step passes`,
|
||||||
log: `
|
log: `
|
||||||
>>>> Before suite
|
>>>> Before suite
|
||||||
>> Before scenario "test"
|
>> Before scenario "test"
|
||||||
Before step "step is undefined"
|
Before step "something unknown happens"
|
||||||
After step "step is undefined", error: step is undefined, status: undefined
|
After step "something unknown happens", error: step is undefined: something unknown happens, status: undefined
|
||||||
<< After scenario "test", error: step is undefined
|
<< After scenario "test", error: step is undefined: something unknown happens
|
||||||
Before step "step passes"
|
Before step "step passes"
|
||||||
After step "step passes", error: <nil>, status: skipped
|
After step "step passes", error: <nil>, status: skipped
|
||||||
<<<< After suite`,
|
<<<< After suite`,
|
||||||
|
@ -1039,15 +1039,15 @@ func TestTestSuite_Run(t *testing.T) {
|
||||||
name: "fail_then_undefined_fails_scenario", afterStepCnt: 2, beforeStepCnt: 2,
|
name: "fail_then_undefined_fails_scenario", afterStepCnt: 2, beforeStepCnt: 2,
|
||||||
body: `
|
body: `
|
||||||
When step fails
|
When step fails
|
||||||
Then step is undefined`,
|
Then something unknown happens`,
|
||||||
log: `
|
log: `
|
||||||
>>>> Before suite
|
>>>> Before suite
|
||||||
>> Before scenario "test"
|
>> Before scenario "test"
|
||||||
Before step "step fails"
|
Before step "step fails"
|
||||||
After step "step fails", error: oops, status: failed
|
After step "step fails", error: oops, status: failed
|
||||||
<< After scenario "test", error: oops
|
<< After scenario "test", error: oops
|
||||||
Before step "step is undefined"
|
Before step "something unknown happens"
|
||||||
After step "step is undefined", error: step is undefined, status: undefined
|
After step "something unknown happens", error: step is undefined: something unknown happens, status: undefined
|
||||||
<<<< After suite`,
|
<<<< After suite`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче