Annotation Interface SpringBootTest
@Target(TYPE)
@Retention(RUNTIME)
@Documented
@Inherited
@BootstrapWith(SpringBootTestContextBootstrapper.class)
@ExtendWith(org.springframework.test.context.junit.jupiter.SpringExtension.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.
- Allows application arguments to be defined using the args attribute.
- Provides support for different webEnvironmentmodes, including the ability to start a fully running web server listening on adefinedorrandomport.
- Registers a TestRestTemplateand/orWebTestClientbean for use in web tests that are using a fully running web server.
- Since:
- 1.4.0
- Author:
- Phillip Webb, Andy Wilkinson
- See Also:
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic enumEnumeration of how the main method of the@SpringBootConfiguration-annotated class is used when creating and running theSpringApplicationunder test.static enumAn enumeration web environment modes.
- 
Optional Element SummaryOptional ElementsModifier and TypeOptional ElementDescriptionString[]Application arguments that should be passed to the application under test.Class<?>[]The component classes to use for loading anApplicationContext.String[]Properties in form key=value that should be added to the SpringEnvironmentbefore the test runs.The type of main method usage to employ when creating theSpringApplicationunder test.String[]Alias forproperties().The type of web environment to create when applicable.
- 
Element Details- 
valueAlias forproperties().- Returns:
- the properties to apply
 - Default:
- {}
 
- 
propertiesProperties in form key=value that should be added to the SpringEnvironmentbefore the test runs.- Returns:
- the properties to add
 - Default:
- {}
 
- 
argsString[] argsApplication arguments that should be passed to the application under test.- Returns:
- the application arguments to pass to the application under test.
- Since:
- 2.2.0
- See Also:
 - Default:
- {}
 
- 
classesClass<?>[] classesThe component 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 a@SpringBootConfigurationsearch.- Returns:
- the component classes used to load the application context
- See Also:
 - Default:
- {}
 
- 
webEnvironmentSpringBootTest.WebEnvironment webEnvironmentThe type of web environment to create when applicable. Defaults toSpringBootTest.WebEnvironment.MOCK.- Returns:
- the type of web environment
 - Default:
- MOCK
 
- 
useMainMethodSpringBootTest.UseMainMethod useMainMethodThe type of main method usage to employ when creating theSpringApplicationunder test.- Returns:
- the type of main method usage
- Since:
- 3.0.0
 - Default:
- NEVER
 
 
-