Tests often create data as they run: a new application, a record, an account. Without a reliable way to clean that data up, it can start piling up in your environment long after the test finishes. To keep your tests self-contained, you can now mark a step group or flow at the end of a test as a teardown. A teardown runs every time the test runs, even when the test fails, so the data your test creates gets cleaned up either way.
- Cleanup that always runs: teardown steps execute whether the test passes or fails, so a mid-test failure never leaves data stranded.
- Self-contained tests: the cleanup lives in the test that created the data, so there's no separate teardown test or dedicated plan stage to build and maintain.
- Ready for agentic authoring: the mabl agent can author tests that set up their own data and tear it down, following the prepare, act, clean up pattern that good end-to-end tests use.
Try it out
- Open a test in the mabl Trainer on the latest version of the mabl Desktop App.
- Add the step group or flow you want to use for cleanup as the last step in the test.
- Mark it as a teardown: ... (More actions) > Run as teardown flow/group. The teardown option is only available if the step group or flow is the final step in the test.
- Author the cleanup steps. A common pattern is to capture the ID of data created during the test, store it in a variable, and use that ID in the teardown to remove exactly what the test made.
Because teardown is meant to run to completion, a failure inside it fails the test, the same way it would in a framework like Playwright or Jest. Write teardown steps that clean up reliably rather than assertions that might fail.