我有一些需要Spring上下文才能运行的测试:
@SpringBootTest
@ContextConfiguration(classes = Application.class)
@Transactional
@ActiveProfiles("test")
@Rollback
@RunWith(SpringRunner.class)
public class SomeTest() {
@Test
public void test() {
...
}
}
我已经为测试创建了自定义注解:
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@SpringBootTest
@ContextConfiguration(classes = Application.class)
@Transactional
@ActiveProfiles("test")
@Rollback
@RunWith(SpringRunner.class)
public @interface DBTest {
}
现在,当我在我的测试中使用@DBTest注释时:
@DBTest
public class SomeTest {
@Test
public void test() {
...
}
}
在这种情况下,Spring上下文没有启动。 我该如何启动它?