diff --git a/CHANGELOG.md b/CHANGELOG.md index b882807..0d4e796 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ The format is based on [Keep a Changelog], and this project adheres to [Keep a Changelog]: https://keepachangelog.com/en/1.0.0/ [Semantic Versioning]: https://semver.org/spec/v2.0.0.html -## [Unreleased] +## [0.12.0] - 2020-12-20 This release includes several changes to the underlying action and expectation systems, some of which are not backwards compatable. Tests written using v0.11.0 @@ -23,6 +23,7 @@ should continue to work without modification. ### Changed - **[BC]** Renamed `Action.Apply()` to `Do()` +- `Test.Expect()` now returns the `Test`, allowing chained calls ### Removed @@ -243,6 +244,7 @@ simple to migrate existing tests to the new API. Please see the [0.9.0]: https://github.com/dogmatiq/testkit/releases/tag/v0.9.0 [0.10.0]: https://github.com/dogmatiq/testkit/releases/tag/v0.10.0 [0.11.0]: https://github.com/dogmatiq/testkit/releases/tag/v0.11.0 +[0.12.0]: https://github.com/dogmatiq/testkit/releases/tag/v0.12.0 [v0.11.0 migration guide]: https://github.com/dogmatiq/testkit/blob/main/docs/MIGRATING-v0.11.0.md diff --git a/test.go b/test.go index 6d1c0b6..f1fd939 100644 --- a/test.go +++ b/test.go @@ -91,7 +91,7 @@ func (t *Test) Prepare(actions ...Action) *Test { } // Expect ensures that a single action results in some expected behavior. -func (t *Test) Expect(act Action, e Expectation) { +func (t *Test) Expect(act Action, e Expectation) *Test { t.testingT.Helper() s := PredicateScope{App: t.app} @@ -102,7 +102,7 @@ func (t *Test) Expect(act Action, e Expectation) { p, err := e.Predicate(s) if err != nil { t.testingT.Fatal(err) - return // required when using a mock testingT that does not panic + return t // required when using a mock testingT that does not panic } // Using a defer inside a closure satisfies the requirements of the @@ -114,7 +114,7 @@ func (t *Test) Expect(act Action, e Expectation) { return t.doAction(act, engine.WithObserver(p)) }(); err != nil { t.testingT.Fatal(err) - return // required when using a mock testingT that does not panic + return t // required when using a mock testingT that does not panic } treeOk := p.Ok() @@ -128,6 +128,8 @@ func (t *Test) Expect(act Action, e Expectation) { if !treeOk { t.testingT.FailNow() } + + return t } // CommandExecutor returns a dogma.CommandExecutor which can be used to execute