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
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.
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.
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:
@ContextConfiguration
to implement integration tests@DirtiesContext
at the test class levelReferenced from: commits c254f38, e31d947, eef6fd3
The text was updated successfully, but these errors were encountered: