I'm using dbsetup for my db tests. The problem is I can't manage to get data rolled back after each test using the aproach which have always worked which is annotating the test case (or method) with @Transactional annotation. I suppose this happens because dbsetup uses the DataSource itself so Spring can't get track of what's being done to the database. How to make this work?
Asked
Active
Viewed 211 times
1 Answers
1
DbSetup is not tight to Spring in any way. It gets a JDBC connection from a DataSource and commits it when it's done.
The recommended way of using DbSetup is to clear and populate the tables before each test. Using a DbSetupTracker allows avoiding useless repopulations in case a test uses the same data as a previous test, and this previous test hasn't altered the data. This is described in the user guide.

JB Nizet
- 678,734
- 91
- 1,224
- 1,255