From 81af0f2fa672d962d4c8569b6b7ee802008717c2 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 9 May 2019 14:54:13 +0200 Subject: [PATCH] Explicitly include JUnit 4 in test starter Closes gh-16807 --- .../main/asciidoc/spring-boot-features.adoc | 31 ++++++++++++++++--- .../spring-boot-starter-test/pom.xml | 4 +++ .../spring-boot-sample-junit-jupiter/pom.xml | 4 +++ 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index 23ea209ec1..9426069481 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -6812,9 +6812,31 @@ Most developers use the `spring-boot-starter-test` "`Starter`", which imports bo Boot test modules as well as JUnit Jupiter, AssertJ, Hamcrest, and a number of other useful libraries. -TIP: The starter brings also the vintage engine so that you can run both JUnit 4 and Junit -5 tests. If you have migrated your tests to JUnit 5, consider excluding the vintage -engine. +[TIP] +==== +The starter also brings the vintage engine and `junit:junit` so that you can run both +JUnit 4 and Junit 5 tests. If you have migrated your tests to JUnit 5, you should +exclude JUnit 4 support, as shown in the following example: + +[source,xml,indent=0,subs="verbatim,quotes,attributes"] +---- + + org.springframework.boot + spring-boot-starter-test + test + + + org.junit.vintage + junit-vintage-engine + + + junit + junit + + + +---- +==== @@ -8891,7 +8913,8 @@ makes it possible to use `@BeforeClass` and `@AfterClass` annotations on non-sta methods, which is a good fit for Kotlin. JUnit 5 is the default and the vintage engine is provided for backward compatibility with -JUnit 4. If you don't use it, exclude `org.junit.vintange:junit-vintage-engine`. See the +JUnit 4. If you don't use it, exclude `org.junit.vintange:junit-vintage-engine` and +`junit:junit`. See the {junit5-documentation}/#dependency-metadata-junit-jupiter-samples[JUnit 5 documentation] for more details. You also need to {junit5-documentation}/#writing-tests-test-instance-lifecycle-changing-default[switch test diff --git a/spring-boot-project/spring-boot-starters/spring-boot-starter-test/pom.xml b/spring-boot-project/spring-boot-starters/spring-boot-starter-test/pom.xml index 5907752179..b0490ee0ed 100644 --- a/spring-boot-project/spring-boot-starters/spring-boot-starter-test/pom.xml +++ b/spring-boot-project/spring-boot-starters/spring-boot-starter-test/pom.xml @@ -43,6 +43,10 @@ org.junit.vintage junit-vintage-engine + + junit + junit + org.mockito mockito-junit-jupiter diff --git a/spring-boot-samples/spring-boot-sample-junit-jupiter/pom.xml b/spring-boot-samples/spring-boot-sample-junit-jupiter/pom.xml index 15eb042064..d0a350b94f 100644 --- a/spring-boot-samples/spring-boot-sample-junit-jupiter/pom.xml +++ b/spring-boot-samples/spring-boot-sample-junit-jupiter/pom.xml @@ -28,6 +28,10 @@ org.junit.vintage junit-vintage-engine + + junit + junit +