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.

Get Mastering Spring 5.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.