Speed up Integration Test Suite
I'm trying to speed up running my integration test suite. For every integration test class I have, it recreates the whole in-memory H2 database from scratch before running the tests - which takes up the most time. All methods I'm testing are within a Spring/Hibernate stack.
Is there a way to avoid recreating the db for each test while ensuring the db is in a clean state?
Some methods I'm testing call methods that start new Hibernate transactions - so not sure if it's possible to begin a new transaction before each test and roll everything back after.
That is the default behavior (rollback) when using @Transactional with @RunWith(SpringJunit4TestRunner.class).
See the Integration Testing Chapter for complete information.