Closed
Description
Stepan Koltsov opened SPR-8710 and commented
Status Quo
AFAIU currently test initialization and finalization code must be placed into a test class (not in the application context), so code cannot be easily reused between unrelated test classes.
Proposal
SpringJUnit4ClassRunner
could publish a TestStartedEvent
before each test method and a TestFinishedEvent
after each test in the application context. Listeners to these events could be used to clean caches from the previous test run, recreate database state before a test method, etc.
Issue Links:
- Publish test execution events to the test ApplicationContext [SPR-13916] #18490 Publish TestExecutionListener events to the ApplicationContext under test
- Introduce support for test-scoped beans in the TestContext framework [SPR-14034] #18606 Introduce support for test-scoped beans in the TestContext framework