diff --git a/build-plugin/spring-boot-gradle-plugin/src/docs/antora/modules/gradle-plugin/pages/aot.adoc b/build-plugin/spring-boot-gradle-plugin/src/docs/antora/modules/gradle-plugin/pages/aot.adoc index 6c1318c9440..ee631e308f7 100644 --- a/build-plugin/spring-boot-gradle-plugin/src/docs/antora/modules/gradle-plugin/pages/aot.adoc +++ b/build-plugin/spring-boot-gradle-plugin/src/docs/antora/modules/gradle-plugin/pages/aot.adoc @@ -44,7 +44,7 @@ The `nativeCompile` task of the GraalVM Native Image plugin is automatically con [[aot.processing-tests]] == Processing Tests -The AOT engine can be applied to JUnit tests that use Spring's Test Context Framework. +The AOT engine can be applied to JUnit 5 tests that use Spring's Test Context Framework. Suitable tests are processed by the `processTestAot` task to generate `ApplicationContextInitializer` code. As with application AOT processing, the `BeanFactory` is fully prepared at build-time. As with `processAot`, the `processTestAot` task is `JavaExec` subclass and can be configured as needed to influence this processing. diff --git a/build-plugin/spring-boot-maven-plugin/src/docs/antora/modules/maven-plugin/pages/aot.adoc b/build-plugin/spring-boot-maven-plugin/src/docs/antora/modules/maven-plugin/pages/aot.adoc index 99c6bf1b718..fcbec79deef 100644 --- a/build-plugin/spring-boot-maven-plugin/src/docs/antora/modules/maven-plugin/pages/aot.adoc +++ b/build-plugin/spring-boot-maven-plugin/src/docs/antora/modules/maven-plugin/pages/aot.adoc @@ -89,7 +89,7 @@ include::partial$goals/process-aot.adoc[leveloffset=+1] [[aot.processing-tests]] == Processing Tests -The AOT engine can be applied to JUnit tests that use Spring's Test Context Framework. +The AOT engine can be applied to JUnit 5 tests that use Spring's Test Context Framework. Those tests are processed by the AOT engine and are then executed in a native image. Just like <>, the `spring-boot-starter-parent` defines a `nativeTest` profile that can be used to streamline the steps required to execute your tests in a native image. diff --git a/core/spring-boot-test/src/test/java/org/springframework/boot/test/context/filter/TestTypeExcludeFilterTests.java b/core/spring-boot-test/src/test/java/org/springframework/boot/test/context/filter/TestTypeExcludeFilterTests.java index ace41b35c19..a3f9056028b 100644 --- a/core/spring-boot-test/src/test/java/org/springframework/boot/test/context/filter/TestTypeExcludeFilterTests.java +++ b/core/spring-boot-test/src/test/java/org/springframework/boot/test/context/filter/TestTypeExcludeFilterTests.java @@ -40,7 +40,6 @@ class TestTypeExcludeFilterTests { private final MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory(); @Test - @Deprecated(since = "4.0.0") void matchesJUnit4TestClass() throws Exception { assertThat(this.filter.match(getMetadataReader(TestTypeExcludeFilterTests.class), this.metadataReaderFactory)) .isTrue(); diff --git a/core/spring-boot/src/main/java/org/springframework/boot/context/annotation/Configurations.java b/core/spring-boot/src/main/java/org/springframework/boot/context/annotation/Configurations.java index bccb1405291..26ac171e52b 100644 --- a/core/spring-boot/src/main/java/org/springframework/boot/context/annotation/Configurations.java +++ b/core/spring-boot/src/main/java/org/springframework/boot/context/annotation/Configurations.java @@ -49,7 +49,7 @@ import org.springframework.util.ClassUtils; * {@link ApplicationContext} and/or custom {@link ImportSelector} implementations. *

* This class is primarily intended for use with tests that need to specify configuration - * classes. + * classes but can't use {@link org.springframework.test.context.junit4.SpringRunner}. *

* Implementations of this class should be annotated with {@link Order @Order} or * implement {@link Ordered}. diff --git a/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/features/kotlin.adoc b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/features/kotlin.adoc index d3ad1f6984c..256237ddaab 100644 --- a/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/features/kotlin.adoc +++ b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/features/kotlin.adoc @@ -142,7 +142,8 @@ Note that some features (such as detecting the default value or deprecated items [[features.kotlin.testing]] == Testing -JUnit enables a test class to be instantiated once and reused for all of the class's tests. +While it is possible to use JUnit 4 to test Kotlin code, JUnit 5 is provided by default and is recommended. +JUnit 5 enables a test class to be instantiated once and reused for all of the class's tests. This makes it possible to use javadoc:org.junit.jupiter.api.BeforeAll[format=annotation] and javadoc:org.junit.jupiter.api.AfterAll[format=annotation] annotations on non-static methods, which is a good fit for Kotlin. To mock Kotlin classes, https://mockk.io/[MockK] is recommended. diff --git a/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/index.adoc b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/index.adoc index 84611a4ce14..1ae13e3d1f5 100644 --- a/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/index.adoc +++ b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/index.adoc @@ -8,7 +8,7 @@ Most developers use the `spring-boot-starter-test` starter, which imports both S [TIP] ==== -If you have tests that still use JUnit 4, JUnit's vintage engine can be used to run them. +If you have tests that use JUnit 4, JUnit 5's vintage engine can be used to run them. To use the vintage engine, add a dependency on `junit-vintage-engine`, as shown in the following example: [source,xml] diff --git a/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/spring-boot-applications.adoc b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/spring-boot-applications.adoc index 80f7138b4c4..d3fea3ccb40 100644 --- a/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/spring-boot-applications.adoc +++ b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/spring-boot-applications.adoc @@ -9,7 +9,8 @@ Spring Boot provides a javadoc:org.springframework.boot.test.context.SpringBootT The annotation works by xref:testing/spring-boot-applications.adoc#testing.spring-boot-applications.detecting-configuration[creating the javadoc:org.springframework.context.ApplicationContext[] used in your tests through javadoc:org.springframework.boot.SpringApplication[]]. In addition to javadoc:org.springframework.boot.test.context.SpringBootTest[format=annotation] a number of other annotations are also provided for xref:testing/spring-boot-applications.adoc#testing.spring-boot-applications.autoconfigured-tests[testing more specific slices] of an application. -If you are using JUnit, there is no need to add the equivalent `@ExtendWith(SpringExtension.class)` as javadoc:org.springframework.boot.test.context.SpringBootTest[format=annotation] and the other `@...Test` annotations are already annotated with it. +TIP: If you are using JUnit 4, do not forget to also add `@RunWith(SpringRunner.class)` to your test, otherwise the annotations will be ignored. +If you are using JUnit 5, there is no need to add the equivalent `@ExtendWith(SpringExtension.class)` as javadoc:org.springframework.boot.test.context.SpringBootTest[format=annotation] and the other `@...Test` annotations are already annotated with it. By default, javadoc:org.springframework.boot.test.context.SpringBootTest[format=annotation] will not start a server. You can use the `webEnvironment` attribute of javadoc:org.springframework.boot.test.context.SpringBootTest[format=annotation] to further refine how your tests run: diff --git a/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/test-scope-dependencies.adoc b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/test-scope-dependencies.adoc index 1695c6a0db1..02d3e2424d1 100644 --- a/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/test-scope-dependencies.adoc +++ b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/test-scope-dependencies.adoc @@ -3,7 +3,7 @@ The `spring-boot-starter-test` starter (in the `test` `scope`) contains the following provided libraries: -* https://junit.org/junit5/[JUnit]: The de-facto standard for unit testing Java applications. +* https://junit.org/junit5/[JUnit 5]: The de-facto standard for unit testing Java applications. * {url-spring-framework-docs}/testing/integration.html[Spring Test] & Spring Boot Test: Utilities and integration test support for Spring Boot applications. * https://assertj.github.io/doc/[AssertJ]: A fluent assertion library. * https://github.com/hamcrest/JavaHamcrest[Hamcrest]: A library of matcher objects (also known as constraints or predicates). diff --git a/loader/spring-boot-loader-classic/src/test/java/org/springframework/boot/loader/jar/JarUrlProtocolHandler.java b/loader/spring-boot-loader-classic/src/test/java/org/springframework/boot/loader/jar/JarUrlProtocolHandler.java index 440b8d778c0..ee43c0df18d 100644 --- a/loader/spring-boot-loader-classic/src/test/java/org/springframework/boot/loader/jar/JarUrlProtocolHandler.java +++ b/loader/spring-boot-loader-classic/src/test/java/org/springframework/boot/loader/jar/JarUrlProtocolHandler.java @@ -28,9 +28,9 @@ import org.junit.jupiter.api.extension.ExtensionContext; import org.springframework.test.util.ReflectionTestUtils; /** - * JUnit {@link Extension} for tests that interact with Spring Boot's {@link Handler} for - * {@code jar:} URLs. Ensures that the handler is registered prior to test execution and - * cleans up the handler's root file cache afterwards. + * JUnit 5 {@link Extension} for tests that interact with Spring Boot's {@link Handler} + * for {@code jar:} URLs. Ensures that the handler is registered prior to test execution + * and cleans up the handler's root file cache afterwards. * * @author Andy Wilkinson */ diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTest.java b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTest.java index 52937e64ca3..ccf7629710b 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTest.java +++ b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTest.java @@ -43,6 +43,9 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; * Using this annotation only enables auto-configuration that is relevant to Data Casandra * tests. Similarly, component scanning is limited to Cassandra repositories and entities * ({@code @Table}). + *

+ * When using JUnit 4, this annotation should be used in combination with + * {@code @RunWith(SpringRunner.class)}. * * @author Artsiom Yudovin * @author Stephane Nicoll diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTest.java b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTest.java index 412324be3ea..5f56fd6d43c 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTest.java +++ b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTest.java @@ -43,6 +43,9 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; * Using this annotation only enables auto-configuration that is relevant to Data * Couchbase tests. Similarly, component scanning is limited to Couchbase repositories and * entities ({@code @Document}). + *

+ * When using JUnit 4, this annotation should be used in combination with + * {@code @RunWith(SpringRunner.class)}. * * @author Eddú Meléndez * @since 2.7.0 diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTest.java b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTest.java index 211a4b337ba..c2baffec73d 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTest.java +++ b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTest.java @@ -43,6 +43,9 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; * Using this annotation only enables auto-configuration that is relevant to Data * Elasticsearch tests. Similarly, component scanning is limited to Elasticsearch * repositories and entities ({@code @Document}). + *

+ * When using JUnit 4, this annotation should be used in combination with + * {@code @RunWith(SpringRunner.class)}. * * @author Eddú Meléndez * @since 2.7.0 diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTest.java b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTest.java index 6ee34b0216e..f9e8fd42a46 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTest.java +++ b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTest.java @@ -57,6 +57,9 @@ import org.springframework.transaction.annotation.Transactional; * database, you should consider {@link SpringBootTest @SpringBootTest} combined with * {@link AutoConfigureTestDatabase @AutoConfigureTestDatabase} rather than this * annotation. + *

+ * When using JUnit 4, this annotation should be used in combination with + * {@code @RunWith(SpringRunner.class)}. * * @author Andy Wilkinson * @since 2.1.0 diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTest.java b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTest.java index a65854ed50f..52edad4fc08 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTest.java +++ b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTest.java @@ -46,6 +46,9 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; *

* By default, tests annotated with {@code @DataLdapTest} will use an embedded in-memory * LDAP process (if available). + *

+ * When using JUnit 4, this annotation should be used in combination with + * {@code @RunWith(SpringRunner.class)}. * * @author Eddú Meléndez * @author Artsiom Yudovin diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTest.java b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTest.java index 7598273f28d..08ddff1d2dd 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTest.java +++ b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTest.java @@ -43,6 +43,9 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; * Using this annotation only enables auto-configuration that is relevant to Data Mongo * tests. Similarly, component scanning is limited to Mongo repositories and entities * ({@code @Document}). + *

+ * When using JUnit 4, this annotation should be used in combination with + * {@code @RunWith(SpringRunner.class)}. * * @author Michael Simons * @author Stephane Nicoll diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTest.java b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTest.java index 9adcab31984..15706667085 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTest.java +++ b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTest.java @@ -49,6 +49,9 @@ import org.springframework.transaction.annotation.Transactional; * usual test-related semantics (i.e. rollback by default). This feature is not supported * with reactive access so this should be disabled by annotating the test class with * {@code @Transactional(propagation = Propagation.NOT_SUPPORTED)}. + *

+ * When using JUnit 4, this annotation should be used in combination with + * {@code @RunWith(SpringRunner.class)}. * * @author Eddú Meléndez * @author Stephane Nicoll diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/r2dbc/DataR2dbcTest.java b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/r2dbc/DataR2dbcTest.java index d32765c4163..dfb3f7ccfa5 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/r2dbc/DataR2dbcTest.java +++ b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/r2dbc/DataR2dbcTest.java @@ -42,6 +42,9 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; * Using this annotation only enables auto-configuration that is relevant to Data R2DBC * tests. Similarly, component scanning is limited to R2DBC repositories and entities * ({@code @Table}). + *

+ * When using JUnit 4, this annotation should be used in combination with + * {@code @RunWith(SpringRunner.class)}. * * @author Mark Paluch * @author Stephane Nicoll diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTest.java b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTest.java index fd65b275ace..ed34eac72f8 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTest.java +++ b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTest.java @@ -43,6 +43,9 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; * Using this annotation only enables auto-configuration that is relevant to Data Redis * tests. Similarly, component scanning is limited to Redis repositories and entities * ({@code @RedisHash}). + *

+ * When using JUnit 4, this annotation should be used in combination with + * {@code @RunWith(SpringRunner.class)}. * * @author Jayaram Pradhan * @author Artsiom Yudovin diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTest.java b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTest.java index ece4b044c08..9b3048e5b98 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTest.java +++ b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTest.java @@ -55,6 +55,9 @@ import org.springframework.transaction.annotation.Transactional; * database, you should consider {@link SpringBootTest @SpringBootTest} combined with * {@link AutoConfigureTestDatabase @AutoConfigureTestDatabase} rather than this * annotation. + *

+ * When using JUnit 4, this annotation should be used in combination with + * {@code @RunWith(SpringRunner.class)}. * * @author Stephane Nicoll * @author Artsiom Yudovin diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jooq/JooqTest.java b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jooq/JooqTest.java index 6dead7d1b50..eba07773663 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jooq/JooqTest.java +++ b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jooq/JooqTest.java @@ -49,6 +49,9 @@ import org.springframework.transaction.annotation.Transactional; * want to replace any explicit or usually auto-configured DataSource by an embedded * in-memory database, the {@link AutoConfigureTestDatabase @AutoConfigureTestDatabase} * annotation can be used to override these settings. + *

+ * When using JUnit 4, this annotation should be used in combination with + * {@code @RunWith(SpringRunner.class)}. * * @author Michael Simons * @author Stephane Nicoll diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTest.java b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTest.java index 6ce7d9382be..0f6ae886225 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTest.java +++ b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTest.java @@ -57,6 +57,9 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; * {@link JacksonTester}, {@link JsonbTester} and {@link GsonTester} fields. More * fine-grained control can be provided through the * {@link AutoConfigureJsonTesters @AutoConfigureJsonTesters} annotation. + *

+ * When using JUnit 4, this annotation should be used in combination with + * {@code @RunWith(SpringRunner.class)}. * * @author Phillip Webb * @author Artsiom Yudovin diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTest.java b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTest.java index cd93915fa13..62dc4fcc8a8 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTest.java +++ b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTest.java @@ -62,6 +62,9 @@ import org.springframework.transaction.annotation.Transactional; * database, you should consider {@link SpringBootTest @SpringBootTest} combined with * {@link AutoConfigureTestDatabase @AutoConfigureTestDatabase} rather than this * annotation. + *

+ * When using JUnit 4, this annotation should be used in combination with + * {@code @RunWith(SpringRunner.class)}. * * @author Phillip Webb * @author Artsiom Yudovin diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTest.java b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTest.java index 864e2aa98ae..0262d519ca0 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTest.java +++ b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTest.java @@ -63,6 +63,9 @@ import org.springframework.web.client.RestTemplate; * If you are testing a bean that doesn't use {@link RestTemplateBuilder} but instead * injects a {@link RestTemplate} directly, you can add * {@code @AutoConfigureWebClient(registerRestTemplate=true)}. + *

+ * When using JUnit 4, this annotation should be used in combination with + * {@code @RunWith(SpringRunner.class)}. * * @author Stephane Nicoll * @author Phillip Webb diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTest.java b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTest.java index ed6f179178d..537f3f24111 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTest.java +++ b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTest.java @@ -76,6 +76,9 @@ import org.springframework.test.web.reactive.server.WebTestClient; * you should consider {@link SpringBootTest @SpringBootTest} combined with * {@link AutoConfigureWebTestClient @AutoConfigureWebTestClient} rather than this * annotation. + *

+ * When using JUnit 4, this annotation should be used in combination with + * {@code @RunWith(SpringRunner.class)}. * * @author Stephane Nicoll * @author Artsiom Yudovin diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTest.java b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTest.java index 37a7a1089d1..1444d337942 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTest.java +++ b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTest.java @@ -83,6 +83,9 @@ import org.springframework.test.web.servlet.MockMvc; * If you are looking to load your full application configuration and use MockMVC, you * should consider {@link SpringBootTest @SpringBootTest} combined with * {@link AutoConfigureMockMvc @AutoConfigureMockMvc} rather than this annotation. + *

+ * When using JUnit 4, this annotation should be used in combination with + * {@code @RunWith(SpringRunner.class)}. * * @author Phillip Webb * @author Artsiom Yudovin diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceClientTest.java b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceClientTest.java index d0a4de8df70..d392357a12c 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceClientTest.java +++ b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceClientTest.java @@ -48,6 +48,9 @@ import org.springframework.ws.test.client.MockWebServiceServer; * If you are testing a bean that doesn't use {@link WebServiceTemplateBuilder} but * instead injects a {@link WebServiceTemplate} directly, you can add * {@code @AutoConfigureWebServiceClient(registerWebServiceTemplate=true)}. + *

+ * When using JUnit 4, this annotation should be used in combination with + * {@code @RunWith(SpringRunner.class)}. * * @author Dmytro Nosan * @since 2.3.0