I wrote two unit test classes using JUnit4. They both run fine separately, but running them one after another (by for example mvn test), the second test fails.
The reason the second test fails is because the first test modified a bean in the first test. The second test wants to use a fresh instance of this bean.
A unit test should give a new Context for each unit test class. Somehow Spring tries to optimise this. How can I configure Spring to restart a new Context for each unit test class?
My test classes are configured as such:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:a.context.xml")
public class AUnitTest {
@Test
public void someTestMethod{
doSomeFancyStuff();
}
}
Aucun commentaire:
Enregistrer un commentaire