Annotation Type BackendTest
Runs a test class against the application the build wired: what
@SpringBootTest does.
The build generates, for each class carrying this, a wiring of the
application's beans with the class's test beans added -- its
TestConfigurations and MockitoBeans -- and the code that fills the class's
@Autowired, LocalServerPort and MockitoBean fields. Nothing is looked up
by reflection, so the same test runs translated, as a native binary.
One application runs at a time, as one runs per server process, and JUnit runs no two classes carrying this concurrently, even with parallel execution on. Test classes whose configuration is the same -- the same test beans, properties, profile and web environment -- share it, as Spring caches a context; a class that differs stops it and starts its own.
It is inherited, as @SpringBootTest is: an abstract base class can carry it,
with the shared fields and tests, for concrete subclasses to run.
-
Nested Class Summary
Nested Classes -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionClass<?>[]TestConfigurationclasses to add.The profile.String[]Settings for this test, askey=value, over the module'sapplication.properties, the profile's file and the environment: a shell'sPORTorDATABASE_URLdoes not reach a test that names its own.How the application is reached.
-
Element Details
-
webEnvironment
BackendTest.WebEnvironment webEnvironmentHow the application is reached.BackendTest.WebEnvironment.MOCK, the default, calls it in the same process throughMockMvc;BackendTest.WebEnvironment.RANDOM_PORTserves it on a free port forTestRestTemplateor any HTTP client.- Default:
MOCK
-
properties
String[] propertiesSettings for this test, askey=value, over the module'sapplication.properties, the profile's file and the environment: a shell'sPORTorDATABASE_URLdoes not reach a test that names its own.- Default:
{}
-
profile
String profileThe profile.testis a development profile: a database neither the test nor the profile's file names is an in-memory SQLite one, whatever the environment says, and the generated daos create their tables.- Default:
"test"
-
classes
Class<?>[] classesTestConfigurationclasses to add. A static nestedTestConfigurationclass of the test class is added without being listed.- Default:
{}
-