AbstractTransactionalJUnit4SpringContextTests MySQL data not getting rolled back?

Posted on Friday, June 18, 2010


We know that the unit tests should not be dependent on each other and hell there are not. But as soon as we switch our unit tests to use MySQL instead of HSQLDB which we use by default then it seems that hell breaks loose. The tests somehow become dependent on each other and start failing.

Wait, isn’t AbstractTransactionalJUnit4SpringContextTests supposed to help with the rollback?

All right after struggling with this for over 30 minutes and blaming it on the mysql driver, we finally realized that there are 2 dialects that you can have for MySQL since the database supports 2 kinds of db schemas. MyISAM the non transaction one and InnoDB the transactional one.

So we changed our dialect to use the transactional one and … the world was green!

This is how our properties file looks like now

#Properties file used for setting up application parameters
#to be run in an Development environment



Posted in: Database, hsqldb, Java, testing, Tip