【发布时间】:2019-08-23 17:45:38
【问题描述】:
我正在尝试为我的其余应用程序之一编写集成测试用例,该应用程序在内部使用 mongodb 来持久化数据
@DataMongoTest
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
public class MainControllerTest {
@LocalServerPort
private int port = 8080;
/* some test cases*/
}
但我遇到了错误
java.lang.IllegalStateException: Configuration error: found multiple declarations of @BootstrapWith for test class [com.sample.core.controller.MainControllerTest]: [@org.springframework.test.context.BootstrapWith(value=class org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTestContextBootstrapper), @org.springframework.test.context.BootstrapWith(value=class org.springframework.boot.test.context.SpringBootTestContextBootstrapper)]
看起来这两者是互斥的,那么如何进行集成测试。
【问题讨论】:
-
看到这个问题,评论和回答:stackoverflow.com/questions/45860899/…
标签: junit integration-testing spring-boot-test