Upgrade to JUnit 5.8

Closes gh-27392
This commit is contained in:
Sam Brannen 2021-09-06 16:38:37 +02:00
parent db424d0bc5
commit 04e6b233ca
6 changed files with 29 additions and 33 deletions

View File

@ -36,7 +36,7 @@ configure(allprojects) { project ->
mavenBom "org.jetbrains.kotlin:kotlin-bom:1.5.30"
mavenBom "org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.5.2"
mavenBom "org.jetbrains.kotlinx:kotlinx-serialization-bom:1.2.2"
mavenBom "org.junit:junit-bom:5.7.2"
mavenBom "org.junit:junit-bom:5.8.0"
}
dependencies {
dependencySet(group: 'org.apache.logging.log4j', version: '2.14.1') {
@ -346,6 +346,7 @@ configure([rootProject] + javaProjects) { project ->
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter-api")
testImplementation("org.junit.jupiter:junit-jupiter-params")
testImplementation("org.junit.platform:junit-platform-suite-api")
testImplementation("org.mockito:mockito-core")
testImplementation("org.mockito:mockito-junit-jupiter")
testImplementation("io.mockk:mockk")
@ -353,6 +354,7 @@ configure([rootProject] + javaProjects) { project ->
// Pull in the latest JUnit 5 Launcher API to ensure proper support in IDEs.
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
testRuntimeOnly("org.junit.platform:junit-platform-suite-engine")
testRuntimeOnly("org.apache.logging.log4j:log4j-core")
testRuntimeOnly("org.apache.logging.log4j:log4j-slf4j-impl")
testRuntimeOnly("org.apache.logging.log4j:log4j-jul")
@ -381,7 +383,7 @@ configure([rootProject] + javaProjects) { project ->
"https://hc.apache.org/httpcomponents-client-5.1.x/current/httpclient5/apidocs/",
"https://projectreactor.io/docs/test/release/api/",
"https://junit.org/junit4/javadoc/4.13.2/",
"https://junit.org/junit5/docs/5.7.2/api/",
"https://junit.org/junit5/docs/5.8.0/api/",
"https://www.reactive-streams.org/reactive-streams-1.0.3-javadoc/",
"https://javadoc.io/static/io.rsocket/rsocket-core/1.1.1/",
"https://r2dbc.io/spec/0.8.5.RELEASE/api/"

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,12 +16,10 @@
package org.springframework.test.context;
import org.junit.platform.runner.JUnitPlatform;
import org.junit.platform.suite.api.ExcludeTags;
import org.junit.platform.suite.api.IncludeClassNamePatterns;
import org.junit.platform.suite.api.SelectPackages;
import org.junit.platform.suite.api.UseTechnicalNames;
import org.junit.runner.RunWith;
import org.junit.platform.suite.api.Suite;
/**
* JUnit Platform based test suite for tests that involve the Spring TestContext
@ -42,10 +40,9 @@ import org.junit.runner.RunWith;
* @author Sam Brannen
* @since 5.2
*/
@RunWith(JUnitPlatform.class)
@Suite
@SelectPackages("org.springframework.test.context")
@IncludeClassNamePatterns(".*Tests?$")
@ExcludeTags("failing-test-case")
@UseTechnicalNames
public class SpringTestContextFrameworkTestSuite {
class SpringTestContextFrameworkTestSuite {
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,12 +16,10 @@
package org.springframework.test.context.env;
import org.junit.platform.runner.JUnitPlatform;
import org.junit.platform.suite.api.IncludeClassNamePatterns;
import org.junit.platform.suite.api.IncludeEngines;
import org.junit.platform.suite.api.SelectPackages;
import org.junit.platform.suite.api.UseTechnicalNames;
import org.junit.runner.RunWith;
import org.junit.platform.suite.api.Suite;
import org.springframework.test.context.TestPropertySource;
@ -35,10 +33,9 @@ import org.springframework.test.context.TestPropertySource;
* @author Sam Brannen
* @since 5.2
*/
@RunWith(JUnitPlatform.class)
@Suite
@IncludeEngines("junit-jupiter")
@SelectPackages("org.springframework.test.context.env")
@IncludeClassNamePatterns(".*Tests$")
@UseTechnicalNames
public class TestPropertySourceTestSuite {
class TestPropertySourceTestSuite {
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,22 +16,17 @@
package org.springframework.test.context.junit;
import org.junit.platform.runner.JUnitPlatform;
import org.junit.platform.suite.api.ExcludeTags;
import org.junit.platform.suite.api.IncludeClassNamePatterns;
import org.junit.platform.suite.api.IncludeEngines;
import org.junit.platform.suite.api.SelectPackages;
import org.junit.platform.suite.api.UseTechnicalNames;
import org.junit.runner.RunWith;
import org.junit.platform.suite.api.Suite;
/**
* JUnit 4 based test suite for tests that involve the Spring TestContext
* JUnit Platform based test suite for tests that involve the Spring TestContext
* Framework and JUnit Jupiter (i.e., JUnit 5's programming model).
*
* <p>This class intentionally does not reside in the "jupiter" package
* so that the entire "jupiter" package can be excluded from the Gradle
* build. This class is therefore responsible for executing all JUnit
* Jupiter based tests in Spring's official test suite.
* <p><strong>This suite is only intended to be used manually within an IDE.</strong>
*
* <h3>Logging Configuration</h3>
*
@ -46,11 +41,10 @@ import org.junit.runner.RunWith;
* @author Sam Brannen
* @since 5.0
*/
@RunWith(JUnitPlatform.class)
@Suite
@IncludeEngines("junit-jupiter")
@SelectPackages("org.springframework.test.context.junit.jupiter")
@IncludeClassNamePatterns(".*Tests$")
@ExcludeTags("failing-test-case")
@UseTechnicalNames
public class SpringJUnitJupiterTestSuite {
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -77,7 +77,9 @@ public class ClientHttpConnectorTests {
server.shutdown();
}
@ParameterizedTest
// Do not auto-close arguments since HttpComponentsClientHttpConnector implements
// AutoCloseable and is shared between parameterized test invocations.
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("org.springframework.http.client.reactive.ClientHttpConnectorTests#methodsWithConnectors")
void basic(ClientHttpConnector connector, HttpMethod method) throws Exception {
URI uri = this.server.url("/").uri();
@ -198,10 +200,11 @@ public class ClientHttpConnectorTests {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@ParameterizedTest
// Do not auto-close arguments since HttpComponentsClientHttpConnector implements
// AutoCloseable and is shared between parameterized test invocations.
@ParameterizedTest(autoCloseArguments = false)
@MethodSource("org.springframework.http.client.reactive.ClientHttpConnectorTests#connectors")
public @interface ParameterizedConnectorTest {
}
static List<ClientHttpConnector> connectors() {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.web.servlet.handler;
import java.lang.annotation.ElementType;
@ -30,7 +31,9 @@ import java.lang.annotation.Target;
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@org.junit.jupiter.params.ParameterizedTest
// Do not auto-close arguments since ConfigurableWebApplicationContext implements
// AutoCloseable and is shared between parameterized test invocations.
@org.junit.jupiter.params.ParameterizedTest(autoCloseArguments = false)
@org.junit.jupiter.params.provider.MethodSource("pathPatternsArguments")
public @interface PathPatternsParameterizedTest {
}