I use Flyway to control the state of my database in my Spring MVC application.
I configured it in the servlet context XML file exactly as I recommend in my docs
<bean id="flyway" class="org.flywaydb.core.Flyway" init-method="migrate">
<property name="dataSource" ref="..."/>
...
</bean>
<bean id="sessionFactory" class="..." depends-on="flyway">
...
</bean>
I would like to do two things in JUnit tests -
Once before ALL tests, drop and recreate the database and let it re-migrate. This creates a clean database for each test suite.
Before each test, clear all database tables. In other frameworks (e.g. RSpec / Rails), I accomplished this by executing database transactions transactionally so that they roll back at the end of the test. Not sure what is the best in the Spring MVC world.
I have no clue where to really start by implementing the above, so any guidance is appreciated.
!