Closed
Description
Noel Flicken opened SPR-4702 and commented
Expected behavior:
Context should be close()'d after end of test class execution
Observed behavior:
Context only closed when @DirtiesContext
annotates method
Multiple test classes can re-use the same context, which allows for faster test execution, so automatically closing a context after test class execution is probably not the best mechanism.
However, there should be a way to annotate that a context should be close()'d after all tests in a test class are executed.
Suggested fix:
- allow
@DirtiesContext
to annotate class - add TestExecutionListener#destroyTestInstance
Willing to implementing, if given approval of design.
Issue Links:
- ApplicationContext not closed when using @ContextConfiguration to implement integration tests [SPR-5395] #10068 ApplicationContext not closed when using
@ContextConfiguration
to implement integration tests ("is duplicated by") - Add a setDirty method to AbstractTestNGSpringContextTests [SPR-5305] #9978 Add a setDirty method to AbstractTestNGSpringContextTests
- Reload the application context for each test in a class with a class level annotation [SPR-5640] #10311 Reload the application context for each test in a class with a class level annotation
- ANT does not call destroy-method after tests [SPR-2007] #6700 ANT does not call destroy-method after tests
- ApplicationContext not closed when using @ContextConfiguration to implement integration tests [SPR-5395] #10068 ApplicationContext not closed when using
@ContextConfiguration
to implement integration tests
Referenced from: commits 2dee54b, e77e070, 7782184, 0483cb5, 8dec6af, 1f087b4, 51b8b99, f26e2e3
4 votes, 6 watchers