Fixed the undefined step definitions help (#350)

Этот коммит содержится в:
Fredrik Lönnblad 2020-10-14 08:39:14 +02:00 коммит произвёл GitHub
родитель 027a1abf0e
коммит 7014a10e2f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
12 изменённых файлов: 41 добавлений и 41 удалений

Просмотреть файл

@ -138,10 +138,10 @@ func thereShouldBeRemaining(arg1 int) error {
return godog.ErrPending
}
func FeatureContext(s *godog.Suite) {
s.Step(`^I eat (\d+)$`, iEat)
s.Step(`^there are (\d+) godogs$`, thereAreGodogs)
s.Step(`^there should be (\d+) remaining$`, thereShouldBeRemaining)
func InitializeScenario(ctx *godog.ScenarioContext) {
ctx.Step(`^I eat (\d+)$`, iEat)
ctx.Step(`^there are (\d+) godogs$`, thereAreGodogs)
ctx.Step(`^there should be (\d+) remaining$`, thereShouldBeRemaining)
}
```
@ -163,10 +163,10 @@ func thereShouldBeRemaining(arg1 int) error {
return godog.ErrPending
}
func FeatureContext(s *godog.Suite) {
s.Step(`^I eat (\d+)$`, iEat)
s.Step(`^there are (\d+) godogs$`, thereAreGodogs)
s.Step(`^there should be (\d+) remaining$`, thereShouldBeRemaining)
func InitializeScenario(ctx *godog.ScenarioContext) {
ctx.Step(`^I eat (\d+)$`, iEat)
ctx.Step(`^there are (\d+) godogs$`, thereAreGodogs)
ctx.Step(`^there should be (\d+) remaining$`, thereShouldBeRemaining)
}
```

Просмотреть файл

@ -14,7 +14,7 @@ import (
var opts = godog.Options{Output: colors.Colored(os.Stdout)}
func init() {
godog.BindCommandLineFlags("godog.", &opts)
godog.BindFlags("godog.", flag.CommandLine, &opts)
}
func TestMain(m *testing.M) {

Просмотреть файл

@ -13,7 +13,7 @@ import (
var opts = godog.Options{Output: colors.Colored(os.Stdout)}
func init() {
godog.BindCommandLineFlags("godog.", &opts)
godog.BindFlags("godog.", flag.CommandLine, &opts)
}
func TestMain(m *testing.M) {

Просмотреть файл

@ -287,8 +287,8 @@ Feature: pretty formatter
return godog.ErrPending
}
func FeatureContext(s *godog.Suite) {
s.Step(`^undefined$`, undefined)
func InitializeScenario(ctx *godog.ScenarioContext) {
ctx.Step(`^undefined$`, undefined)
}
"""

Просмотреть файл

@ -28,9 +28,9 @@ Feature: undefined step snippets
return godog.ErrPending
}
func FeatureContext(s *godog.Suite) {
s.Step(`^I send "([^"]*)" request to "([^"]*)"$`, iSendRequestTo)
s.Step(`^the response code should be (\d+)$`, theResponseCodeShouldBe)
func InitializeScenario(ctx *godog.ScenarioContext) {
ctx.Step(`^I send "([^"]*)" request to "([^"]*)"$`, iSendRequestTo)
ctx.Step(`^the response code should be (\d+)$`, theResponseCodeShouldBe)
}
"""
@ -56,9 +56,9 @@ Feature: undefined step snippets
return godog.ErrPending
}
func FeatureContext(s *godog.Suite) {
s.Step(`^I send "([^"]*)" request to "([^"]*)" with:$`, iSendRequestToWith)
s.Step(`^the response code should be (\d+) and header "([^"]*)" should be "([^"]*)"$`, theResponseCodeShouldBeAndHeaderShouldBe)
func InitializeScenario(ctx *godog.ScenarioContext) {
ctx.Step(`^I send "([^"]*)" request to "([^"]*)" with:$`, iSendRequestToWith)
ctx.Step(`^the response code should be (\d+) and header "([^"]*)" should be "([^"]*)"$`, theResponseCodeShouldBeAndHeaderShouldBe)
}
"""
@ -87,9 +87,9 @@ Feature: undefined step snippets
return godog.ErrPending
}
func FeatureContext(s *godog.Suite) {
s.Step(`^I pull from github\.com$`, iPullFromGithubcom)
s.Step(`^the project should be there$`, theProjectShouldBeThere)
func InitializeScenario(ctx *godog.ScenarioContext) {
ctx.Step(`^I pull from github\.com$`, iPullFromGithubcom)
ctx.Step(`^the project should be there$`, theProjectShouldBeThere)
}
"""
@ -113,9 +113,9 @@ Feature: undefined step snippets
return godog.ErrPending
}
func FeatureContext(s *godog.Suite) {
s.Step(`^I add the "([^"]*)" to the basket$`, iAddTheToTheBasket)
s.Step(`^there is a "([^"]*)", which costs £(\d+)$`, thereIsAWhichCosts)
func InitializeScenario(ctx *godog.ScenarioContext) {
ctx.Step(`^I add the "([^"]*)" to the basket$`, iAddTheToTheBasket)
ctx.Step(`^there is a "([^"]*)", which costs £(\d+)$`, thereIsAWhichCosts)
}
"""
@ -139,8 +139,8 @@ Feature: undefined step snippets
return godog.ErrPending
}
func FeatureContext(s *godog.Suite) {
s.Step(`^(\d+) godogs$`, godogs)
s.Step(`^"([^"]*)", which costs £(\d+)$`, whichCosts)
func InitializeScenario(ctx *godog.ScenarioContext) {
ctx.Step(`^(\d+) godogs$`, godogs)
ctx.Step(`^"([^"]*)", which costs £(\d+)$`, whichCosts)
}
"""

Просмотреть файл

@ -49,7 +49,8 @@ func FlagSet(opt *Options) *flag.FlagSet {
// BindFlags binds godog flags to given flag set prefixed
// by given prefix, without overriding usage
//
// Deprecated: Use BindCommandLineFlags(prefix, &opts) instead of BindFlags(prefix, flag.CommandLine, &opts)
// Deprecated: Use BindCommandLineFlags(prefix, &opts)
// instead of BindFlags(prefix, flag.CommandLine, &opts)
func BindFlags(prefix string, set *flag.FlagSet, opt *Options) {
descFormatOption := "How to format tests output. Built-in formats:\n"
// @TODO: sort by name

Просмотреть файл

@ -43,7 +43,6 @@ func init() {
{{end}}
func main() {
{{if or .TestSuiteContexts .ScenarioContexts .XTestSuiteContexts .XScenarioContexts}}
status := godog.TestSuite{
Name: "{{ .Name }}",
TestSuiteInitializer: func (ctx *godog.TestSuiteContext) {
@ -64,7 +63,7 @@ func main() {
{{end}}
},
}.Run()
{{end}}
os.Exit(status)
}`))

Просмотреть файл

@ -26,4 +26,4 @@
{"event":"TestStepStarted","location":"formatter-tests/features/some_scenarions_including_failing.feature:14","timestamp":-6795364578871}
{"event":"TestStepFinished","location":"formatter-tests/features/some_scenarions_including_failing.feature:14","timestamp":-6795364578871,"status":"skipped"}
{"event":"TestCaseFinished","location":"formatter-tests/features/some_scenarions_including_failing.feature:12","timestamp":-6795364578871,"status":"undefined"}
{"event":"TestRunFinished","status":"failed","timestamp":-6795364578871,"snippets":"You can implement step definitions for undefined steps with these snippets:\n\nfunc undefined() error {\n\treturn godog.ErrPending\n}\n\nfunc FeatureContext(s *godog.Suite) {\n\ts.Step(`^undefined$`, undefined)\n}\n","memory":""}
{"event":"TestRunFinished","status":"failed","timestamp":-6795364578871,"snippets":"You can implement step definitions for undefined steps with these snippets:\n\nfunc undefined() error {\n\treturn godog.ErrPending\n}\n\nfunc InitializeScenario(ctx *godog.ScenarioContext) {\n\tctx.Step(`^undefined$`, undefined)\n}\n","memory":""}

Просмотреть файл

@ -32,7 +32,7 @@ func undefined() error {
return godog.ErrPending
}
func FeatureContext(s *godog.Suite) {
s.Step(`^undefined$`, undefined)
func InitializeScenario(ctx *godog.ScenarioContext) {
ctx.Step(`^undefined$`, undefined)
}
</yellow>

Просмотреть файл

@ -18,7 +18,7 @@ func undefined() error {
return godog.ErrPending
}
func FeatureContext(s *godog.Suite) {
s.Step(`^undefined$`, undefined)
func InitializeScenario(ctx *godog.ScenarioContext) {
ctx.Step(`^undefined$`, undefined)
}
</yellow>

Просмотреть файл

@ -27,8 +27,8 @@ var undefinedSnippetsTpl = template.Must(template.New("snippets").Funcs(snippetH
return godog.ErrPending
}
{{end}}func FeatureContext(s *godog.Suite) { {{ range . }}
s.Step({{ backticked .Expr }}, {{ .Method }}){{end}}
{{end}}func InitializeScenario(ctx *godog.ScenarioContext) { {{ range . }}
ctx.Step({{ backticked .Expr }}, {{ .Method }}){{end}}
}
`))

Просмотреть файл

@ -145,10 +145,10 @@ func undef() error {
return godog.ErrPending
}
func FeatureContext(s *godog.Suite) {
s.Step(` + "`^three$`" + `, three)
s.Step(` + "`^unavailable \"([^\"]*)\" cost (\\d+)$`" + `, unavailableCost)
s.Step(` + "`^undef$`" + `, undef)
func InitializeScenario(ctx *godog.ScenarioContext) {
ctx.Step(` + "`^three$`" + `, three)
ctx.Step(` + "`^unavailable \"([^\"]*)\" cost (\\d+)$`" + `, unavailableCost)
ctx.Step(` + "`^undef$`" + `, undef)
}
`