Created
March 18, 2014 22:07
-
-
Save agoston/9630792 to your computer and use it in GitHub Desktop.
TestExecutionListener for Spring + JUnit tests, similar to @DirtiesContext, but reinitializes context _before_ test class is run. The upside is that you can influence context creating from the @BeforeClass this way.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.springframework.test.annotation.DirtiesContext; | |
import org.springframework.test.context.TestContext; | |
import org.springframework.test.context.support.AbstractTestExecutionListener; | |
public class ReinitContextTestExecutionListener extends AbstractTestExecutionListener { | |
@Override | |
public void beforeTestClass(final TestContext testContext) throws Exception { | |
testContext.markApplicationContextDirty(DirtiesContext.HierarchyMode.EXHAUSTIVE); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment