Annotation Interface InfraTest
@Target(TYPE)
@Retention(RUNTIME)
@Documented
@Inherited
@BootstrapWith(InfraTestContextBootstrapper.class)
@ExtendWith(InfraExtension.class)
public @interface InfraTest
Annotation that can be specified on a test class that runs Infra based tests.
Provides the following features over and above the regular Infra TestContext
Framework:
- Uses
InfraApplicationContextLoaderas the defaultContextLoaderwhen no specific@ContextConfiguration(loader=...)is defined. - Automatically searches for a
@InfraConfigurationwhen 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.
- 从以下版本开始:
- 4.0
- 作者:
- Phillip Webb, Andy Wilkinson
- 另请参阅:
-
嵌套类概要
嵌套类 -
可选元素概要
可选元素修饰符和类型可选元素说明String[]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 InfraEnvironmentbefore the test runs.String[]Alias forproperties().The type of web environment to create when applicable.
-
元素详细资料
-
value
Alias forproperties().- 返回:
- the properties to apply
- 默认值:
- {}
-
properties
Properties in form key=value that should be added to the InfraEnvironmentbefore the test runs.- 返回:
- the properties to add
- 默认值:
- {}
-
args
String[] argsApplication arguments that should be passed to the application under test.- 返回:
- the application arguments to pass to the application under test.
- 另请参阅:
-
ApplicationArgumentsApplication.run(String...)
- 默认值:
- {}
-
classes
Class<?>[] 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@InfraConfigurationsearch.- 返回:
- the component classes used to load the application context
- 另请参阅:
- 默认值:
- {}
-
webEnvironment
InfraTest.WebEnvironment webEnvironmentThe type of web environment to create when applicable. Defaults toInfraTest.WebEnvironment.MOCK.- 返回:
- the type of web environment
- 默认值:
- MOCK
-