We're using Maven/Surefire and Spring/Hibernate transactional tests for a fairly large web application. There are 138 Test* classes, running a total of 1178 tests.
A straightforward "mvn test" will generate 82 errors, the nature of which tend to imply a corrupt application context:
Many of these:
IllegalTransactionStateException: Pre-bound JDBC Connection found!
A few of these:
NoSuchMethodError: org.hibernate.cache.CacheException.(Ljava/lang/Exception;)V
For every failed test, running the test class individually "mvn test -Dtest=TestFailingClass" succeeds. Indeed, using -Dtest=TestClass1,TestClass2,Etc." with various subsets of all my test classes succeeds or fails in different ways. For instance, running only the failing test classes succeeds with 0 errors.
With no apparent means to control the order of classes tested by Surefire, I have a difficult time determining which of my test classes seem to be leaving the context in a bad state.
What I'm looking for is a strategy to help determine what is happening in some kind of deterministic manner. I can certainly see the order of tests run from the log, but I cannot reproduce that order controllably.
And of course, suggestions for what to do about it ...