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

JUnit4to5Migration excludes required dependency of testcontainers #429

Closed
simonzn opened this issue Nov 22, 2023 · 0 comments · Fixed by #430
Closed

JUnit4to5Migration excludes required dependency of testcontainers #429

simonzn opened this issue Nov 22, 2023 · 0 comments · Fixed by #430
Assignees
Labels
bug Something isn't working

Comments

@simonzn
Copy link
Contributor

simonzn commented Nov 22, 2023

org.testcontainers:testcontainers has a hard dependency on Junit4, see testcontainers/testcontainers-java#970

The JUnit4to5Migration adds an exclusion to the dependency, which breaks our builds. The issue above suggests crude workarounds like creating dummy classes in your project, but it seems cleaner to not add the exclusion in the first place.

As a workaround I added another recipe to our list which reverts the change; this has the (IMO cosmetic) issue that it creates an empty diff. Pull request is coming up for discussion.

I am aware this is really an issue with testcontainers and not so much with the JUnit4to5Migration recipe, but I think many projects could benefit from a workaround. This should be safe as well - once the issue in testcontainers is resolved it's a NOOP.

What version of OpenRewrite are you using?

I am using

  • OpenRewrite 8.9.0
  • rewrite-maven-plugin 5.14.0-SNAPSHOT
  • rewrite-testing-frameworks 2.1.0

How are you running OpenRewrite?

I am executing the JUnit4to5Migration recipe with the Maven command line.

What is the smallest, simplest way to reproduce the problem?

<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example.jackson</groupId>
    <artifactId>test-plugins</artifactId>
    <version>1.0.0</version>
    <dependencies>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>testcontainers</artifactId>
            <version>1.18.3</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>

What did you expect to see?

<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example.jackson</groupId>
    <artifactId>test-plugins</artifactId>
    <version>1.0.0</version>
    <dependencies>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>testcontainers</artifactId>
            <version>1.18.3</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>

What did you see instead?

<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example.jackson</groupId>
    <artifactId>test-plugins</artifactId>
    <version>1.0.0</version>
    <dependencies>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>testcontainers</artifactId>
            <version>1.18.3</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>junit</groupId>
                    <artifactId>junit</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>
</project>
@simonzn simonzn added the bug Something isn't working label Nov 22, 2023
simonzn added a commit to simonzn/rewrite-testing-frameworks that referenced this issue Nov 22, 2023
simonzn added a commit to simonzn/rewrite-testing-frameworks that referenced this issue Nov 22, 2023
timtebeek added a commit that referenced this issue Nov 22, 2023
* Adds test case for broken testcontainers dependency

Reproduces #429

* Remove JUnit4 exclusion from testcontainers dependency

Fixes #429

* Document why output is identical but still different

---------

Co-authored-by: e512271 <simon.zilliken@sbb.ch>
Co-authored-by: Tim te Beek <tim@moderne.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant