Browse Source

Remove mentions of JUnit 4

This commit removes all mentions of JUnit 4 from the Javadoc and
reference documentation. It also harmonizes to simply refers to JUnit.

Closes gh-47228
pull/47286/head
Stéphane Nicoll 3 months ago
parent
commit
3b98af30f5
  1. 2
      build-plugin/spring-boot-gradle-plugin/src/docs/antora/modules/gradle-plugin/pages/aot.adoc
  2. 2
      build-plugin/spring-boot-maven-plugin/src/docs/antora/modules/maven-plugin/pages/aot.adoc
  3. 1
      core/spring-boot-test/src/test/java/org/springframework/boot/test/context/filter/TestTypeExcludeFilterTests.java
  4. 2
      core/spring-boot/src/main/java/org/springframework/boot/context/annotation/Configurations.java
  5. 3
      documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/features/kotlin.adoc
  6. 2
      documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/index.adoc
  7. 3
      documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/spring-boot-applications.adoc
  8. 2
      documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/test-scope-dependencies.adoc
  9. 6
      loader/spring-boot-loader-classic/src/test/java/org/springframework/boot/loader/jar/JarUrlProtocolHandler.java
  10. 3
      module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTest.java
  11. 3
      module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTest.java
  12. 3
      module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTest.java
  13. 3
      module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTest.java
  14. 3
      module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTest.java
  15. 3
      module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTest.java
  16. 3
      module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTest.java
  17. 3
      module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/r2dbc/DataR2dbcTest.java
  18. 3
      module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTest.java
  19. 3
      module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTest.java
  20. 3
      module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jooq/JooqTest.java
  21. 3
      module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTest.java
  22. 3
      module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTest.java
  23. 3
      module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTest.java
  24. 3
      module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTest.java
  25. 3
      module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTest.java
  26. 3
      module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceClientTest.java

2
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 @@ -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 5 tests that use Spring's Test Context Framework.
The AOT engine can be applied to JUnit 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.

2
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] @@ -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 5 tests that use Spring's Test Context Framework.
The AOT engine can be applied to JUnit 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 <<aot.processing-applications.using-the-native-profile,for production code>>, 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.

1
core/spring-boot-test/src/test/java/org/springframework/boot/test/context/filter/TestTypeExcludeFilterTests.java

@ -40,6 +40,7 @@ class TestTypeExcludeFilterTests { @@ -40,6 +40,7 @@ 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();

2
core/spring-boot/src/main/java/org/springframework/boot/context/annotation/Configurations.java

@ -49,7 +49,7 @@ import org.springframework.util.ClassUtils; @@ -49,7 +49,7 @@ import org.springframework.util.ClassUtils;
* {@link ApplicationContext} and/or custom {@link ImportSelector} implementations.
* <p>
* This class is primarily intended for use with tests that need to specify configuration
* classes but can't use {@link org.springframework.test.context.junit4.SpringRunner}.
* classes.
* <p>
* Implementations of this class should be annotated with {@link Order @Order} or
* implement {@link Ordered}.

3
documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/features/kotlin.adoc

@ -142,8 +142,7 @@ Note that some features (such as detecting the default value or deprecated items @@ -142,8 +142,7 @@ Note that some features (such as detecting the default value or deprecated items
[[features.kotlin.testing]]
== Testing
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.
JUnit 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.

2
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 @@ -8,7 +8,7 @@ Most developers use the `spring-boot-starter-test` starter, which imports both S
[TIP]
====
If you have tests that use JUnit 4, JUnit 5's vintage engine can be used to run them.
If you have tests that still use JUnit 4, JUnit'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]

3
documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/spring-boot-applications.adoc

@ -9,8 +9,7 @@ Spring Boot provides a javadoc:org.springframework.boot.test.context.SpringBootT @@ -9,8 +9,7 @@ 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.
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.
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.
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:

2
documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/test-scope-dependencies.adoc

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
The `spring-boot-starter-test` starter (in the `test` `scope`) contains the following provided libraries:
* https://junit.org/junit5/[JUnit 5]: The de-facto standard for unit testing Java applications.
* https://junit.org/junit5/[JUnit]: 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).

6
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; @@ -28,9 +28,9 @@ import org.junit.jupiter.api.extension.ExtensionContext;
import org.springframework.test.util.ReflectionTestUtils;
/**
* 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.
* 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.
*
* @author Andy Wilkinson
*/

3
module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTest.java

@ -43,9 +43,6 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; @@ -43,9 +43,6 @@ 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}).
* <p>
* When using JUnit 4, this annotation should be used in combination with
* {@code @RunWith(SpringRunner.class)}.
*
* @author Artsiom Yudovin
* @author Stephane Nicoll

3
module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTest.java

@ -43,9 +43,6 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; @@ -43,9 +43,6 @@ 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}).
* <p>
* When using JUnit 4, this annotation should be used in combination with
* {@code @RunWith(SpringRunner.class)}.
*
* @author Eddú Meléndez
* @since 2.7.0

3
module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTest.java

@ -43,9 +43,6 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; @@ -43,9 +43,6 @@ 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}).
* <p>
* When using JUnit 4, this annotation should be used in combination with
* {@code @RunWith(SpringRunner.class)}.
*
* @author Eddú Meléndez
* @since 2.7.0

3
module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTest.java

@ -57,9 +57,6 @@ import org.springframework.transaction.annotation.Transactional; @@ -57,9 +57,6 @@ import org.springframework.transaction.annotation.Transactional;
* database, you should consider {@link SpringBootTest @SpringBootTest} combined with
* {@link AutoConfigureTestDatabase @AutoConfigureTestDatabase} rather than this
* annotation.
* <p>
* When using JUnit 4, this annotation should be used in combination with
* {@code @RunWith(SpringRunner.class)}.
*
* @author Andy Wilkinson
* @since 2.1.0

3
module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTest.java

@ -46,9 +46,6 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; @@ -46,9 +46,6 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
* <p>
* By default, tests annotated with {@code @DataLdapTest} will use an embedded in-memory
* LDAP process (if available).
* <p>
* When using JUnit 4, this annotation should be used in combination with
* {@code @RunWith(SpringRunner.class)}.
*
* @author Eddú Meléndez
* @author Artsiom Yudovin

3
module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTest.java

@ -43,9 +43,6 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; @@ -43,9 +43,6 @@ 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}).
* <p>
* When using JUnit 4, this annotation should be used in combination with
* {@code @RunWith(SpringRunner.class)}.
*
* @author Michael Simons
* @author Stephane Nicoll

3
module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTest.java

@ -49,9 +49,6 @@ import org.springframework.transaction.annotation.Transactional; @@ -49,9 +49,6 @@ 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)}.
* <p>
* When using JUnit 4, this annotation should be used in combination with
* {@code @RunWith(SpringRunner.class)}.
*
* @author Eddú Meléndez
* @author Stephane Nicoll

3
module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/r2dbc/DataR2dbcTest.java

@ -42,9 +42,6 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; @@ -42,9 +42,6 @@ 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}).
* <p>
* When using JUnit 4, this annotation should be used in combination with
* {@code @RunWith(SpringRunner.class)}.
*
* @author Mark Paluch
* @author Stephane Nicoll

3
module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTest.java

@ -43,9 +43,6 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; @@ -43,9 +43,6 @@ 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}).
* <p>
* When using JUnit 4, this annotation should be used in combination with
* {@code @RunWith(SpringRunner.class)}.
*
* @author Jayaram Pradhan
* @author Artsiom Yudovin

3
module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTest.java

@ -55,9 +55,6 @@ import org.springframework.transaction.annotation.Transactional; @@ -55,9 +55,6 @@ import org.springframework.transaction.annotation.Transactional;
* database, you should consider {@link SpringBootTest @SpringBootTest} combined with
* {@link AutoConfigureTestDatabase @AutoConfigureTestDatabase} rather than this
* annotation.
* <p>
* When using JUnit 4, this annotation should be used in combination with
* {@code @RunWith(SpringRunner.class)}.
*
* @author Stephane Nicoll
* @author Artsiom Yudovin

3
module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jooq/JooqTest.java

@ -49,9 +49,6 @@ import org.springframework.transaction.annotation.Transactional; @@ -49,9 +49,6 @@ 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.
* <p>
* When using JUnit 4, this annotation should be used in combination with
* {@code @RunWith(SpringRunner.class)}.
*
* @author Michael Simons
* @author Stephane Nicoll

3
module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTest.java

@ -57,9 +57,6 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; @@ -57,9 +57,6 @@ 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.
* <p>
* When using JUnit 4, this annotation should be used in combination with
* {@code @RunWith(SpringRunner.class)}.
*
* @author Phillip Webb
* @author Artsiom Yudovin

3
module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTest.java

@ -62,9 +62,6 @@ import org.springframework.transaction.annotation.Transactional; @@ -62,9 +62,6 @@ import org.springframework.transaction.annotation.Transactional;
* database, you should consider {@link SpringBootTest @SpringBootTest} combined with
* {@link AutoConfigureTestDatabase @AutoConfigureTestDatabase} rather than this
* annotation.
* <p>
* When using JUnit 4, this annotation should be used in combination with
* {@code @RunWith(SpringRunner.class)}.
*
* @author Phillip Webb
* @author Artsiom Yudovin

3
module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTest.java

@ -63,9 +63,6 @@ import org.springframework.web.client.RestTemplate; @@ -63,9 +63,6 @@ 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)}.
* <p>
* When using JUnit 4, this annotation should be used in combination with
* {@code @RunWith(SpringRunner.class)}.
*
* @author Stephane Nicoll
* @author Phillip Webb

3
module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTest.java

@ -76,9 +76,6 @@ import org.springframework.test.web.reactive.server.WebTestClient; @@ -76,9 +76,6 @@ import org.springframework.test.web.reactive.server.WebTestClient;
* you should consider {@link SpringBootTest @SpringBootTest} combined with
* {@link AutoConfigureWebTestClient @AutoConfigureWebTestClient} rather than this
* annotation.
* <p>
* When using JUnit 4, this annotation should be used in combination with
* {@code @RunWith(SpringRunner.class)}.
*
* @author Stephane Nicoll
* @author Artsiom Yudovin

3
module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTest.java

@ -83,9 +83,6 @@ import org.springframework.test.web.servlet.MockMvc; @@ -83,9 +83,6 @@ 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.
* <p>
* When using JUnit 4, this annotation should be used in combination with
* {@code @RunWith(SpringRunner.class)}.
*
* @author Phillip Webb
* @author Artsiom Yudovin

3
module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceClientTest.java

@ -48,9 +48,6 @@ import org.springframework.ws.test.client.MockWebServiceServer; @@ -48,9 +48,6 @@ 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)}.
* <p>
* When using JUnit 4, this annotation should be used in combination with
* {@code @RunWith(SpringRunner.class)}.
*
* @author Dmytro Nosan
* @since 2.3.0

Loading…
Cancel
Save