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 uses old mockito-junit-jupiter version #541

Closed
Saturas89 opened this issue Jul 2, 2024 · 4 comments
Closed

JUnit4to5Migration uses old mockito-junit-jupiter version #541

Saturas89 opened this issue Jul 2, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@Saturas89
Copy link

The added dependency from mockito-junit-jupiter could be upgraded to a newer one.

How are you running OpenRewrite?

I am using the Maven plugin, and my project is a single module project.

<plugin>
  <groupId>org.openrewrite.maven</groupId>
  <artifactId>rewrite-maven-plugin</artifactId>
  <version>5.34.1</version>
  <configuration>
   <activeRecipes>
       <recipe>org.openrewrite.java.testing.junit5.JUnit4to5Migration</recipe>
    </activeRecipes>
   </configuration>
         <dependencies>
          <dependency>
           <groupId>org.openrewrite.recipe</groupId>
           <artifactId>rewrite-testing-frameworks</artifactId>
            <version>2.12.2</version>
           </dependency>
          </dependencies>
</plugin>

What did you expect to see?

      <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-junit-jupiter</artifactId>
            <version>5.12.0</version>
            <scope>test</scope>
        </dependency>

What did you see instead?

      <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-junit-jupiter</artifactId>
            <version>3.12.4</version>
            <scope>test</scope>
        </dependency>
@Saturas89 Saturas89 added the bug Something isn't working label Jul 2, 2024
@timtebeek
Copy link
Contributor

Hi! Thanks for the report; looks like we indeed bump to 3.x in two locations:

Once as part of org.openrewrite.java.testing.junit5.JUnit4to5Migration

- org.openrewrite.java.dependencies.AddDependency:
groupId: org.mockito
artifactId: mockito-junit-jupiter
version: 3.x
onlyIfUsing: org.mockito..*
acceptTransitive: true
scope: test

And once more via org.openrewrite.java.testing.mockito.Mockito1to3Migration

- org.openrewrite.java.dependencies.AddDependency:
groupId: org.mockito
artifactId: mockito-junit-jupiter
version: 3.x
onlyIfUsing: org.mockito.junit.jupiter.MockitoExtension
acceptTransitive: true

If you were to execute either of these recipes I think you should be upgraded to 4.x or 5.x

  • org.openrewrite.java.testing.mockito.Mockito1to4Migration
  • org.openrewrite.java.testing.mockito.Mockito1to5Migration

As per Mockito's 5.x release notes it seems that 5.x requires Java 11, whereas 4.x still works with Java 8. As our JUnit4to5Migration is intended to get you onto JUnit 5 without raising the required Java version just yet, I suppose we could only bump you up to Mockito 4.x, or make that conditional on the Java version in use.

In any case I believe we could fix all the above using only declarative Yaml recipes and preconditions. Would you want to help out making that a reality?

@MBoegers
Copy link
Collaborator

MBoegers commented Jul 2, 2024

There is at least one more location in the recipeDependencies within

parserClasspath("org.mockito:mockito-junit-jupiter:3.+")

@Saturas89
Copy link
Author

In any case I believe we could fix all the above using only declarative Yaml recipes and preconditions. Would you want to help out making that a reality?

unfortunately i am so busy with updating many projects, where i am very grateful for rewrite. i try to open up feedback & issues as best as possible. i have helped myself by pulling the version of mockito-junit-jupiter through a parent pom.

@timtebeek
Copy link
Contributor

All good; as per the above I've for now changed our JUnit 5 upgrade to pull in Mockito 4.x via f1fda26
Thanks for pointing this out!

@timtebeek timtebeek self-assigned this Jul 8, 2024
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

No branches or pull requests

3 participants