Gary Russell opened SPR-11576 and commented
Currently, when using @ContextConfiguration and SpringJunit4ClassRunner, the context is only close() d (AFTER CLASS) if the class is annotated with @DirtiesContext.
I don't know if this is a change in behavior or has always been this way, but it seems non-intuitive to me, given that the context is no longer available for use.
With "active" contexts (such as Spring Integration) this can cause issues when many tests are run, for example in a gradle build. Aside from the memory/cpu, it can cause unfortunate side effects (such as MBean name collisions, test cross-talk when using the same JMS queue name, etc).
We have started to mark our tests with class-level DirtiesContext but I wonder if this behavior is intentional.
If this would be considered too big a change, perhaps we could consider a system property, e.g. spring.always.close.test.context.after.class ?
Affects: 3.0 GA
Issue Links:
Gary Russell opened SPR-11576 and commented
Currently, when using
@ContextConfigurationandSpringJunit4ClassRunner, the context is onlyclose()d (AFTER CLASS) if the class is annotated with@DirtiesContext.I don't know if this is a change in behavior or has always been this way, but it seems non-intuitive to me, given that the context is no longer available for use.
With "active" contexts (such as Spring Integration) this can cause issues when many tests are run, for example in a gradle build. Aside from the memory/cpu, it can cause unfortunate side effects (such as MBean name collisions, test cross-talk when using the same JMS queue name, etc).
We have started to mark our tests with class-level
DirtiesContextbut I wonder if this behavior is intentional.If this would be considered too big a change, perhaps we could consider a system property, e.g.
spring.always.close.test.context.after.class?Affects: 3.0 GA
Issue Links: