I am looking for a way to simplify the following code.
@WebAppConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {
// My configuration classes
})
public class MyServiceTest {
@Autowired
private MyService service;
@Test
public void myTest() {
Assert.assertTrue(service != null);
}
}
I have many configuration classes and I don't want to put them into each test class. So I got the idea to create my own annotation:
@WebAppConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {
// My configuration classes
})
public @interface IntegrationTests {
}
I try to use it in the following way:
@IntegrationTests
public class MyServiceTest {
@Autowired
private MyService service;
@Test
public void myTest() {
Assert.assertTrue(service != null);
}
}
But it doesn't work. Any idea?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…