M04 Q39 What does @SpringBootTest auto-configure?
@SpringBootTest
annotation will auto-configure:
ApplicationContext
is configured by searching for @SpringBootApplication
or @SpringBootConfiguration
annotated classes, based on those bean definitions will be created.
It is also possible to test only slice of the application with usage one of following:
@AutoConfigureā¦
annotations allows you to configure specific environment and tools for testing, for example @AutoConfigureMockMvc
will configure Mock Mvc that can be used for Controllers testing.
Spring Boot Test includes annotations that are wrapping @AutoConfigureā¦
annotations and make test development simpler:
- @WebFluxTest
- @DataJpaTest - tests interactions with JPA
- @JdbcTest - tests interactions with JDBC
- @JooqTest - tests interactions with Jooq
- @DataMongoTest - tests interactions with Mongo
- @DataLdapTest
- @RestClientTest
Each of this annotation uses @AutoConfigureā¦
annotations and also @ExtendWith(SpringExtension.class)
for JUnit 5, which makes test development easier.