0

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

  1. Create a Template.
  2. Link template to some Petition.
  3. 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.

  • 1
    Can you be more specific regarding your environment and possibilities for setting up these preconditions? Your concerns are valid, but they happen even on the simplest unit tests - meaning that they are inherently natural for automation in testing. With more details, the contributors can give more specif robust solutions. – João Farias May 16 at 5:11
  • 1
    SRM21's answer seems reasonable – João Farias May 16 at 7:17
  • Thank You @JoãoFarias – SRM21 May 16 at 8:35
  • @JoãoFarias please find a scenario below . – Automation Keeda Oct 9 at 7:51
  • @JoãoFarias please find a scenario below .i have a bunch of tests for a feature called notes . Which tests i)creation of notes ii) editing a note iii)locking a note . deleting a note . Question -- should i create all the tests independently as automation guidelines says to create independent tests . If yes every tests of mine would be long where it will create a note . What if the in one of the tests creation fails so my actual test would fail as the precondition of creation of note failed . Or should i put dependency for each of the tests which would create a note as precondition . – Automation Keeda Oct 9 at 7:57
1

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:

  1. 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.
  2. Have some database cleaning script clearing your test data which you can run automatically or manually after some iterations of your script execution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.