Our development struggled for some time as the application was getting bigger and bigger, the performance of unit testing got really bad becoming at some point (especially after migrating to latest Hibernate 3.6) unusable (aka stop of quality development) 😦
We investigated the environment (jdk, hw specs, ram), the frameworks being used (Hibernate, Spring), even the underlying DB (I am actually here talking of integration tests)… but the answer was to be found in the Maven settings.
The Maven Surefire Plugin instantiates a new JVM for running the test classes, but it appears that the JVM settings of Maven (typically what you set in the bin/mvn.bat) are not propagated to the newly created JVM, hence running the tests with some (inadequate) default values…
Check this out to see how the JVM memory settings can be configured. It did the trick 🙂