lundi 1 août 2016

Spring Boot test REST Controller - How to debug the TestRestTemplate exchange call?

I am writing a test for controller endpoint and when I execute I always get a null value. Is there any way when I call a test method to debug to check if my call is reaching endpoint or not?

e.g. My test

@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();


}

}

Above call always return null.

Please suggest a way to debug so that I can make sure I am reaching the endpoint in controller.

Aucun commentaire:

Enregistrer un commentaire