Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
```

Expand All @@ -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)
}
```

Expand Down
2 changes: 1 addition & 1 deletion _examples/assert-godogs/godogs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion _examples/godogs/godogs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions features/formatter/pretty.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
"""

Expand Down
30 changes: 15 additions & 15 deletions features/snippets.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
"""

Expand All @@ -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)
}
"""

Expand Down Expand Up @@ -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)
}
"""

Expand All @@ -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)
}
"""

Expand All @@ -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)
}
"""
3 changes: 2 additions & 1 deletion flags_deprecated.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions internal/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -64,7 +63,7 @@ func main() {
{{end}}
},
}.Run()
{{end}}

os.Exit(status)
}`))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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":""}
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -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>
4 changes: 2 additions & 2 deletions internal/formatters/undefined_snippets_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
}
`))

Expand Down
8 changes: 4 additions & 4 deletions run_progress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

`
Expand Down