Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce BEFORE_METHOD and BEFORE_CLASS modes for @DirtiesContext [SPR-12429] #17035

Closed
spring-issuemaster opened this issue Nov 13, 2014 · 2 comments

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

commented Nov 13, 2014

Torsten Krah opened SPR-12429 and commented

Status Quo

@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.


Affects: 3.0 GA

Reference URL: http://stackoverflow.com/questions/26931236/is-it-possble-to-reset-spring-tests-context-cache-before-a-test-suite-runs-not

Issue Links:

  • #17772 BEFORE_* modes in @DirtiesContext cause context to be closed before test
@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 22, 2015

Sam Brannen commented

Completed as described in GitHub commit e086a63:

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

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Jul 1, 2015

Sam Brannen commented

FYI: a bug introduced in conjunction with this issue has been fixed in #17772.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.