diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTest.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTest.java index 99f8739b45d..b50c2ca0e32 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTest.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTest.java @@ -31,11 +31,13 @@ import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache; import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; +import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan.Filter; import org.springframework.core.annotation.AliasFor; import org.springframework.core.env.Environment; import org.springframework.test.context.BootstrapWith; import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.springframework.transaction.annotation.Transactional; /** * Annotation that can be used in combination with {@code @RunWith(SpringRunner.class)} @@ -44,6 +46,17 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; *
* Using this annotation will disable full auto-configuration and instead apply only * configuration relevant to Data JDBC tests. + *
+ * By default, tests annotated with {@code @DataJdbcTest} are transactional and roll back + * at the end of each test. They also use an embedded in-memory database (replacing any + * explicit or usually auto-configured DataSource). The + * {@link AutoConfigureTestDatabase @AutoConfigureTestDatabase} annotation can be used to + * override these settings. + *
+ * If you are looking to load your full application configuration, but use an embedded + * database, you should consider {@link SpringBootTest @SpringBootTest} combined with + * {@link AutoConfigureTestDatabase @AutoConfigureTestDatabase} rather than this + * annotation. * * @author Andy Wilkinson * @since 2.1.0 @@ -56,6 +69,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; @ExtendWith(SpringExtension.class) @OverrideAutoConfiguration(enabled = false) @TypeExcludeFilters(DataJdbcTypeExcludeFilter.class) +@Transactional @AutoConfigureCache @AutoConfigureDataJdbc @AutoConfigureTestDatabase diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTest.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTest.java index 41353bebf23..ff055ef71d0 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTest.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTest.java @@ -46,8 +46,9 @@ import org.springframework.transaction.annotation.Transactional; * Using this annotation will disable full auto-configuration and instead apply only * configuration relevant to jdbc tests. *
- * By default, tests annotated with {@code @JdbcTest} will use an embedded in-memory - * database (replacing any explicit or usually auto-configured DataSource). The + * By default, tests annotated with {@code @JdbcTest} are transactional and roll back + * at the end of each test. They also use an embedded in-memory database (replacing any + * explicit or usually auto-configured DataSource). The * {@link AutoConfigureTestDatabase @AutoConfigureTestDatabase} annotation can be used to * override these settings. *
diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTest.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTest.java index 25f229d22bf..e9e2961a5b9 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTest.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTest.java @@ -48,8 +48,9 @@ import org.springframework.transaction.annotation.Transactional; * Using this annotation will disable full auto-configuration and instead apply only * configuration relevant to JPA tests. *
- * By default, tests annotated with {@code @DataJpaTest} will use an embedded in-memory - * database (replacing any explicit or usually auto-configured DataSource). The + * By default, tests annotated with {@code @DataJpaTest} are transactional and roll back + * at the end of each test. They also use an embedded in-memory database (replacing any + * explicit or usually auto-configured DataSource). The * {@link AutoConfigureTestDatabase @AutoConfigureTestDatabase} annotation can be used to * override these settings. *