I would like to check if my understanding is correct and also would like some help in how to handle a particular scenario with test case executions.
I have been writing test cases for all the Apex classes, triggers, etc. I have custom data objects and of course CRUD operations on these classes. I know about the annotation
@seeAllData=true. Some people suggested removing this to test the insert/update/delete operations as this affects the data in the Org.
However, I would like to run these operations with the above annotation so that I can also test all the exception handling and other cases(update if the record is already present, etc.). If I don't use the annotation, all these erroneous scenarios are avoided. I have added them too and it works quite well. But how can I make a full set of CRUD operations transactional? For e.g. I am worried what if my test cases are running and there is an error after an insert and a delete operation fails in my test cases. This loads the org with unwanted data. Can it be handled in some way?
Thanks for any help.