Teardowns run at the end of every test, whether that test passed or failed. While they're great for adding reliable cleanup steps, sometimes you might only want to run those steps if the test fails. Now, you can use a new set of runtime variables to conditionally run steps inside a teardown step group or flow.
Three variables resolve inside a teardown:
-
run.test_status:failedwhen a step failed before the teardown began,passedotherwise. -
run.failure_message: the message from that failure. Empty on a passing run. -
run.failed_step_number: the display number of the step that failed, such as1.1. Empty on a passing run.
Using these new variables, you can wrap teardown steps in a conditional that checks run.test_status and executes steps only on the outcome you pick. For example:
-
Clean up only after a failure: use a conditional where
run.test_statusdoes not equalpassed. -
Capture diagnostics only after a failure: use a conditional where
run.test_statusequalsfailed, then reportrun.failure_messageandrun.failed_step_numberto wherever you track failures.
Try it out
To see these variables in the Trainer's variable picker, update the mabl Desktop App to version 2.69.3 or later.
- Open a test that ends in a teardown step group or flow.
- Inside the teardown, add a conditional step that compares
run.test_status. - Add the steps you want gated inside that conditional.
- Run the test.
Cloud runs need no action. For local runs, update the mabl CLI to version 2.133.16 or later.
Note
The three variables resolve only inside a teardown. Elsewhere in a test they are empty.