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

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

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

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

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

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

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

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

@ -28,9 +28,9 @@ Feature: undefined step snippets
return godog.ErrPending return godog.ErrPending
} }
func FeatureContext(s *godog.Suite) { func InitializeScenario(ctx *godog.ScenarioContext) {
s.Step(`^I send "([^"]*)" request to "([^"]*)"$`, iSendRequestTo) ctx.Step(`^I send "([^"]*)" request to "([^"]*)"$`, iSendRequestTo)
s.Step(`^the response code should be (\d+)$`, theResponseCodeShouldBe) ctx.Step(`^the response code should be (\d+)$`, theResponseCodeShouldBe)
} }
""" """
@ -56,9 +56,9 @@ Feature: undefined step snippets
return godog.ErrPending return godog.ErrPending
} }
func FeatureContext(s *godog.Suite) { func InitializeScenario(ctx *godog.ScenarioContext) {
s.Step(`^I send "([^"]*)" request to "([^"]*)" with:$`, iSendRequestToWith) ctx.Step(`^I send "([^"]*)" request to "([^"]*)" with:$`, iSendRequestToWith)
s.Step(`^the response code should be (\d+) and header "([^"]*)" should be "([^"]*)"$`, theResponseCodeShouldBeAndHeaderShouldBe) ctx.Step(`^the response code should be (\d+) and header "([^"]*)" should be "([^"]*)"$`, theResponseCodeShouldBeAndHeaderShouldBe)
} }
""" """
@ -87,9 +87,9 @@ Feature: undefined step snippets
return godog.ErrPending return godog.ErrPending
} }
func FeatureContext(s *godog.Suite) { func InitializeScenario(ctx *godog.ScenarioContext) {
s.Step(`^I pull from github\.com$`, iPullFromGithubcom) ctx.Step(`^I pull from github\.com$`, iPullFromGithubcom)
s.Step(`^the project should be there$`, theProjectShouldBeThere) ctx.Step(`^the project should be there$`, theProjectShouldBeThere)
} }
""" """
@ -113,9 +113,9 @@ Feature: undefined step snippets
return godog.ErrPending return godog.ErrPending
} }
func FeatureContext(s *godog.Suite) { func InitializeScenario(ctx *godog.ScenarioContext) {
s.Step(`^I add the "([^"]*)" to the basket$`, iAddTheToTheBasket) ctx.Step(`^I add the "([^"]*)" to the basket$`, iAddTheToTheBasket)
s.Step(`^there is a "([^"]*)", which costs £(\d+)$`, thereIsAWhichCosts) ctx.Step(`^there is a "([^"]*)", which costs £(\d+)$`, thereIsAWhichCosts)
} }
""" """
@ -139,8 +139,8 @@ Feature: undefined step snippets
return godog.ErrPending return godog.ErrPending
} }
func FeatureContext(s *godog.Suite) { func InitializeScenario(ctx *godog.ScenarioContext) {
s.Step(`^(\d+) godogs$`, godogs) ctx.Step(`^(\d+) godogs$`, godogs)
s.Step(`^"([^"]*)", which costs £(\d+)$`, whichCosts) 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 // BindFlags binds godog flags to given flag set prefixed
// by given prefix, without overriding usage // 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) { func BindFlags(prefix string, set *flag.FlagSet, opt *Options) {
descFormatOption := "How to format tests output. Built-in formats:\n" descFormatOption := "How to format tests output. Built-in formats:\n"
// @TODO: sort by name // @TODO: sort by name

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

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

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

@ -26,4 +26,4 @@
{"event":"TestStepStarted","location":"formatter-tests/features/some_scenarions_including_failing.feature:14","timestamp":-6795364578871} {"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":"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":"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 return godog.ErrPending
} }
func FeatureContext(s *godog.Suite) { func InitializeScenario(ctx *godog.ScenarioContext) {
s.Step(`^undefined$`, undefined) ctx.Step(`^undefined$`, undefined)
} }
</yellow> </yellow>

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

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

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

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

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

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