resolve step definition source code line properly with race detector enabled
Этот коммит содержится в:
родитель
51d481d1c7
коммит
2ef5a29c36
5 изменённых файлов: 81 добавлений и 14 удалений
3
fmt.go
3
fmt.go
|
@ -388,7 +388,8 @@ func (f *basefmt) Summary() {
|
|||
}
|
||||
|
||||
if text := f.snippets(); text != "" {
|
||||
fmt.Fprintln(f.out, yellow("\nYou can implement step definitions for undefined steps with these snippets:"))
|
||||
fmt.Fprintln(f.out, "")
|
||||
fmt.Fprintln(f.out, yellow("You can implement step definitions for undefined steps with these snippets:"))
|
||||
fmt.Fprintln(f.out, yellow(text))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
Feature: some scenarios
|
||||
|
||||
Scenario: failing
|
||||
Given passing step
|
||||
When failing step
|
||||
Then passing step
|
||||
|
||||
Scenario: pending
|
||||
When pending step
|
||||
Then passing step
|
||||
|
||||
Scenario: undefined
|
||||
When undefined
|
||||
Then passing step
|
|
@ -4,7 +4,7 @@
|
|||
feature
|
||||
|
||||
<bold-white>Scenario:</bold-white> one step passing <black># formatter-tests/features/single_scenario_with_passing_step.feature:6</black>
|
||||
<green>Given</green> <green>a passing step</green> <black># formatters_print_test.go:35 -> github.com/DATA-DOG/godog.TestPrintingFormatters.func4</black>
|
||||
<green>Given</green> <green>a passing step</green> <black># formatters_print_test.go:64 -> passingStepDef</black>
|
||||
|
||||
1 scenarios (<green>1 passed</green>)
|
||||
1 steps (<green>1 passed</green>)
|
||||
|
|
38
formatter-tests/pretty/some_scenarions_including_failing
Обычный файл
38
formatter-tests/pretty/some_scenarions_including_failing
Обычный файл
|
@ -0,0 +1,38 @@
|
|||
<bold-white>Feature:</bold-white> some scenarios
|
||||
|
||||
<bold-white>Scenario:</bold-white> failing <black># formatter-tests/features/some_scenarions_including_failing.feature:3</black>
|
||||
<green>Given</green> <green>passing step</green> <black># formatters_print_test.go:64 -> passingStepDef</black>
|
||||
<red>When</red> <red>failing step</red> <black># formatters_print_test.go:80 -> failingStepDef</black>
|
||||
<bold-red>step failed</bold-red>
|
||||
<cyan>Then</cyan> <cyan>passing step</cyan> <black># formatters_print_test.go:64 -> passingStepDef</black>
|
||||
|
||||
<bold-white>Scenario:</bold-white> pending <black># formatter-tests/features/some_scenarions_including_failing.feature:8</black>
|
||||
<yellow>When</yellow> <yellow>pending step</yellow> <black># formatters_print_test.go:78 -> pendingStepDef</black>
|
||||
<yellow>TODO: write pending definition</yellow>
|
||||
<cyan>Then</cyan> <cyan>passing step</cyan> <black># formatters_print_test.go:64 -> passingStepDef</black>
|
||||
|
||||
<bold-white>Scenario:</bold-white> undefined <black># formatter-tests/features/some_scenarions_including_failing.feature:12</black>
|
||||
<yellow>When</yellow> <yellow>undefined</yellow>
|
||||
<cyan>Then</cyan> <cyan>passing step</cyan> <black># formatters_print_test.go:64 -> passingStepDef</black>
|
||||
|
||||
--- <red>Failed steps:</red>
|
||||
|
||||
<red>Scenario: failing</red><black> # formatter-tests/features/some_scenarions_including_failing.feature:3</black>
|
||||
<red>When failing step</red><black> # formatter-tests/features/some_scenarions_including_failing.feature:5</black>
|
||||
<red>Error: </red><bold-red>step failed</bold-red>
|
||||
|
||||
|
||||
3 scenarios (<red>1 failed</red>, <yellow>1 pending</yellow>, <yellow>1 undefined</yellow>)
|
||||
7 steps (<green>1 passed</green>, <red>1 failed</red>, <yellow>1 pending</yellow>, <yellow>1 undefined</yellow>, <cyan>3 skipped</cyan>)
|
||||
0s
|
||||
|
||||
<yellow>You can implement step definitions for undefined steps with these snippets:</yellow>
|
||||
<yellow>
|
||||
func undefined() error {
|
||||
return godog.ErrPending
|
||||
}
|
||||
|
||||
func FeatureContext(s *godog.Suite) {
|
||||
s.Step(`^undefined$`, undefined)
|
||||
}
|
||||
</yellow>
|
|
@ -22,19 +22,14 @@ func TestPrintingFormatters(t *testing.T) {
|
|||
features: features,
|
||||
}
|
||||
|
||||
suite.Step(`^(?:a )?failing step`, func() error {
|
||||
return fmt.Errorf("step failed")
|
||||
})
|
||||
suite.Step(`^this step should fail`, func() error {
|
||||
return fmt.Errorf("step failed")
|
||||
})
|
||||
suite.Step(`^(?:a )?pending step$`, func() error {
|
||||
return ErrPending
|
||||
})
|
||||
suite.Step(`^(?:a )?passing step$`, func() error {
|
||||
return nil
|
||||
})
|
||||
// inlining steps to have same source code line reference
|
||||
suite.Step(`^(?:a )?failing step`, failingStepDef)
|
||||
suite.Step(`^(?:a )?pending step$`, pendingStepDef)
|
||||
suite.Step(`^(?:a )?passing step$`, passingStepDef)
|
||||
suite.Step(`^is <odd> and <even> number$`, oddEvenStepDef)
|
||||
|
||||
pkg := os.Getenv("GODOG_TESTED_PACKAGE")
|
||||
os.Setenv("GODOG_TESTED_PACKAGE", "github.com/DATA-DOG/godog")
|
||||
for _, feat := range features {
|
||||
for name := range AvailableFormatters() {
|
||||
expectOutputPath := strings.Replace(feat.Path, "features", name, 1)
|
||||
|
@ -63,4 +58,23 @@ func TestPrintingFormatters(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
os.Setenv("GODOG_TESTED_PACKAGE", pkg)
|
||||
}
|
||||
|
||||
func passingStepDef() error { return nil }
|
||||
|
||||
func oddEvenStepDef(odd, even int) error { return oddOrEven(odd, even) }
|
||||
|
||||
func oddOrEven(odd, even int) error {
|
||||
if odd%2 == 0 {
|
||||
return fmt.Errorf("%d is not odd", odd)
|
||||
}
|
||||
if even%2 != 0 {
|
||||
return fmt.Errorf("%d is not even", even)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func pendingStepDef() error { return ErrPending }
|
||||
|
||||
func failingStepDef() error { return fmt.Errorf("step failed") }
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче