mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
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:
parent
e58bef5f2b
commit
79b81a95c8
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user