Maven Spring tests fail when run together, but succeed individually (ehcache closed, IllegalTransactionStateException)

Indeed the problem comes from a corrupt Spring application context. One of the early tests is dirtying the context and causing the following tests to error out.

One difficulty is trying to control the order of the tests while discovering the test causing the trouble.

I was able to accomplish that by using Maven's log to find the order of the test classes run, then excluding tests one at a time from the top. Thirty-four tests in, I found the culprit.

It was a test called TestSpringContexts. Adding @DirtiesContext to these tests solve the problem, but it was also solved by removing calls to context.close() from the tests.

I wrote a blog post about the process here, but that's the gist of the matter: http://mojo.whiteoaks.com/2010/04/27/finding-the-test-that-corrupts-the-suite/

Mojo