类 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
TestContextBootstrapper
for Spring Boot. Provides support for@SpringBootTest
and may also be used directly or subclassed. Provides the following features over and aboveDefaultTestContextBootstrapper
:- Uses
SpringBootContextLoader
as thedefault context loader
. - Automatically searches for a
@SpringBootConfiguration
when required. - Allows custom
Environment
getProperties(Class)
to be defined. - Provides support for different
webEnvironment
modes.
- 从以下版本开始:
- 1.4.0
- 另请参阅:
SpringBootTest
,TestConfiguration
构造器概要
构造器 构造器 说明 SpringBootTestContextBootstrapper()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 org.springframework.test.context.TestContext
buildTestContext()
protected org.springframework.test.context.MergedContextConfiguration
createModifiedConfig(org.springframework.test.context.MergedContextConfiguration mergedConfig, Class<?>[] classes)
Create a newMergedContextConfiguration
with different classes.protected org.springframework.test.context.MergedContextConfiguration
createModifiedConfig(org.springframework.test.context.MergedContextConfiguration mergedConfig, Class<?>[] classes, String[] propertySourceProperties)
Create a newMergedContextConfiguration
with different classes and properties.protected SpringBootTest
getAnnotation(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 String
getDifferentiatorPropertySourceProperty()
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.WebEnvironment
getWebEnvironment(Class<?> testClass)
Return theSpringBootTest.WebEnvironment
type for this test or null if undefined.protected org.springframework.test.context.MergedContextConfiguration
processMergedContextConfiguration(org.springframework.test.context.MergedContextConfiguration mergedConfig)
protected void
processPropertySourceProperties(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.ContextLoader
resolveContextLoader(Class<?> testClass, List<org.springframework.test.context.ContextConfigurationAttributes> configAttributesList)
protected void
verifyConfiguration(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.WebEnvironment
type for this test or null if undefined.- 参数:
testClass
- the source test class- 返回:
- the
SpringBootTest.WebEnvironment
ornull
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 newMergedContextConfiguration
with 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 newMergedContextConfiguration
with different classes and properties.- 参数:
mergedConfig
- the source configclasses
- the replacement classespropertySourceProperties
- the replacement properties- 返回:
- a new
MergedContextConfiguration