mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-10-05 08:49:15 +00:00
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
This commit is contained in:
+1
-2
@@ -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.
|
||||
|
||||
+1
-1
@@ -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]
|
||||
|
||||
+1
-2
@@ -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:
|
||||
|
||||
+1
-1
@@ -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).
|
||||
|
||||
Reference in New Issue
Block a user