Skip to content

Commit 81af0f2

Browse files
committed
Explicitly include JUnit 4 in test starter
Closes gh-16807
1 parent 7e118a0 commit 81af0f2

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed

spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6812,9 +6812,31 @@ Most developers use the `spring-boot-starter-test` "`Starter`", which imports bo
68126812
Boot test modules as well as JUnit Jupiter, AssertJ, Hamcrest, and a number of other
68136813
useful libraries.
68146814

6815-
TIP: The starter brings also the vintage engine so that you can run both JUnit 4 and Junit
6816-
5 tests. If you have migrated your tests to JUnit 5, consider excluding the vintage
6817-
engine.
6815+
[TIP]
6816+
====
6817+
The starter also brings the vintage engine and `junit:junit` so that you can run both
6818+
JUnit 4 and Junit 5 tests. If you have migrated your tests to JUnit 5, you should
6819+
exclude JUnit 4 support, as shown in the following example:
6820+
6821+
[source,xml,indent=0,subs="verbatim,quotes,attributes"]
6822+
----
6823+
<dependency>
6824+
<groupId>org.springframework.boot</groupId>
6825+
<artifactId>spring-boot-starter-test</artifactId>
6826+
<scope>test</scope>
6827+
<exclusions>
6828+
<exclusion>
6829+
<groupId>org.junit.vintage</groupId>
6830+
<artifactId>junit-vintage-engine</artifactId>
6831+
</exclusion>
6832+
<exclusion>
6833+
<groupId>junit</groupId>
6834+
<artifactId>junit</artifactId>
6835+
</exclusion>
6836+
</exclusions>
6837+
</dependency>
6838+
----
6839+
====
68186840

68196841

68206842

@@ -8891,7 +8913,8 @@ makes it possible to use `@BeforeClass` and `@AfterClass` annotations on non-sta
88918913
methods, which is a good fit for Kotlin.
88928914

88938915
JUnit 5 is the default and the vintage engine is provided for backward compatibility with
8894-
JUnit 4. If you don't use it, exclude `org.junit.vintange:junit-vintage-engine`. See the
8916+
JUnit 4. If you don't use it, exclude `org.junit.vintange:junit-vintage-engine` and
8917+
`junit:junit`. See the
88958918
{junit5-documentation}/#dependency-metadata-junit-jupiter-samples[JUnit 5 documentation]
88968919
for more details. You also need to
88978920
{junit5-documentation}/#writing-tests-test-instance-lifecycle-changing-default[switch test

spring-boot-project/spring-boot-starters/spring-boot-starter-test/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@
4343
<groupId>org.junit.vintage</groupId>
4444
<artifactId>junit-vintage-engine</artifactId>
4545
</dependency>
46+
<dependency>
47+
<groupId>junit</groupId>
48+
<artifactId>junit</artifactId>
49+
</dependency>
4650
<dependency>
4751
<groupId>org.mockito</groupId>
4852
<artifactId>mockito-junit-jupiter</artifactId>

spring-boot-samples/spring-boot-sample-junit-jupiter/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
<groupId>org.junit.vintage</groupId>
2929
<artifactId>junit-vintage-engine</artifactId>
3030
</exclusion>
31+
<exclusion>
32+
<groupId>junit</groupId>
33+
<artifactId>junit</artifactId>
34+
</exclusion>
3135
</exclusions>
3236
</dependency>
3337
</dependencies>

0 commit comments

Comments
 (0)