Class SpringBootTestContextBootstrapper
java.lang.Object
org.springframework.test.context.support.AbstractTestContextBootstrapper
org.springframework.test.context.support.DefaultTestContextBootstrapper
org.springframework.boot.test.context.SpringBootTestContextBootstrapper
- All Implemented Interfaces:
 TestContextBootstrapper
TestContextBootstrapper for Spring Boot. Provides support for
 @SpringBootTest and may also be used directly or subclassed.
 Provides the following features over and above DefaultTestContextBootstrapper:
 - Uses 
SpringBootContextLoaderas thedefault context loader. - Automatically searches for a
 
@SpringBootConfigurationwhen required. - Allows custom 
EnvironmentgetProperties(Class)to be defined. - Provides support for different 
webEnvironmentmodes. 
- Since:
 - 1.4.0
 - Author:
 - Phillip Webb, Andy Wilkinson, Brian Clozel, Madhura Bhave, Lorenzo Dee
 - See Also:
 
- 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionprotected final MergedContextConfigurationcreateModifiedConfig(MergedContextConfiguration mergedConfig, Class<?>[] classes) Create a newMergedContextConfigurationwith different classes.protected final MergedContextConfigurationcreateModifiedConfig(MergedContextConfiguration mergedConfig, Class<?>[] classes, String[] propertySourceProperties) Create a newMergedContextConfigurationwith different classes and properties.protected StringdetermineResourceBasePath(MergedContextConfiguration configuration) Determines the resource base path for web applications using the value of@WebAppConfiguration, if any, on the test class of the givenconfiguration.protected SpringBootTestgetAnnotation(Class<?> testClass) protected Class<?>[]getClasses(Class<?> testClass) protected Class<? extends ContextLoader>getDefaultContextLoaderClass(Class<?> testClass) protected StringReturn a "differentiator" property to ensure that there is something to differentiate regular tests and bootstrapped tests.protected Class<?>[]getOrFindConfigurationClasses(MergedContextConfiguration mergedConfig) protected String[]getProperties(Class<?> testClass) protected SpringBootTest.WebEnvironmentgetWebEnvironment(Class<?> testClass) Return theSpringBootTest.WebEnvironmenttype for this test or null if undefined.protected MergedContextConfigurationprocessMergedContextConfiguration(MergedContextConfiguration mergedConfig) protected voidprocessPropertySourceProperties(MergedContextConfiguration mergedConfig, List<String> propertySourceProperties) Post process the property source properties, adding or removing elements as required.protected ContextLoaderresolveContextLoader(Class<?> testClass, List<ContextConfigurationAttributes> configAttributesList) protected voidverifyConfiguration(Class<?> testClass) Methods inherited from class org.springframework.test.context.support.AbstractTestContextBootstrapper
buildMergedContextConfiguration, getBootstrapContext, getCacheAwareContextLoaderDelegate, getContextCustomizerFactories, getDefaultTestExecutionListeners, getTestExecutionListeners, resolveExplicitContextLoaderClass, setBootstrapContext 
- 
Constructor Details
- 
SpringBootTestContextBootstrapper
public SpringBootTestContextBootstrapper() 
 - 
 - 
Method Details
- 
buildTestContext
- Specified by:
 buildTestContextin interfaceTestContextBootstrapper- Overrides:
 buildTestContextin classAbstractTestContextBootstrapper
 - 
resolveContextLoader
protected ContextLoader resolveContextLoader(Class<?> testClass, List<ContextConfigurationAttributes> configAttributesList) - Overrides:
 resolveContextLoaderin classAbstractTestContextBootstrapper
 - 
getDefaultContextLoaderClass
- Overrides:
 getDefaultContextLoaderClassin classDefaultTestContextBootstrapper
 - 
processMergedContextConfiguration
protected MergedContextConfiguration processMergedContextConfiguration(MergedContextConfiguration mergedConfig) - Overrides:
 processMergedContextConfigurationin classAbstractTestContextBootstrapper
 - 
determineResourceBasePath
Determines the resource base path for web applications using the value of@WebAppConfiguration, if any, on the test class of the givenconfiguration. Defaults tosrc/main/webappin its absence.- Parameters:
 configuration- the configuration to examine- Returns:
 - the resource base path
 - Since:
 - 2.1.6
 
 - 
getOrFindConfigurationClasses
 - 
getDifferentiatorPropertySourceProperty
Return a "differentiator" property to ensure that there is something to differentiate regular tests and bootstrapped tests. Without this property a cached context could be returned that wasn't created by this bootstrapper. By default uses the bootstrapper class as a property.- Returns:
 - the differentiator or 
null 
 - 
processPropertySourceProperties
protected void processPropertySourceProperties(MergedContextConfiguration mergedConfig, List<String> propertySourceProperties) Post process the property source properties, adding or removing elements as required.- Parameters:
 mergedConfig- the merged context configurationpropertySourceProperties- the property source properties to process
 - 
getWebEnvironment
Return theSpringBootTest.WebEnvironmenttype for this test or null if undefined.- Parameters:
 testClass- the source test class- Returns:
 - the 
SpringBootTest.WebEnvironmentornull 
 - 
getClasses
 - 
getProperties
 - 
getAnnotation
 - 
verifyConfiguration
 - 
createModifiedConfig
protected final MergedContextConfiguration createModifiedConfig(MergedContextConfiguration mergedConfig, Class<?>[] classes) Create a newMergedContextConfigurationwith different classes.- Parameters:
 mergedConfig- the source configclasses- the replacement classes- Returns:
 - a new 
MergedContextConfiguration 
 - 
createModifiedConfig
protected final MergedContextConfiguration createModifiedConfig(MergedContextConfiguration mergedConfig, Class<?>[] classes, String[] propertySourceProperties) Create a newMergedContextConfigurationwith different classes and properties.- Parameters:
 mergedConfig- the source configclasses- the replacement classespropertySourceProperties- the replacement properties- Returns:
 - a new 
MergedContextConfiguration 
 
 -