Unit testing

A standalone setup of MockMvc Framework creates the bare minimum infrastructure required by DispatcherServlet. If provided with a view resolver, it can execute view resolution. However, it would not execute the view. So, during a unit test with the standalone setup, we cannot verify the content of the view. However, we can check whether the correct view is being delivered.

In this unit test, we want to set up BasicViewController, execute a get request to /welcome-view, and check whether the view name returned is welcome. In a future section, we will discuss how to execute the integration test, including the rendering of view. As far as this test is concerned, we restrict our purview to verifying the view name.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset