MockMVC class is part of Spring MVC test framework which helps in testing the controllers explicitly starting a Servlet container. In this MockMVC tutorial, we will use it along with Spring boot’s WebMvcTest class to execute Junit testcases which tests REST controller methods written for Spring boot 2 hateoas example.
What is MockMvcBuilders standaloneSetup?
We set up the MockMvc . We add the MyController to the standalone setup. The MockMvcBuilders. standaloneSetup() allows to register one or more controllers without the need to use the full WebApplicationContext .
What is MockHttpServletRequestBuilder?
public class MockHttpServletRequestBuilder extends Object implements ConfigurableSmartRequestBuilder<MockHttpServletRequestBuilder>, Mergeable. Default builder for MockHttpServletRequest required as input to perform requests in MockMvc .