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
Introduce BEFORE_METHOD and BEFORE_CLASS modes for @DirtiesContext [SPR-12429] #17035
@DirtiesContext currently only supports closing a test ApplicationContext after an entire test class or after a test method.
Proposal
It would be useful to have before class and before method modes, too.
Currently this is achievable with a custom TestExecutionListener which marks the context as dirty at the requested phase (before class or before method), but this could be easily achieved via new modes within the @DirtiesContext annotation.
Introduce BEFORE METHOD/CLASS modes in @DirtiesContext
Prior to this commit, @DirtiesContext could only be used to close a
test ApplicationContext after an entire test class or after a test
method; however, there are some use cases for which it would be
beneficial to close a test ApplicationContext before a given test class
or test method -- for example, if some rogue (i.e., yet to be
determined) test within a large test suite has corrupted the original
configuration for the ApplicationContext.
This commit provides a solution to such testing challenges by
introducing the following modes for @DirtiesContext.
MethodMode.BEFORE_METHOD: configured via the new methodMode attribute
ClassMode.BEFORE_CLASS and ClassMode.BEFORE_EACH_TEST_METHOD: both
configured via the existing classMode attribute
Activity
spring-projects-issues commentedon Mar 22, 2015
Sam Brannen commented
Completed as described in GitHub commit e086a63:
spring-projects-issues commentedon Jul 1, 2015
Sam Brannen commented
FYI: a bug introduced in conjunction with this issue has been fixed in #17772.