Each test runs in its own transaction and rollbacks at the end. You can tune that by adding @Rollback(false)
to your first test.
The problem now is that the transaction of insertDataTest
has completed so you should remove what it has created manually. To do that, the class you extends from has several utility methods such as deleteFromTables
or deleteFromTableWhere
.
This should go ideally in an @AfterClass
or something.
But that's not what I would do. I would factor out the data that are inserted by insertDataTest
in a shared utility. That way, you could call it again in your second test and remove the dependsOnMethods
. Having such dependency is not recommended as you can't run that test in isolation.