So the reference documentation suggests @BeforeEach void setup( WebApplicationContext wac) { this.mockMvc = MockMvcBuilders.webAppContextSetup( wac ) .apply( …
Tag: spring-test-mvc
How to write a unit test for a Spring Boot Controller endpoint
I have a sample Spring Boot app with the following Boot main class Controller What’s the easiest way to write a unit test for the controller? I tried the following but it complains about failing to autowire WebApplicationContext Answer Spring MVC offers a standaloneSetup that supports testing relatively simple controllers, without the need of context. Build a MockMvc by registering