diff --git a/CHANGELOG.md b/CHANGELOG.md index b6762b3..06e985d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,17 +8,21 @@ This document is formatted according to the principles of [Keep A CHANGELOG](htt --- -## [Unreleased] +## [v0.12.0] ### Added - Support for step definitions without return ([364](https://github.com/cucumber/godog/pull/364) - [titouanfreville]) - Contextualized hooks for scenarios and steps ([409](https://github.com/cucumber/godog/pull/409)) - [vearutop]) - Step result status in After hook ([409](https://github.com/cucumber/godog/pull/409)) - [vearutop]) +- Support auto converting doc strings to plain strings ([380](https://github.com/cucumber/godog/pull/380)) - [chirino]) +- Use multiple formatters in the same test run ([392](https://github.com/cucumber/godog/pull/392)) - [vearutop]) +- Added `RetrieveFeatures()` method to `godog.TestSuite` ([276](https://github.com/cucumber/godog/pull/276)) - [radtriste]) ### Changed -- Upgraded gherkin-go to v19 ([402](https://github.com/cucumber/godog/pull/402) - [mbow]) +- Upgraded gherkin-go to v19 and messages-go to v16 ([402](https://github.com/cucumber/godog/pull/402) - [mbow]) +- Generate simpler snippets that use *godog.DocString and *godog.Table ([379](https://github.com/cucumber/godog/pull/379)) - [chirino]) ### Deprecated @@ -207,3 +211,6 @@ This document is formatted according to the principles of [Keep A CHANGELOG](htt [rickardenglund]: https://github.com/rickardenglund [mbow]: https://github.com/mbow [vearutop]: https://github.com/vearutop +[chirino]: https://github.com/chirino +[radtriste]: https://github.com/radtriste +[karfrank]: https://github.com/karfrank diff --git a/README.md b/README.md index 08c84e9..3aa722a 100644 --- a/README.md +++ b/README.md @@ -45,13 +45,13 @@ When automated testing is this much fun, teams can easily protect themselves fro ## Install ``` -go get github.com/cucumber/godog/cmd/godog@v0.11.0 +go get github.com/cucumber/godog/cmd/godog@v0.12.0 ``` -Adding `@v0.11.0` will install v0.11.0 specifically instead of master. +Adding `@v0.12.0` will install v0.12.0 specifically instead of master. Running `within the $GOPATH`, you would also need to set `GO111MODULE=on`, like this: ``` -GO111MODULE=on go get github.com/cucumber/godog/cmd/godog@v0.11.0 +GO111MODULE=on go get github.com/cucumber/godog/cmd/godog@v0.12.0 ``` ## Contributions @@ -390,7 +390,7 @@ import ( "github.com/cucumber/godog" "github.com/cucumber/godog/colors" - "github.com/spf13/pflag" // godog v0.11.0 (latest) + "github.com/spf13/pflag" // godog v0.11.0 and later ) var opts = godog.Options{ diff --git a/godog.go b/godog.go index b97c233..1b8d98b 100644 --- a/godog.go +++ b/godog.go @@ -39,4 +39,4 @@ Godog was inspired by Behat and Cucumber the above description is taken from it' package godog // Version of package - based on Semantic Versioning 2.0.0 http://semver.org/ -const Version = "v0.11.0" +const Version = "v0.12.0" diff --git a/release-notes/v0.12.0.md b/release-notes/v0.12.0.md new file mode 100644 index 0000000..b25e3c3 --- /dev/null +++ b/release-notes/v0.12.0.md @@ -0,0 +1,132 @@ +We are excited to announce the release of godog v0.12.0. + +Here follows a summary of Notable Changes, the Non Backward Compatible Changes and Deprecation Notices. The full change +log is available [here](https://github.com/cucumber/godog/blob/master/CHANGELOG.md). + + +Notable Changes +--------------- + +### Output with multiple formatters + +Now `godog` is able to use multiple formatters simultaneously with comma-separated formatters. + +`--format pretty,junit:report.xml,cucumber:report.json` will write `pretty` format to stdout, `junit` to report.xml +and `cucumber` to report.json. + +### Contextualized hooks + +Scenario and Step hooks are now passing context to allow custom state communication. Returned context should generally +be based or equal to received context. Context is also passed to steps that have it in declaration and is read from +steps that return it. + +Hooks can now return error, if non nil error is returned test is failed. This enables additional flow control, for +example to check expectations after the scenario. + +Scenario hooks are now named `Before` and `After`. + +```go +// BeforeScenarioHook defines a hook before scenario. +type BeforeScenarioHook func (ctx context.Context, sc *Scenario) (context.Context, error) + +// AfterScenarioHook defines a hook after scenario. +type AfterScenarioHook func (ctx context.Context, sc *Scenario, err error) (context.Context, error) +``` + +Step hooks are now also named `Before` and `After`, but they are available with `ScenarioContext.StepContext()`. + +```go +// BeforeStepHook defines a hook before step. +type BeforeStepHook func (ctx context.Context, st *Step) (context.Context, error) + +// AfterStepHook defines a hook after step. +type AfterStepHook func (ctx context.Context, st *Step, status StepResultStatus, err error) (context.Context, error) +``` + +### Step definition improvements + +Now `godog` can use additional ways to declare step definition. These declarations are optional and do not break +backwards compatibility. + +Error result may be omitted if the step does not fail. + +```go +func iEat(arg1 int) { + // Eat arg1. +} +``` + +You can have `context.Context` as first argument, test runner will pass current context to the step. + +```go +func iEat(ctx context.Context, arg1 int) { + if v, ok := ctx.Value(eatKey{}).int; ok { + // Eat v from context. + } + // Eat arg1. +} +``` + +You can have `context.Context` in return, test runner will use returned context to pass to next hooks and steps. + +```go +func iEat(ctx context.Context, arg1 int) context.Context { + if v, ok := ctx.Value(eatKey{}).int; ok { + // Eat v from context. + } + // Eat arg1. + + return context.WithValue(ctx, eatKey{}, 0) +} +``` + +If error is also needed in return, context have to be first. + +```go +func iEat(ctx context.Context, arg1 int) (context.Context, error) { + if v, ok := ctx.Value(eatKey{}).int; ok { + // Eat v from context. + } + // Eat arg1. + + if arg1 == 0 { + return errors.New("can't eat nothing") + } + + return context.WithValue(ctx, eatKey{}, 0), nil +} +``` + +You can now use `string` instead of `*godog.DocString` in declaration. + +### Getting features of test suite + +`godog.TestSuite` now can `RetrieveFeatures() ([]*models.Feature, error)` to expose parsed features to the user. + +### Added official support for go1.16 + +With the introduction of go1.16, go1.16 is now officially supported. + +Non Backward Compatible Changes +------------------------------- + +### Messages library updated + +Messages library is changed from `github.com/cucumber/messages-go/v10` to `github.com/cucumber/messages-go/v16`. + +Deprecation Notices +------------------- + +### Hooks + +Scenario and step hooks were upgraded with new API to support context and errors, previous methods are now deprecated. + +- `ScenarioContext.BeforeScenario`, use `ScenarioContext.Before` +- `ScenarioContext.AfterScenario`, use `ScenarioContext.After` +- `ScenarioContext.BeforeStep`, use `ScenarioContext.StepContext().Before` +- `ScenarioContext.AfterStep`, use `ScenarioContext.StepContext().After` + +Full change log +--------------- + +See [CHANGELOG.md](https://github.com/cucumber/godog/blob/master/CHANGELOG.md).