注释类型 SpringBootTest
@Target(TYPE) @Retention(RUNTIME) @Documented @Inherited @BootstrapWith(SpringBootTestContextBootstrapper.class) public @interface SpringBootTest
Annotation that can be specified on a test class that runs Spring Boot based tests. Provides the following features over and above the regular Spring TestContext Framework:- Uses 
SpringBootContextLoaderas the defaultContextLoaderwhen no specific@ContextConfiguration(loader=...)is defined. - Automatically searches for a 
@SpringBootConfigurationwhen nested@Configurationis not used, and no explicitclassesare specified. - Allows custom 
Environmentproperties to be defined using theproperties attribute. - Provides support for different 
webEnvironmentmodes, including the ability to start a fully running container listening on adefinedorrandomport. - Registers a 
TestRestTemplatebean for use in web tests that are using a fully running container. 
- 从以下版本开始:
 - 1.4.0
 - 另请参阅:
 ContextConfiguration
- Uses 
 
可选元素概要
可选元素 修饰符和类型 可选元素 说明 Class<?>[]classesThe annotated classes to use for loading anApplicationContext.String[]propertiesProperties in form key=value that should be added to the SpringEnvironmentbefore the test runs.String[]valueAlias forproperties().SpringBootTest.WebEnvironmentwebEnvironmentThe type of web environment to create when applicable.
元素详细资料
value
@AliasFor("properties") String[] valueAlias forproperties().- 返回:
 - the properties to apply
 
- 默认值:
 - {}
 
properties
@AliasFor("value") String[] propertiesProperties in form key=value that should be added to the SpringEnvironmentbefore the test runs.- 返回:
 - the properties to add
 
- 默认值:
 - {}
 
classes
Class<?>[] classes
The annotated classes to use for loading anApplicationContext. Can also be specified using@ContextConfiguration(classes=...). If no explicit classes are defined the test will look for nested@Configurationclasses, before falling back to aSpringBootConfigurationsearch.- 返回:
 - the annotated classes used to load the application context
 - 另请参阅:
 ContextConfiguration.classes()
- 默认值:
 - {}
 
webEnvironment
SpringBootTest.WebEnvironment webEnvironment
The type of web environment to create when applicable. Defaults toSpringBootTest.WebEnvironment.MOCK.- 返回:
 - the type of web environment
 
- 默认值:
 - org.springframework.boot.test.context.SpringBootTest.WebEnvironment.MOCK