How it works...

This recipe is about building a unit test for a controller through the use of the Spring TestContext framework. The use of @MockitoJUnitRunner is to load the controller to the SpringContext container for testing. This Mockito injection only loads the controller to the Test framework including its validators, view resolvers, and message handlers. After this procedure, MockMvcBuilders offers some utility methods that will instantiate the controller and mock its request handlers.

This type of testing focuses more on the properties of each controller, making the tests more refined and focused on the behavior of each component. This is also an effective and convenient way of determining what causes some bugs during its actual execution.

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

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