1
我正在为控制器端点写一个测试,当我执行时,我总是得到一个空值。当我调用测试方法进行调试以检查我的呼叫是否到达终端时,有什么方法吗?Spring Boot测试REST控制器 - 如何调试TestRestTemplate交换调用?
例如 我的测试
@ActiveProfiles("local")
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = { Application.class })
@WebIntegrationTest("server.port:0")
@Slf4j
public class XYZControllerTest{
.
.
.
@Test
public void testEndpointXYZ(){
...
Message createdMessage = testRestTemplate.exchange(postRequest, Message.class).getBody();
}
}
上面的调用总是返回null。
请建议一种调试方式,以便我可以确保我到达控制器中的端点。