According to: http://ift.tt/1Ctg5Un SpringJUnit4ClassRunner won't always called DisposableBean.destroy after tests (*facepalm*!) -- due to implementation problems with JUnit.
Is this still true?
I'm creating tests in scala like so:
@RunWith(classOf[SpringJUnit4ClassRunner])
@WebAppConfiguration
@ContextConfiguration(classes = Array(classOf[Service1Config]))
class Service1Test {
@Test
def test1(): Unit = {
}
}
@RunWith(classOf[SpringJUnit4ClassRunner])
@WebAppConfiguration
@ContextConfiguration(classes = Array(classOf[Service2Config]))
class Service2Test {
@Test
def test2(): Unit = {
}
}
and I'm finding that the destroy method of beans in Service1Config aren't destroyed when Service2Test is executed.
I've found many articles recommending adding a @After to shut down the context explicitly. This sounds like a fuck up waiting to happen (since if you forget to add an @After cleanup in one test, the next test class will fail and you will have no idea why).
If this still can't be done with SpringJUnit4ClassRunner/JUnit, is there a test framework that will automatically call the context cleanup after each test?
Aucun commentaire:
Enregistrer un commentaire