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
@ -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.
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.
@ -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.
@ -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:
@ -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:
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).