When your Conveys have some set-up involved, you may need to tear down after or between tests. Use Reset()
to clean up in those cases. A Convey's Reset() runs at the end of each Convey()
within that same scope.
For example:
- Convey("Top-level", t, func() {
- // setup (run before each `Convey` at this scope):
- db.Open()
- db.Initialize()
- Convey("Test a query", func() {
- db.Query()
- // TODO: assertions here
- })
- Convey("Test inserts", func() {
- db.Insert()
- // TODO: assertions here
- })
- Reset(func() {
- // This reset is run after each `Convey` at the same scope.
- db.Close()
- })
- })