mercredi 13 avril 2016

What to check when testing controllers in Spring

I am testing controllers in simple Sprinng application using MockMvc. It is first time I am trying to do testing. Based on resources I found, I am successfully running my tests, but I am not sure about what to check on responses. My controllers only return name of views to be rendered: index page (contains menu bar and welcome text), product page (contains menu bar and empty table of products) and about page (again menu bar and some info about author). Tests looks like this:

    mockMvc.perform(get("/myviews"))
    .andExpect(status().isOk())
    .andExpect(view().name("myviewsnames"))
    .andExpect(forwardedUrl("/WEB-INF/jsp/myviewsjsps.jsp"));

But based on MockMvcResultMatchers documentation http://ift.tt/23GQIZy I see a lot of other options for matching. What else, and why, should I check in my tests? Thank you.

Aucun commentaire:

Enregistrer un commentaire