What is the best approach to manage Precondition for set of tests
Marcee last edited by
Lets say I have a set of tests which depends on a precondition.
Should I automate the precondition or manually perform the precondition data?
If I automate the precondition test and execute them before all dependent tests there is a problem that what if the precondition test itself failed due to some reason. So in that case all my dependent tests will fail.
Also even if precondition tests goes thorough and dependent tests passes, I still need to delete or reset my system, else I will have end of having lots of test data which is again a difficult task to manage.
What if my reset / delete test fails. How should I approach these challenges?
-- Update from comments --
Here is my test flow
- Create a Template.
- Link template to some Petition.
- Verify It is Linked.
If I create an independent test all 3 steps have to be included. But since I may have to run my test multiple times I will end up having lots of templates.
The other approach, to verify the linking part on a predefined template and unlink the petition to to avoid multiple creation but in this case what if unlinking fails? So next time when I come and try to link it will already be linked.
You should handle pre and post setup for tests using Automation only whenever possible.
You can create your code in such a way that if pre-condition script fails, none of the tests run.
And for post-setup you can go with two approaches:
- Verify and check whether it is actually worked using code or by querying into db, if it is not worked then create new template for next run.
- Have some database cleaning script clearing your test data which you can run automatically or manually after some iterations of your script execution.