mercredi 3 août 2016

In Spring tests with MockMVC, how to test for multiple chained redirects?

I have a web application which requires login. Once login, the user navigation flow is like this: there will be several webpages, each representing one step of a process. The user may already finished some steps, the page will be redirected several times continuously, to the first non-completed step's webpage.

I am testing this web application using Spring test framework 4.12, using MockMVC.

Question: how to test several changed page redirects? I want something like this:

mockMvc
               .perform(post("/login").session(session).param("username", "Jack").param("password","Jack'sPassword"))
               .andExpect(redirectedUrl("/firstRedirectPage"))
               .andExpect(redirectedUrl("/secondRedirectPage"))
               .andExpect(redirectedUrl("/thirdRedirectPage"))

Aucun commentaire:

Enregistrer un commentaire