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:
- Open up a test case in offline mode from the Automation section:
- Click on the Settings (gear icon) and from the menu which shows up, click on Add option inside the Post Test Hook section:
- From the modal which appears, select any of your existing templates and click on Add Post-Test Hook button:
- You can then click on Save Options to save the newly added post test hook to your test case:
- Once done, the post test hook will show up at the end of the test case with a label on top for easy identification:
- 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.
- 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: