I have a set of integration tests with SpringJUnit4ClassRunner . I am trying to run them in parallel using maven surefire. However, I noticed that the code is blocked before entering the synchronized block in CacheAwareContextLoaderDelegate.loadContext() .
Is there any way around this cache? I tried to do this, but it looks like there is a more general state than just the cache itself, since my application has stalled inside Spring code. Or can the synchronization be finer-grained, somehow synchronizing on the card key, and not on the entire card?
The motivation for parallel tests is twofold:
- In some tests, I replace beans with mocks. Since mocks is stateful at its core, I have to create a new ApplicationContext for each test method using
@DirtiesContext . - In other tests, I want to deploy a subset of Jersey resources. To do this, I define a subset of the Spring configuration classes. Because Spring uses
MergedContextConfiguration as the key in the context cache, these tests will not be able to share ApplicationContexts.
hertzsprung
source share