The code to perform integration testing on the TodoController class is shown in the following code snippet. It launches up the entire Spring context with all the controllers and beans defined:
@RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class TodoControllerIT { @LocalServerPort private int port; private TestRestTemplate template = new TestRestTemplate(); @Test public void retrieveTodos() throws Exception { String expected = "[" + "{id:1,user:Jack,desc:\"Learn Spring MVC\",done:false}" + "," + "{id:2,user:Jack,desc:\"Learn Struts\",done:false}" + "]"; String uri = "/users/Jack/todos"; ResponseEntity<String> response ...