🪴 Nishanth Gobi

Search

SearchSearch
Home

>

Zettelkasten

>

Literature Notes

>

Testing in SpringBoot

Testing in SpringBoot

May 15, 2024, 1 min read

  • #zettel
  • #lit
  • #draft

WebMvcTest §

@RunWith(SpringRunner.class)
@WebMvcTest(HelloController.class)
public class HelloControllerApplicationTest {
    @Autowired    
    private MockMvc mvc;
 
    @Test
    public void getHello() throws Exception {
        mvc.perform(
	        MockMvcRequestBuilders.get("/")
	    )
	    .andExpect(status().isOk())
        .andExpect(
	        content().string(equalTo("Hello!"))
		);
    }
}

Refs §

  1. https://stackoverflow.com/questions/39865596/difference-between-using-mockmvc-with-springboottest-and-using-webmvctest

Graph View

  • WebMvcTest
  • Refs

Created with Quartz v4.1.0, © 2024

  • GitHub
  • LinkedIn