I\'m fairly new to Spring, trying to do some basic integration tests for a @Controller
.
@RunWith(SpringRunner.class)
@WebMvcTest(DemoController.clas
If anyone uses Spring boot and don't want to remove @EntityScan
and @EnableJpaRepositories
you can remove @WebMvcTest
annotation from your test class and add the following instead:
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@AutoConfigureMockMvc
public class DemoControllerIntegrationTests {
@Autowired
private MockMvc mvc;
//...
}
and you will be able to autowire MockMvc
and use it.