# Adding Post Test Hook or Cleanup Steps

**Post-test hooks** are steps executed after a test case to ensure that the testing environment is restored to its original state. They help automate the manual cleanup process, and ensure that the device is in a clean state for the next test.

Here's how you can add a post test hook to your test in Sofy:

1. Open up a test case in offline mode from the **Automation** section: 
2. Click on the **Settings (gear icon)** and from the menu which shows up, click on **Add** option inside the **Post Test Hook** section:

3. From the modal which appears, select any of your existing templates and click on **Add Post-Test Hook** button: 
4. You can then click on **Save Options** to save the newly added post test hook to your test case: 
5. Once done, the post test hook will show up at the end of the test case with a **label** on top for easy identification: 
6. From now on, whenever you run your test, your post test hook will execute at the end of your test case, irrespective of if your test passed or failed and perform the cleanup steps for you.
7. To view the results of your test case which contains the post hook, you can simply view it from the **Runs & Results** section and Sofy will tell you if your test and post hook passed or failed:
