Use SpringBootContextLoader for tests annotated with @WebMvcTest
Previously, tests annotated with @WebMvcTest would use Spring Framework’s WebDelegatingSmartContextLoader. This meant that SpringApplication was not used to create the application context. One effect of this was that Spring Boot’s logging system was not initialized and large quantities of debug log output was produced due to Logback’s default behaviour. This commit updates WebMvcTestContextBootstrapper so that it uses SpringBootContextLoader. This aligns the behaviour of @WebMvcTest with the behaviour of @SpringBootTest and @DataJpaTest. Closes gh-5847
This commit is contained in:
@@ -17,10 +17,8 @@
|
||||
package org.springframework.boot.test.autoconfigure.web.servlet;
|
||||
|
||||
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper;
|
||||
import org.springframework.test.context.ContextLoader;
|
||||
import org.springframework.test.context.MergedContextConfiguration;
|
||||
import org.springframework.test.context.TestContextBootstrapper;
|
||||
import org.springframework.test.context.web.WebDelegatingSmartContextLoader;
|
||||
import org.springframework.test.context.web.WebMergedContextConfiguration;
|
||||
|
||||
/**
|
||||
@@ -30,12 +28,6 @@ import org.springframework.test.context.web.WebMergedContextConfiguration;
|
||||
*/
|
||||
class WebMvcTestContextBootstrapper extends SpringBootTestContextBootstrapper {
|
||||
|
||||
@Override
|
||||
protected Class<? extends ContextLoader> getDefaultContextLoaderClass(
|
||||
Class<?> testClass) {
|
||||
return WebDelegatingSmartContextLoader.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MergedContextConfiguration processMergedContextConfiguration(
|
||||
MergedContextConfiguration mergedConfig) {
|
||||
|
||||
Reference in New Issue
Block a user