类 SpringBootTestContextBootstrapper
- java.lang.Object
 - org.springframework.test.context.support.AbstractTestContextBootstrapper
 - org.springframework.test.context.support.DefaultTestContextBootstrapper
 - org.springframework.boot.test.context.SpringBootTestContextBootstrapper
 
- 所有已实现的接口:
 org.springframework.test.context.TestContextBootstrapper
public class SpringBootTestContextBootstrapper extends org.springframework.test.context.support.DefaultTestContextBootstrapper
TestContextBootstrapperfor Spring Boot. Provides support for@SpringBootTestand may also be used directly or subclassed. Provides the following features over and aboveDefaultTestContextBootstrapper:- 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
 - 另请参阅:
 SpringBootTest,TestConfiguration
构造器概要
构造器 构造器 说明 SpringBootTestContextBootstrapper()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 org.springframework.test.context.TestContextbuildTestContext()protected org.springframework.test.context.MergedContextConfigurationcreateModifiedConfig(org.springframework.test.context.MergedContextConfiguration mergedConfig, Class<?>[] classes)Create a newMergedContextConfigurationwith different classes.protected org.springframework.test.context.MergedContextConfigurationcreateModifiedConfig(org.springframework.test.context.MergedContextConfiguration mergedConfig, Class<?>[] classes, String[] propertySourceProperties)Create a newMergedContextConfigurationwith different classes and properties.protected SpringBootTestgetAnnotation(Class<?> testClass)protected Class<?>[]getClasses(Class<?> testClass)protected Class<? extends org.springframework.test.context.ContextLoader>getDefaultContextLoaderClass(Class<?> testClass)protected Set<Class<? extends org.springframework.test.context.TestExecutionListener>>getDefaultTestExecutionListenerClasses()protected StringgetDifferentiatorPropertySourceProperty()Return a "differentiator" property to ensure that there is something to differentiate regular tests and bootstrapped tests.protected Class<?>[]getOrFindConfigurationClasses(org.springframework.test.context.MergedContextConfiguration mergedConfig)protected String[]getProperties(Class<?> testClass)protected SpringBootTest.WebEnvironmentgetWebEnvironment(Class<?> testClass)Return theSpringBootTest.WebEnvironmenttype for this test or null if undefined.protected org.springframework.test.context.MergedContextConfigurationprocessMergedContextConfiguration(org.springframework.test.context.MergedContextConfiguration mergedConfig)protected voidprocessPropertySourceProperties(org.springframework.test.context.MergedContextConfiguration mergedConfig, List<String> propertySourceProperties)Post process the property source properties, adding or removing elements as required.protected org.springframework.test.context.ContextLoaderresolveContextLoader(Class<?> testClass, List<org.springframework.test.context.ContextConfigurationAttributes> configAttributesList)protected voidverifyConfiguration(Class<?> testClass)从类继承的方法 org.springframework.test.context.support.AbstractTestContextBootstrapper
buildMergedContextConfiguration, getBootstrapContext, getCacheAwareContextLoaderDelegate, getContextCustomizerFactories, getDefaultTestExecutionListenerClassNames, getTestExecutionListeners, resolveExplicitContextLoaderClass, setBootstrapContext
构造器详细资料
SpringBootTestContextBootstrapper
public SpringBootTestContextBootstrapper()
方法详细资料
buildTestContext
public org.springframework.test.context.TestContext buildTestContext()
- 指定者:
 buildTestContext在接口中org.springframework.test.context.TestContextBootstrapper- 覆盖:
 buildTestContext在类中org.springframework.test.context.support.AbstractTestContextBootstrapper
getDefaultTestExecutionListenerClasses
protected Set<Class<? extends org.springframework.test.context.TestExecutionListener>> getDefaultTestExecutionListenerClasses()
- 覆盖:
 getDefaultTestExecutionListenerClasses在类中org.springframework.test.context.support.AbstractTestContextBootstrapper
resolveContextLoader
protected org.springframework.test.context.ContextLoader resolveContextLoader(Class<?> testClass, List<org.springframework.test.context.ContextConfigurationAttributes> configAttributesList)
- 覆盖:
 resolveContextLoader在类中org.springframework.test.context.support.AbstractTestContextBootstrapper
getDefaultContextLoaderClass
protected Class<? extends org.springframework.test.context.ContextLoader> getDefaultContextLoaderClass(Class<?> testClass)
- 覆盖:
 getDefaultContextLoaderClass在类中org.springframework.test.context.support.DefaultTestContextBootstrapper
processMergedContextConfiguration
protected org.springframework.test.context.MergedContextConfiguration processMergedContextConfiguration(org.springframework.test.context.MergedContextConfiguration mergedConfig)
- 覆盖:
 processMergedContextConfiguration在类中org.springframework.test.context.support.AbstractTestContextBootstrapper
getOrFindConfigurationClasses
protected Class<?>[] getOrFindConfigurationClasses(org.springframework.test.context.MergedContextConfiguration mergedConfig)
getDifferentiatorPropertySourceProperty
protected String 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(org.springframework.test.context.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
protected SpringBootTest.WebEnvironment getWebEnvironment(Class<?> testClass)
Return theSpringBootTest.WebEnvironmenttype for this test or null if undefined.- 参数:
 testClass- the source test class- 返回:
 - the 
SpringBootTest.WebEnvironmentornull 
getClasses
protected Class<?>[] getClasses(Class<?> testClass)
getProperties
protected String[] getProperties(Class<?> testClass)
getAnnotation
protected SpringBootTest getAnnotation(Class<?> testClass)
verifyConfiguration
protected void verifyConfiguration(Class<?> testClass)
createModifiedConfig
protected final org.springframework.test.context.MergedContextConfiguration createModifiedConfig(org.springframework.test.context.MergedContextConfiguration mergedConfig, Class<?>[] classes)
Create a newMergedContextConfigurationwith different classes.- 参数:
 mergedConfig- the source configclasses- the replacement classes- 返回:
 - a new 
MergedContextConfiguration 
createModifiedConfig
protected final org.springframework.test.context.MergedContextConfiguration createModifiedConfig(org.springframework.test.context.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