//to focus on mvc components only
class HelloControllerIntegrationTest{
  private MockMvc mvc;

  void hello() throws Exception{
    RequestBuilder request = MockMvcRequestBuilders.get("/find/by/id");
    MvcResults result = mvc.perform(request).andReturn();
    //first param is expected value, second- actual value
    assertEquals("Hello, World", results.getResponse().getContentAsString());

  public void testHelloWithName throws Exception{
      mvc.perform(get("/find/by/id?id=123")).andExpect(content().string("Hello, Dan"));


downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter