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

Reload the application context for each test in a class with a class level annotation [SPR-5640] #10311

Closed
spring-projects-issues opened this issue Mar 31, 2009 · 2 comments
Assignees
Labels
in: test Issues in the test module type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Mar 31, 2009

Peter Lappo opened SPR-5640 and commented

Tests can often alter the context state, this can cause subsequent tests to fail. A class level annotion similar to @DirtiesContext would allow class level control of reloading contexts. Changing the default at the application level to reload would be possible but somewhat heavy handed and contrary to the current approach of reusing the context. A class level annotation called @DirtiesClassContext to force a context reload for each test in the class is proposed. The attached zip file In the forum contains an implemention @DirtiesClassContext that has proven to work. For convenience the classes in the implementation are packaged in the same way as spring-test.


Affects: 2.5.6

Reference URL: http://forum.springsource.org/showthread.php?p=234264#post234264

Attachments:

Issue Links:

Referenced from: commits c254f38, e31d947, eef6fd3

@spring-projects-issues
Copy link
Collaborator Author

Peter Lappo commented

Proposed implementation.

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Jul 6, 2009

Sam Brannen commented

Support for using @DirtiesContext at the class-level was added in #9379.

Class-level usage of @DirtiesContext has now been extended with support for class modes which can specified via the new classMode attribute of the DirtiesContext annotation. Supported modes include:

  • AFTER_CLASS
  • AFTER_EACH_TEST_METHOD

I invite you to try out this new feature in an upcoming nightly snapshot or Spring 3.0.0.RC1 and let us know if it meets your needs.

Regards,

Sam

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test Issues in the test module type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants