Automated Acceptance tests under specific contraints
- by HH_
This is a follow up to my previous question, which was a bit general, so I'll be asking for a more precise situation.
I want to automate acceptance testing on a web application. Briefly, this application allows the user to create contracts for subscribers with the two constraints:
You cannot create more than one contract for a subscriber.
Once a contract is created, it cannot be deleted (from the UI)
Let's say TestCreate is a test case with tests for the normal creation of a contract.
The constraints have introduced complexities to the testing process, mainly dependencies between test cases and test executions.
Before we run TestCreate we need to make sure that the application is in a suitable state (the subscriber has no contract)
If we run TestCreate twice, the second run will fail since the state of the application will have changed.
So we need to revert back to the initial state (i.e. delete the contract), which is impossible to do from the UI.
More generally, after each test case we should guarantee that the state is reverted back. And since, in this case, it is impossible to do it from the UI, how do you handle this?
Possible solution: I thought about doing a backup of the database in the state that I desire, and after each test case, run a script which deletes the db and restores the backup. However, I find that to be too heavy to do for each single test case. In addition, what if some information are stored in files? or in multiple or unaccessible databases?
My question: In this situation, what would an experienced tester do to write automated and maintanable tests. Thank you.
More info: I'm trying to integrate tests into a BDD framework, which I find to be a neat solution for test documentation and communication, but it does not solve this particular problem (it even makes it harder)