I use the SpringJUnit4ClassRunner
for writing integration tests. I also use @DirtiesContext
for tests that leave the context in an broken state behind and that works just fine.
But now I have a test the sets an important SystemProperty in an static initializer, which in turn is used in the Spring context. This again works fine when the test executes on its own. But when I run the test with other tests the Spring context gets already created with out that property set and gets reused by my new Test.
How can I force the fresh creation of a Spring context in my test, which then will use the changed System Property?