Why do my tests throw random exceptions when I use the surefire setting parallel=methods ?
That's because JUnit creates just one Runner instance per test class, which is used by multiple threads when using parallel=methods. SpringJUnit4ClassRunner creates just one TestContextManager, which stores the test instance in an instance field, so it isn't thread safe.
When you use parallel=classes everything should be fine, because then JUnit creates one runner with a dedicated TestContextManager per thread.
I have filed a bug about that: https://jira.spring.io/browse/SPR-12421
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With