类 SpringBootTestContextBootstrapper
java.lang.Object
org.springframework.test.context.support.AbstractTestContextBootstrapper
org.springframework.test.context.support.DefaultTestContextBootstrapper
org.springframework.boot.test.context.SpringBootTestContextBootstrapper
- 所有已实现的接口:
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.
- 从以下版本开始:
- 1.4.0
- 作者:
- Phillip Webb, Andy Wilkinson, Brian Clozel, Madhura Bhave, Lorenzo Dee
- 另请参阅:
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明protected 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) 从类继承的方法 org.springframework.test.context.support.AbstractTestContextBootstrapper
buildMergedContextConfiguration, getBootstrapContext, getCacheAwareContextLoaderDelegate, getContextCustomizerFactories, getDefaultTestExecutionListeners, getTestExecutionListeners, resolveExplicitContextLoaderClass, setBootstrapContext
-
构造器详细资料
-
SpringBootTestContextBootstrapper
public SpringBootTestContextBootstrapper()
-
-
方法详细资料
-
buildTestContext
-
resolveContextLoader
protected ContextLoader resolveContextLoader(Class<?> testClass, List<ContextConfigurationAttributes> configAttributesList) -
getDefaultContextLoaderClass
-
processMergedContextConfiguration
protected MergedContextConfiguration processMergedContextConfiguration(MergedContextConfiguration mergedConfig) -
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.- 参数:
configuration- the configuration to examine- 返回:
- the resource base path
- 从以下版本开始:
- 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.- 返回:
- 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.- 参数:
mergedConfig- the merged context configurationpropertySourceProperties- the property source properties to process
-
getWebEnvironment
Return theSpringBootTest.WebEnvironmenttype for this test or null if undefined.- 参数:
testClass- the source test class- 返回:
- the
SpringBootTest.WebEnvironmentornull
-
getClasses
-
getProperties
-
getAnnotation
-
verifyConfiguration
-
createModifiedConfig
protected final MergedContextConfiguration createModifiedConfig(MergedContextConfiguration mergedConfig, Class<?>[] classes) Create a newMergedContextConfigurationwith different classes.- 参数:
mergedConfig- the source configclasses- the replacement classes- 返回:
- a new
MergedContextConfiguration
-
createModifiedConfig
protected final MergedContextConfiguration createModifiedConfig(MergedContextConfiguration mergedConfig, Class<?>[] classes, String[] propertySourceProperties) Create a newMergedContextConfigurationwith different classes and properties.- 参数:
mergedConfig- the source configclasses- the replacement classespropertySourceProperties- the replacement properties- 返回:
- a new
MergedContextConfiguration
-