I'm writing an autotest(with java maven+junit+cucumber)
- Before the start of testcase I need to create a user for test and some entities in db(lets name them entity1 and entity2)
- During the testcase I create entity3 by clicking "create" button in UI(entity3 is connected to entity1 as many to one)
- After the end of testcase I need to clean up(which means to delete all the data that I created before the test and all the data created from ui during the test)
Now I try to make some delete queries to db after the end, but face some problems:
- Tables are connected between each other and by the end of the test I have a bunch of rows in the other tables that reference to my initial entity1 and entity2 and need to cascade delete them and that takes a lot of time, eventually it will lead to after method taking more time than test itself
- Tables are not specified on cascade delete and I cant change it since it is expected behavior
- it is dev environment that is used for manual tests also so I cant just delete all data, I need to delete only what is created by autotest
I know there is some hibernate thing but I have never used it and Im not sure if It can make what I need
Im looking for some options were I can save how db was before test then do test and then revert all what happend to db so it is same as it was before test