【发布时间】:2019-11-09 01:51:22
【问题描述】:
我正在使用WebTestClient 对控制器进行一些集成测试。如果我在控制器内设置断点,我会达到WebTestClient 的 5 秒标准超时。对此的解决方案是将@AutoConfigureWebTestClient(timeout = "600000") 添加到我的测试中,如她所说的Timeout on blocking read for 5000 MILLISECONDS in Spring WEBFLUX。
对我来说@AutoConfigureWebTestClient(timeout = "600000") 不会改变任何东西。 5秒后我仍然得到超时异常。
有什么想法吗?
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
@ActiveProfiles("test")
@Transactional
@Import(EntityFactoryConfiguration.class)
@AutoConfigureWebTestClient(timeout = "600000") // giv me 10 min for debugging
public class LogControllerIntegrationTest {
...
@Autowired
private WebTestClient webTestClient;
...
@Test
public void myTest() {
...
webTestClient.post().uri("/log")
.contentType(MediaType.APPLICATION_JSON_UTF8)
.accept(MediaType.APPLICATION_JSON_UTF8)
.body(BodyInserters.fromObject(protocolLine))
.exchange()
.expectStatus().isOk();
}
【问题讨论】:
-
我认为这个答案帮助你解决了问题,你能接受它来结束这个问题吗?谢谢!
标签: java spring-boot junit spring-boot-test