I have several test that running on the same machine, in the beginning of each test I backup up the environment and in the end I restore the real environment.
Some times I have test that stuck in the middle, how do you think I have to handle a case like that
(The real environment didn't restore) ?
Are the tests reliant on each other ? i.e. Test one creates something that is then used in Test 2 ?
I would advise that you always create tests that are stand alone so if test 1 fails, you can still run test 2 - 10.
Also I know that Mercury in their courses advise that you create tests on an environment, run them, restore the environment and run them again.
However I would attempt to create functions / tests that will run on your application again and again and are not too reliant on the state of the environment. How much quicker is it to run test 1, it fails, you get a fix and you can run test 1 again without any backups etc.
That's generally good advive TQASheffield [nice city, but the way. I was once arrested there as a student for selling Bangor Univ Rag Magazines
without a licence!]
However, it's not always feasible. For example, a script that receives against a Purchase Order. (To over-simplify) you can't receive unless the PO exists, and you can't receive twice against the same PO. The only alternatives are the two things you recommend against: restore the environment, or make the script dependent upon one that creates a new PO. (Well, I guess there's a third alternative -- enter a PO manually first, but that'd be a bit dumb if a script would do the same thing for you)