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 SummaryConstructors
- 
Method SummaryModifier 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 List<TestExecutionListener>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.AbstractTestContextBootstrapperbuildMergedContextConfiguration, getBootstrapContext, getCacheAwareContextLoaderDelegate, getContextCustomizerFactories, getTestExecutionListeners, resolveExplicitContextLoaderClass, setBootstrapContext
- 
Constructor Details- 
SpringBootTestContextBootstrapperpublic SpringBootTestContextBootstrapper()
 
- 
- 
Method Details- 
buildTestContext- Specified by:
- buildTestContextin interface- TestContextBootstrapper
- Overrides:
- buildTestContextin class- AbstractTestContextBootstrapper
 
- 
getDefaultTestExecutionListeners- Overrides:
- getDefaultTestExecutionListenersin class- AbstractTestContextBootstrapper
 
- 
resolveContextLoaderprotected ContextLoader resolveContextLoader(Class<?> testClass, List<ContextConfigurationAttributes> configAttributesList) - Overrides:
- resolveContextLoaderin class- AbstractTestContextBootstrapper
 
- 
getDefaultContextLoaderClass- Overrides:
- getDefaultContextLoaderClassin class- DefaultTestContextBootstrapper
 
- 
processMergedContextConfigurationprotected MergedContextConfiguration processMergedContextConfiguration(MergedContextConfiguration mergedConfig) - Overrides:
- processMergedContextConfigurationin class- AbstractTestContextBootstrapper
 
- 
determineResourceBasePathDetermines 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
- 
getDifferentiatorPropertySourcePropertyReturn 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
 
- 
processPropertySourcePropertiesprotected void processPropertySourceProperties(MergedContextConfiguration mergedConfig, List<String> propertySourceProperties) Post process the property source properties, adding or removing elements as required.- Parameters:
- mergedConfig- the merged context configuration
- propertySourceProperties- the property source properties to process
 
- 
getWebEnvironmentReturn theSpringBootTest.WebEnvironmenttype for this test or null if undefined.- Parameters:
- testClass- the source test class
- Returns:
- the SpringBootTest.WebEnvironmentornull
 
- 
getClasses
- 
getProperties
- 
getAnnotation
- 
verifyConfiguration
- 
createModifiedConfigprotected final MergedContextConfiguration createModifiedConfig(MergedContextConfiguration mergedConfig, Class<?>[] classes) Create a newMergedContextConfigurationwith different classes.- Parameters:
- mergedConfig- the source config
- classes- the replacement classes
- Returns:
- a new MergedContextConfiguration
 
- 
createModifiedConfigprotected final MergedContextConfiguration createModifiedConfig(MergedContextConfiguration mergedConfig, Class<?>[] classes, String[] propertySourceProperties) Create a newMergedContextConfigurationwith different classes and properties.- Parameters:
- mergedConfig- the source config
- classes- the replacement classes
- propertySourceProperties- the replacement properties
- Returns:
- a new MergedContextConfiguration
 
 
-