How do I reset my database state after each unit test without making the whole test a transaction?

Since you are using Hibernate, you could use the property hibernate.hbm2ddl.auto to create the database on startup every time. You would also need to force the spring context to be reloaded after each test. You can do this with the @DirtiesContext annotation.

This might add a bit extra overhead to your tests, so the other solution is to just manually delete the data from each table.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)