Cleanup Steps
  • 22 Sep 2023
  • 2 Minutes to read
  • Contributors
  • Dark
    Light

Cleanup Steps

  • Dark
    Light

Article Summary

⚠️ Cleanup Steps are available on Advanced, Enterprise, or any other equivalent plans.

Overview

Cleanup Steps are special steps that always run at the end of test execution even when the scenario failed in the preceding steps. This is very useful when you have steps that need to be run when the test finishes regardless of the result, such as deleting data generated during the test so that the next test will run under the same conditions.

Enable Cleanup Steps

Cleanup Steps can be added to existing scenarios, however, they are hidden by default. To enable the feature, open the Options tab on the scenario details page and check Show Cleanup Steps.

Screen Shot 2023-08-27 at 21.30.58.png

When you go back to the Scenario tab, the Cleanup Steps section is added to the bottom of the screen.

Screen Shot 2023-08-27 at 21.31.16.png

Create Cleanup Steps

Cleanup Steps can be created in two ways:

Drag and drop existing steps to mark them as Cleanup Steps

If you already have steps in the scenario that can be used as Cleanup Steps, you can drag and drop them into the Cleanup Steps area.

Screen Shot 2023-09-15 at 11.05.25.png

Record new steps as Cleanup Steps

Alternatively, you can also record Cleanup Steps from scratch. Note that the recording starts from the URL specified in Step 1 of the scenario. If you would like to start recording from a different URL, add a Go To step to the beginning of the Cleanup Steps.

Screen Shot 2023-09-15 at 11.04.43.png

Run a scenario with Cleanup Steps

Scenarios with Cleanup Steps can run just as regular scenarios. However, how the steps will be run is different.

Scenario

In the following example where Step 1 - 3 are regular steps (with the setting When this step fails: Abort) and Step 4 - 5 are Cleanup steps:

  • If successful, the steps will be run in the order of 12345
  • If the scenario fails at Step 2, it will continue to run 1245

Screen Shot 2023-09-06 at 15.50.52.png

Results

The test result details page is divided into two parts: regular steps and Cleanup Steps. Here are some examples:

Successful test result

Screen Shot 2023-09-14 at 15.52.07.png

Failed test result with Cleanup Steps run

Even if regular steps failed in the middle, Cleanup Steps will run.

Screen Shot 2023-09-14 at 16.24.04.png

Failed test result with Cleanup Steps failure

It's also possible that Cleanup Steps may fail in the test. The test is considered to have failed, but the error message area is highlighted in yellow so that it's easy to make a distinction from a regular steps failure.

Screen Shot 2023-09-14 at 16.25.14.png

Tips

Add Go To steps at the beginning

Cleanup Steps can work without a starting URL specified. Make sure to add a Go To step at the beginning if you want to make sure that Cleanup Steps start from a specific URL.

Prepare an API endpoint to clear data

One of the best practices to clean up data created during tests is to prepare an API endpoint that clears your test data that can be called from a JS Step. Alternatively, you can simply record steps to delete or recover data by interacting with your application.

Note

Since this is an advanced feature provided for Advanced, Enterprise, or equivalent plans, Cleanup Steps will be hidden if you downgrade your contract plan to one where Cleanup Steps are not available.


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.