From fabc984e29529afa5ba19d285be92c2ffb000d02 Mon Sep 17 00:00:00 2001 From: Etienne Dysli Metref Date: Tue, 11 Oct 2022 21:02:22 +0200 Subject: [PATCH 1/3] Stop exposing junit-jupiter-api as transitive dependency Stop exposing `org.junit.jupiter:junit-jupiter-api` as a transitive dependency of `org.testcontainers:junit-jupiter` by including it using the `implementation` configuration instead of `api`. This should prevent conflicts with dependencies on JUnit 5 declared by users of `org.testcontainers:junit-jupiter`. Also use JUnit's BOM to simplify version management of all included JUnit artifacts. For running this module's tests, a `testImplementation` dependency on `org.junit.jupiter:junit-jupiter` is enough, as recommended in the [JUnit 5 User Guide][junit5guide]. Users of the `@Testcontainers` annotation must ensure their project direcly declares a test-scoped dependency on `org.junit.jupiter:junit-jupiter` in addition to `org.testcontainers:junit-jupiter`. See the [JUnit 5 User Guide][junit5guide] for recommended configurations. Fixes: #5680 [junit5guide]: https://junit.org/junit5/docs/current/user-guide/#running-tests-build "JUnit 5 User Guide: Build Support" --- modules/junit-jupiter/build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/junit-jupiter/build.gradle b/modules/junit-jupiter/build.gradle index e801e54ab83..68483059ae8 100644 --- a/modules/junit-jupiter/build.gradle +++ b/modules/junit-jupiter/build.gradle @@ -2,7 +2,8 @@ description = "Testcontainers :: JUnit Jupiter Extension" dependencies { api project(':testcontainers') - api 'org.junit.jupiter:junit-jupiter-api:5.9.1' + implementation platform('org.junit:junit-bom:5.9.1') + implementation 'org.junit.jupiter:junit-jupiter-api' testImplementation project(':mysql') testImplementation project(':postgresql') @@ -13,11 +14,10 @@ dependencies { exclude(module: 'hamcrest-core') } testImplementation 'org.assertj:assertj-core:3.23.1' - testImplementation 'org.junit.jupiter:junit-jupiter-params:5.9.1' + testImplementation 'org.junit.jupiter:junit-jupiter' testRuntimeOnly 'org.postgresql:postgresql:42.5.0' testRuntimeOnly 'mysql:mysql-connector-java:8.0.30' - testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.1' } test { From a75761f1f98fecd8c0dc716bcabd4f953150c2fe Mon Sep 17 00:00:00 2001 From: Etienne Dysli Metref Date: Tue, 11 Oct 2022 21:31:51 +0200 Subject: [PATCH 2/3] Fix Neo4j container example Add a direct dependency on `org.junit.jupiter:junit-jupiter:5.9.1` to stop relying on it being transitively provided by `org.testcontainers:junit-jupiter`. --- examples/neo4j-container/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/neo4j-container/build.gradle b/examples/neo4j-container/build.gradle index e7e42ff00bd..4af0d86ed3c 100644 --- a/examples/neo4j-container/build.gradle +++ b/examples/neo4j-container/build.gradle @@ -11,4 +11,5 @@ dependencies { testImplementation 'org.neo4j.driver:neo4j-java-driver:4.4.9' testImplementation 'org.testcontainers:neo4j' testImplementation 'org.testcontainers:junit-jupiter' + testImplementation 'org.junit.jupiter:junit-jupiter:5.9.1' } From 554339e542cea337fdba5ba2ec2857b52e359785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Thu, 16 Feb 2023 11:55:03 -0600 Subject: [PATCH 3/3] Remove empty line --- modules/junit-jupiter/build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/junit-jupiter/build.gradle b/modules/junit-jupiter/build.gradle index bff2306b22d..315b3c534d1 100644 --- a/modules/junit-jupiter/build.gradle +++ b/modules/junit-jupiter/build.gradle @@ -13,7 +13,6 @@ dependencies { testImplementation ('org.mockito:mockito-core:4.11.0') { exclude(module: 'hamcrest-core') } - testImplementation 'org.assertj:assertj-core:3.24.2' testImplementation 'org.junit.jupiter:junit-jupiter'