【发布时间】:2019-10-21 16:09:18
【问题描述】:
Spring Boot 中是否有任何属性可用于配置 @Autowired WebTestClient?例如,如何在 WebTestClient 上设置 servlet 上下文路径(或者只是一些基本路径)?
这是我现在的网络测试配置方式:
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@ActiveProfiles("test")
public class MyTestClass{
@Autowired
private WebTestClient cl;
//the rest of it
}
换句话说,什么是 Spring Boot 等价物
WebTestClient client = WebTestClient.bindToServer()
.baseUrl("http://localhost:<random port>/myServletContext").build();
我没有在文档中找到任何有用的东西: https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html
【问题讨论】:
标签: spring spring-boot testing integration-testing