类 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
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
- 作者:
- Phillip Webb, Andy Wilkinson, Brian Clozel, Madhura Bhave, Lorenzo Dee
- 另请参阅:
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明protected final MergedContextConfiguration
createModifiedConfig
(MergedContextConfiguration mergedConfig, Class<?>[] classes) Create a newMergedContextConfiguration
with different classes.protected final MergedContextConfiguration
createModifiedConfig
(MergedContextConfiguration mergedConfig, Class<?>[] classes, String[] propertySourceProperties) Create a newMergedContextConfiguration
with different classes and properties.protected String
determineResourceBasePath
(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 SpringBootTest
getAnnotation
(Class<?> testClass) protected Class<?>[]
getClasses
(Class<?> testClass) protected Class
<? extends ContextLoader> getDefaultContextLoaderClass
(Class<?> testClass) protected String
Return 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.WebEnvironment
getWebEnvironment
(Class<?> testClass) Return theSpringBootTest.WebEnvironment
type for this test or null if undefined.protected MergedContextConfiguration
processMergedContextConfiguration
(MergedContextConfiguration mergedConfig) protected void
processPropertySourceProperties
(MergedContextConfiguration mergedConfig, List<String> propertySourceProperties) Post process the property source properties, adding or removing elements as required.protected ContextLoader
resolveContextLoader
(Class<?> testClass, List<ContextConfigurationAttributes> configAttributesList) protected void
verifyConfiguration
(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/webapp
in 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.WebEnvironment
type for this test or null if undefined.- 参数:
testClass
- the source test class- 返回:
- the
SpringBootTest.WebEnvironment
ornull
-
getClasses
-
getProperties
-
getAnnotation
-
verifyConfiguration
-
createModifiedConfig
protected final MergedContextConfiguration createModifiedConfig(MergedContextConfiguration mergedConfig, Class<?>[] classes) Create a newMergedContextConfiguration
with 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 newMergedContextConfiguration
with different classes and properties.- 参数:
mergedConfig
- the source configclasses
- the replacement classespropertySourceProperties
- the replacement properties- 返回:
- a new
MergedContextConfiguration
-