Skip to content

implementation scope for junit4 #10283

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

panchenko
Copy link

@panchenko panchenko commented May 30, 2025

Currently junit4 has api scope, so it will be visible outside
And then projects using junit 5 will see 2 @Test annotations, which can cause problems - #970

After this change

  • if project uses existing classes, then no changes would be needed. Source and binary compatible.
  • if project extends classes which implement TestRule - then it would need compile/test dependency on junit4

@panchenko panchenko changed the title no api scope for junit4 implementation/runtime scope for junit4 Jun 2, 2025
@panchenko panchenko changed the title implementation/runtime scope for junit4 implementation scope for junit4 Jun 2, 2025
@panchenko panchenko marked this pull request as ready for review June 2, 2025 13:48
@panchenko panchenko requested a review from a team as a code owner June 2, 2025 13:48
@eddumelendez
Copy link
Member

Hi, thanks for your contribution. Have you tested the changes?

Previous to this changes, org.testcontainers:junit-jupiter has only one dependency

<dependencies>
    <dependency>
      <groupId>org.testcontainers</groupId>
      <artifactId>testcontainers</artifactId>
      <version>1.21.1</version>
      <scope>compile</scope>
    </dependency>
</dependencies>

Now, it has

<dependencies>
    <dependency>
      <groupId>org.testcontainers</groupId>
      <artifactId>testcontainers</artifactId>
      <version>1.21.2-SNAPSHOT</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.junit</groupId>
      <artifactId>junit-bom</artifactId>
      <version>5.10.3</version>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-api</artifactId>
      <version>5.10.3</version>
      <scope>runtime</scope>
    </dependency>
</dependencies>

which fails because of org.junit:junit-bom.

Also, org.junit.Test annotation is still visible.

I've tried different approaches in the past and it was not easy to remove the dependency without breaking changes.

@panchenko
Copy link
Author

Hi,
I have checked some modules, but not all.

I think it would be more straightforward to use standard gradle way of building pom.xml instead of manual operations (not sure why it's like that currently), then we can have more control. Let me try that first.

Where can you see the org.junit.Test annotation now? It's only in core as a runtime dependency. In junit-jupiter it's added a compile dependency, but won't be visible to users of junit-jupiter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment