I have Integration test for controller method in spring mvc by SpringJUnit4ClassRunner:
@Test
public void testUpdateSuccess() throws Exception {
Integer pageId = 2;
RequestBuilder request = post("/admin/page/update/"+pageId)
.param("id", pageId.toString())
.param("title", "page title 2 edited")
.param("content", "page content 2 edited")
.with(csrf());
mockMvc.perform(request)
.andExpect(status().is3xxRedirection())
.andExpect(MockMvcResultMatchers.flash().attribute("message", "Successfully updated!"));
}
1- How can I test if above test updated related database row?
2- Is it good to test if database updated Appropriately?
Aucun commentaire:
Enregistrer un commentaire