testcontainers-java icon indicating copy to clipboard operation
testcontainers-java copied to clipboard

Move junit-jupiter-api's dependency configuration to implementation

Open edysli opened this issue 3 years ago • 7 comments

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.

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 for recommended configurations.

Fixes: #5680

edysli avatar Oct 11 '22 19:10 edysli

I think the release notes should mention that projects using org.testcontainers:junit-jupiter should ensure they declare a direct dependency on org.junit.jupiter:junit-jupiter. How can we do this?

edysli avatar Oct 11 '22 19:10 edysli

thanks for submitting the PR @edysli ! If we decide to include it in the next release, we will include a note on the Release Notes.

Examples are failing because of missing the junit dependency :)

eddumelendez avatar Oct 11 '22 19:10 eddumelendez

Ironically, this CI failure illustrates exactly what happens to projects who don't declare a dependency on JUnit after the changes in this PR! :wink:

/home/runner/work/testcontainers-java/testcontainers-java/examples/neo4j-container/src/test/java/org/testcontainers/containers/Neo4jExampleTest.java:13: error: package org.junit.jupiter.api does not exist
import org.junit.jupiter.api.Test;
                            ^
/home/runner/work/testcontainers-java/testcontainers-java/examples/neo4j-container/src/test/java/org/testcontainers/containers/Neo4jExampleTest.java:34: error: cannot find symbol
    @Test
     ^
  symbol:   class Test
  location: class org.testcontainers.containers.Neo4jExampleTest

edysli avatar Oct 11 '22 19:10 edysli

Examples are failing because of missing the junit dependency :)

The remaining failures seem to have been caused by connectivity problems. Or did I miss a dependency somewhere @eddumelendez ?

edysli avatar Oct 11 '22 19:10 edysli

checks are passing now

eddumelendez avatar Oct 11 '22 20:10 eddumelendez

Just FYI @edysli, we plan to eventually merge this PR, since we think it is the right approach. However, because of its breaking nature, we want to include it in the 1.18.0 release (we don't have a strict SemVer policy, but it should not be in a patch release). Therefore, we don't merge it yet.

However, it added the hacktoberfest-accepted label, which counts towards your Hacktoberfest contributions, even without merging. Thanks for your work on this 🙌

kiview avatar Oct 19 '22 07:10 kiview

Thank you so much @kiview ! :grin: I totally understand this has to wait for the appropriate release.

edysli avatar Oct 19 '22 18:10 edysli

Thanks for your contribution, @edysli ! This is now merged in main branch and it will be part of the next release.

eddumelendez avatar Feb 16 '23 18:02 eddumelendez