Flow 2 – simple controller flow with a View

Now, let's shift our attention to unit testing flow 2, which uses a view—JSP. Here is a screenshot of how this would appear on screen when the URL is hit:

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.

A standalone setup of the 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 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