You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SpringContexts not properly closed after test-class is finished [SPR-11363] #15989
First testclass: derived from class AbstractTestNGSpringContextTests, uses annotation @EnableSpringConfigured
Second testclass: plain TestNG-Test without spring context, tries to instantiate a @Configurable-annotated-class
Maven runs the testcases in the order given above. When the second testclass is run and the @Configurable-annotated-class is constructed, a NoSuchBeanDefinitionEception is thrown.
I assume that the spring-context of the first testclass is not automatically destroyed.
Further investigation showed:
adding @DiritiesContext to the first testclass resolves the problem.
running AnnotationBeanConfigurerAspect.aspectOf().destroy() before the second test-class is executed resolves the problem.
This issue duplicates #10789, with regard to support for @Configurable across test classes within a test suite.
Regarding not properly closing a context after a test class has finished, this is in fact by design and one of the key features of the Spring TestContext Framework (TCF). Namely, the TCF caches contexts across all test methods and test classes within a test suite unless a test method or test class is explicitly configured with @DirtiesContext. For details on caching support in the TCF, please refer to the Context caching section of the reference manual.
Activity
spring-projects-issues commentedon Jan 31, 2014
Sam Brannen commented
This issue duplicates #10789, with regard to support for
@Configurableacross test classes within a test suite.Regarding not properly closing a context after a test class has finished, this is in fact by design and one of the key features of the Spring TestContext Framework (TCF). Namely, the TCF caches contexts across all test methods and test classes within a test suite unless a test method or test class is explicitly configured with
@DirtiesContext. For details on caching support in the TCF, please refer to the Context caching section of the reference manual.