I have the REST service that I need to testing. That service has a spring security authentication and I need to turn off it in my tests or mock. I decided to mock it because I couldn't turn off it. I write @TestConfiguration
for that but now my context not load:
@TestConfiguration
public class TestConfig {
}
@WebMvcTest(controller = MyController.class)
@ContextConfiguration(classes = TestConfig.class)
public MyControllerTest {
@Test
public void simpleTest() {
}
}
and in my main source, I have some config class that load some other beans and it class did not load in my test and I have an exception:
java.lang.IllegalStateException: Failed to load ApplicationContext
What I do wrong? Can anyone help me? I using SpringBoot 2.2.0
and in that version @WebMvcTest(secure = false)
not working because of secure
property doesn't exist anymore.