Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8274274: Update JUnit to version 5.8.1 #633

Closed
wants to merge 12 commits into from
@@ -1944,7 +1944,18 @@ allprojects {
// By default all of our projects require junit for testing so we can just
// setup this dependency here.
dependencies {
testImplementation group: "junit", name: "junit", version: "4.8.2"
testImplementation group: "junit", name: "junit", version: "4.13.2"
testImplementation group: "org.hamcrest", name: "hamcrest-core", version: "1.3"
testImplementation group: "org.junit.jupiter", name: "junit-jupiter", version: "5.8.1"
This conversation was marked as resolved by hjohn

This comment has been minimized.

@kevinrushforth

kevinrushforth Nov 20, 2021
Member

We need an explicit list of dependencies here, rather than relying on the maven pom files to bring them in. This is needed for our internal builds where we only host a snapshot of the jar files and not the pom files. Also, it better documents the dependencies. After adding the following to my local build, it all works now:

testImplementation group: "org.junit.jupiter", name: "junit-jupiter-api", version: "5.8.1"
testImplementation group: "org.hamcrest", name: "hamcrest-core", version: "1.3"
testRuntimeOnly group: "org.junit.jupiter", name: "junit-jupiter-engine", version: "5.8.1"
testRuntimeOnly group: "org.junit.jupiter", name: "junit-jupiter-params", version: "5.8.1"
testRuntimeOnly group: "org.junit.platform", name: "junit-platform-commons", version: "1.8.1"
testRuntimeOnly group: "org.junit.platform", name: "junit-platform-engine", version: "1.8.1"
testRuntimeOnly group: "org.apiguardian", name: "apiguardian-api", version: "1.1.2"
testRuntimeOnly group: "org.opentest4j", name: "opentest4j", version: "1.2.0"

This comment has been minimized.

@hjohn

hjohn Nov 21, 2021
Author Collaborator

I've added the dependencies you listed here.

testImplementation group: "org.junit.jupiter", name: "junit-jupiter-api", version: "5.8.1"
testRuntimeOnly group: "org.apiguardian", name: "apiguardian-api", version: "1.1.2"
testRuntimeOnly group: "org.junit.jupiter", name: "junit-jupiter-engine", version: "5.8.1"
testRuntimeOnly group: "org.junit.jupiter", name: "junit-jupiter-params", version: "5.8.1"
testRuntimeOnly group: "org.junit.platform", name: "junit-platform-commons", version: "1.8.1"
testRuntimeOnly group: "org.junit.platform", name: "junit-platform-engine", version: "1.8.1"
testRuntimeOnly group: "org.junit.vintage", name: "junit-vintage-engine", version: "5.8.1"
testRuntimeOnly group: "org.opentest4j", name: "opentest4j", version: "1.2.0"

if (BUILD_CLOSED && DO_JCOV) {
testImplementation name: "jcov"
}
@@ -1959,6 +1970,8 @@ allprojects {
// Java 7 but when we switch to 8 this will be needed, and probably again when
// we start building with Java 9.
test {
useJUnitPlatform();

executable = JAVA;
enableAssertions = true;
testLogging.exceptionFormat = "full";
@@ -2033,7 +2046,6 @@ project(":base") {
}

dependencies {
testImplementation group: "junit", name: "junit", version: "4.8.2"
testImplementation sourceSets.main.output
testImplementation sourceSets.shims.output
}
@@ -2109,8 +2121,6 @@ project(":graphics") {
}

dependencies {
stubImplementation group: "junit", name: "junit", version: "4.8.2"

antlr group: "org.antlr", name: "antlr4", version: "4.7.2", classifier: "complete"
testImplementation project(":base").sourceSets.test.output
implementation project(':base')
@@ -74,7 +74,8 @@ repositories {
}

dependencies {
testImplementation group: "junit", name: "junit", version: "4.8.2"
testImplementation group: "junit", name: "junit", version: "4.13.2"
testImplementation group: "org.hamcrest", name: "hamcrest-core", version: "1.3"
}

// At the moment the ASM library shipped with Gradle that is used to
@@ -111,12 +111,12 @@
<sha256 value="c80313e6c26c0b9e0c241504718e2d8bbc2798b73429933adf03fdc6d84f0e70" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="junit" name="junit" version="4.8.2">
<artifact name="junit-4.8.2.jar">
<sha256 value="a2aa2c3bb2b72da76c3e6a71531f1eefdc350494819baf2b1d80d7146e020f9e" origin="Generated by Gradle"/>
<component group="junit" name="junit" version="4.13.2">
<artifact name="junit-4.13.2.jar">
<sha256 value="8e495b634469d64fb8acfa3495a065cbacc8a0fff55ce1e31007be4c16dc57d3" origin="Generated by Gradle"/>
</artifact>
<artifact name="junit-4.8.2.pom">
<sha256 value="df39d34d1f5830b2d8a92790c66b5798358b0b3e01452dc85b3722a881ad923e" origin="Generated by Gradle"/>
<artifact name="junit-4.13.2.pom">
<sha256 value="569b6977ee4603c965c1c46c3058fa6e969291b0160eb6964dd092cd89eadd94" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="net.java" name="jvnet-parent" version="3">
@@ -229,6 +229,14 @@
<sha256 value="3a2837580ca76af36af7dfe2dc1d334fc6ff5f26d10f24899db7770ad7cfd9fe" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.apiguardian" name="apiguardian-api" version="1.1.2">
<artifact name="apiguardian-api-1.1.2.jar">
<sha256 value="b509448ac506d607319f182537f0b35d71007582ec741832a1f111e5b5b70b38" origin="Generated by Gradle"/>
</artifact>
<artifact name="apiguardian-api-1.1.2.module">
<sha256 value="e08028131375b357d1d28734e9a4fb4216da84b240641cb3ef7e7c7d628223fc" origin="Generated by Gradle"/>
</artifact>
</component>
This conversation was marked as resolved by hjohn
Comment on lines +232 to +239

This comment has been minimized.

@kevinrushforth

kevinrushforth Sep 24, 2021
Member

Is apiguardian actually required in order to support JUnit 5? If not, this should be reverted. If so, that's another third-party dependency we would need to get approval for.

This comment has been minimized.

@hjohn

hjohn Sep 24, 2021
Author Collaborator

It's an annotation used within JUnit code, it might be possible to block this one, I will see how to do this in Gradle syntax.

This is the whole transitive tree it pulls in:
image

This comment has been minimized.

@hjohn

hjohn Sep 24, 2021
Author Collaborator

Blocked this one without ill effects, tests still run.

<component group="org.glassfish" name="javax.json" version="1.0.4">
<artifact name="javax.json-1.0.4.jar">
<sha256 value="0e1dec40a1ede965941251eda968aeee052cc4f50378bc316cc48e8159bdbeb4" origin="Generated by Gradle"/>
@@ -242,6 +250,91 @@
<sha256 value="6d7c68423115f921718d944f859924b4c685217ec03a49f70455a8b2caa972e6" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.hamcrest" name="hamcrest-core" version="1.3">
<artifact name="hamcrest-core-1.3.jar">
<sha256 value="66fdef91e9739348df7a096aa384a5685f4e875584cce89386a7a47251c4d8e9" origin="Generated by Gradle"/>
</artifact>
<artifact name="hamcrest-core-1.3.pom">
<sha256 value="fde386a7905173a1b103de6ab820727584b50d0e32282e2797787c20a64ffa93" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.hamcrest" name="hamcrest-parent" version="1.3">
<artifact name="hamcrest-parent-1.3.pom">
<sha256 value="6d535f94efb663bdb682c9f27a50335394688009642ba7a9677504bc1be4129b" origin="Generated by Gradle"/>
</artifact>
</component>
This conversation was marked as resolved by hjohn
Comment on lines +253 to +265

This comment has been minimized.

@kevinrushforth

kevinrushforth Sep 24, 2021
Member

Is hamcrest actually required in order to support JUnit 5? If not, this should be reverted. If so, that's another third-party dependency we would need to get approval for.

This comment has been minimized.

@hjohn

hjohn Sep 24, 2021
Author Collaborator

I will try block this and get back to you.

This comment has been minimized.

@hjohn

hjohn Sep 24, 2021
Author Collaborator

Hamcrest could be blocked, tests still run.

This comment has been minimized.

@kevinrushforth

kevinrushforth Nov 11, 2021
Member

As it turns out, hamcrest does not need to be blocked, so you can restore it if it is easier. I'll leave it up to you.

<component group="org.junit" name="junit-bom" version="5.8.1">
<artifact name="junit-bom-5.8.1.pom">
<sha256 value="ef7dc47f8e4a16864f4779728e87ed78539819e4fb892768a9da6b8ef903f863" origin="Generated by Gradle"/>
</artifact>
<artifact name="junit-bom-5.8.1.module">
<sha256 value="6b82cba52a134b13c1982f0cf9622c6d485371d40b989246f3124e3b0a5b1854" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.junit.jupiter" name="junit-jupiter" version="5.8.1">
<artifact name="junit-jupiter-5.8.1.jar">
<sha256 value="8f1049ee24b34a10b60cd810048099f781c2658cde2181e831496ab30a982985" origin="Generated by Gradle"/>
</artifact>
<artifact name="junit-jupiter-5.8.1.module">
<sha256 value="2e34ba4c858c38cd0a365afffecc932a7196ce9385e2eb5405942e581c15ff5c" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.junit.jupiter" name="junit-jupiter-api" version="5.8.1">
<artifact name="junit-jupiter-api-5.8.1.jar">
<sha256 value="ce3374a7efba605e2d2b69a3fef90134032bab3ecc3ed8579a4871b1c2c4729c" origin="Generated by Gradle"/>
</artifact>
<artifact name="junit-jupiter-api-5.8.1.module">
<sha256 value="0d69dbc236b7dcaab4ca7369aa560e9b0a9bbef7f958882ffb48533cbba7c09d" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.junit.jupiter" name="junit-jupiter-engine" version="5.8.1">
<artifact name="junit-jupiter-engine-5.8.1.jar">
<sha256 value="4689bc902255a19fe98277683ba3231c094d107c54c8d35f2b6f9c97d226418e" origin="Generated by Gradle"/>
</artifact>
<artifact name="junit-jupiter-engine-5.8.1.module">
<sha256 value="68790fec33f97b0ec840cf47ac40ee0c72e056f122ca0f3c6646743349937699" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.junit.jupiter" name="junit-jupiter-params" version="5.8.1">
<artifact name="junit-jupiter-params-5.8.1.jar">
<sha256 value="389b8d13a8d8872fcbd4f0eba7b2c46afc628419f9a1b2a3a9f93241a06a7218" origin="Generated by Gradle"/>
</artifact>
<artifact name="junit-jupiter-params-5.8.1.module">
<sha256 value="124d603c6d8033366d8ca471636b446e38b9cc1bd010f329542358187afa865e" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.junit.platform" name="junit-platform-commons" version="1.8.1">
<artifact name="junit-platform-commons-1.8.1.jar">
<sha256 value="fa4fa68c8bd54dd0cb49c3fcbe9b2e42f4da6bedbe7e7ccf2a05f1a1e609b593" origin="Generated by Gradle"/>
</artifact>
<artifact name="junit-platform-commons-1.8.1.module">
<sha256 value="698fd0541acb7effc6659848fd0c7dd5010a49f15f0c1cba43e535807f90f66b" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.junit.platform" name="junit-platform-engine" version="1.8.1">
<artifact name="junit-platform-engine-1.8.1.jar">
<sha256 value="702868ed7e86b9b4672ede0f1e185e905baca9afab57746a7c650be3c7bca047" origin="Generated by Gradle"/>
</artifact>
<artifact name="junit-platform-engine-1.8.1.module">
<sha256 value="d9f420a64539a3edf60f80df0c6fd722b750725744c79ca40f7d25ae56ca4ba4" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.junit.vintage" name="junit-vintage-engine" version="5.8.1">
<artifact name="junit-vintage-engine-5.8.1.jar">
<sha256 value="176b53cd1bdbf9233e96c8b0c7a9e5b864282fbbdeba43b5ceafdedb29a49156" origin="Generated by Gradle"/>
</artifact>
<artifact name="junit-vintage-engine-5.8.1.module">
<sha256 value="9ce9fa2e4ee6a740d610102530462a71ce0fa9d2f1418522e4b2bdb6072f679a" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.opentest4j" name="opentest4j" version="1.2.0">
<artifact name="opentest4j-1.2.0.jar">
<sha256 value="58812de60898d976fb81ef3b62da05c6604c18fd4a249f5044282479fc286af2" origin="Generated by Gradle"/>
</artifact>
<artifact name="opentest4j-1.2.0.pom">
<sha256 value="a96e671816c1ff8803bdec74c9241f025bdfb277da5d2b4ee02266405936f994" origin="Generated by Gradle"/>
</artifact>
</component>
This conversation was marked as resolved by hjohn
Comment on lines +330 to +337

This comment has been minimized.

@kevinrushforth

kevinrushforth Sep 24, 2021
Member

Is opentest4j actually required in order to support JUnit 5? If not, this should be reverted. If so, that's another third-party dependency we would need to get approval for.

This comment has been minimized.

@hjohn

hjohn Sep 24, 2021
Author Collaborator

Will try block

This comment has been minimized.

@hjohn

hjohn Sep 24, 2021
Author Collaborator

I couldn't block opentest4j. Apparently this is a project that harmonizes the exceptions thrown by various test frameworks (not just JUnit 5) and JUnit 5 depends on it for the exceptions it uses to signal test failures and other error conditions. It is a fairly small project (6 classes only) licensed under the Apache 2.0 license: https://github.com/ota4j-team/opentest4j

This comment has been minimized.

@kevinrushforth

kevinrushforth Nov 11, 2021
Member

Since we only use JUnit for build / test, and don't directly depend on opentest4j, this is not a problem.

<component group="org.sonatype.oss" name="oss-parent" version="7">
<artifact name="oss-parent-7.pom">
<sha256 value="b51f8867c92b6a722499557fc3a1fdea77bdf9ef574722fe90ce436a29559454" origin="Generated by Gradle"/>
@@ -20,6 +20,11 @@
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5">
<attributes>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="module" value="true"/>
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

package test;
This conversation was marked as resolved by hjohn

This comment has been minimized.

@kevinrushforth

kevinrushforth Sep 24, 2021
Member

This needs a copyright header block.

This comment has been minimized.

@hjohn

hjohn Sep 24, 2021
Author Collaborator

Added


import static org.junit.jupiter.api.Assertions.assertNotNull;

import org.junit.jupiter.api.Test;

public class JUnit5Test {

@Test
void junit5ShouldWork() {
System.err.println("JUnit 5 test working!");
This conversation was marked as resolved by hjohn

This comment has been minimized.

@kevinrushforth

kevinrushforth Nov 20, 2021
Member

I recommend adding a trivial assert here (e.g., assertNotNull(this) or similar).

This comment has been minimized.

@hjohn

hjohn Nov 21, 2021
Author Collaborator

Added

assertNotNull(this);
}
}