Reputation: 6879
I have a transaction method that looks like this:
@Transactions
public processTransaction(MyAPi api);
In order to make sure that hibernate transactions are functioning okay, I would like to test if the DB rolls back in Junit.
How do we do it?
Upvotes: 0
Views: 361
Reputation: 5070
Have a look at DBUnit - it's designed to assist with this exact type of testing. You can define table states, build up in-memory or physical databases, then perform your tests and compare the table state afterwards. You can also use it to provide a known-state database before each test runs.
Upvotes: 1