Skip to content

Instantly share code, notes, and snippets.

@NajeebArif
Created June 10, 2021 21:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NajeebArif/4343f7a4afec4d8f49fbecd8c762cd97 to your computer and use it in GitHub Desktop.
Save NajeebArif/4343f7a4afec4d8f49fbecd8c762cd97 to your computer and use it in GitHub Desktop.
@WebMvcTest(IndexController.class)
@AutoConfigureMockMvc
class IndexControllerTest {
@Autowired
private MockMvc mockMvc;
@Test
@DisplayName("check if index page is rendered.")
public void testIndexPage() throws Exception {
mockMvc.perform(MockMvcRequestBuilders.get("/"))
.andExpect(MockMvcResultMatchers.status().is2xxSuccessful())
.andExpect(MockMvcResultMatchers.view().name("index"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment