So far, we have tested our beans, but we need to test how our controller answers our HTTP requests. For example, what happens when we do an HTTP GET request from the /customers URL? To test this, we need a way to test each of our requests. Spring provides a class named MockMvc that simulates our server in a way that we can test our requests.
First, go to the CustomerController class. Select it in the Project window, and then select the class name in the editor. Press Shift + Ctrl + T and choose to Create New Test. This will be automatically named as CustomerControllerTest. We do not need to choose any options on Create Test window, just click on OK.
Now, we need to add our MockMvc object to the class:
package com.microservices.chapter09 ...