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

Mockito > 5.2.0 remove mockito-inline #410

Closed
Tracked by #295
yeikel opened this issue Sep 29, 2023 · 2 comments · Fixed by #439
Closed
Tracked by #295

Mockito > 5.2.0 remove mockito-inline #410

yeikel opened this issue Sep 29, 2023 · 2 comments · Fixed by #439
Labels
good first issue Good for newcomers recipe Recipe request

Comments

@yeikel
Copy link
Contributor

yeikel commented Sep 29, 2023

What problem are you trying to solve?

Starting with Mockito 5.3.0, the mockito-inline dependency is no longer published :

The inline mockmaker is the default mockmaker since 5.0.0 and we stopped publishing the artifact in 5.3.0. You can replace it with mockito-core to get the same outcome.

What precondition(s) should be checked before applying this recipe?

  • mockito-inline is a dependency

Describe the situation before applying the recipe

       <mockito.version>5.2.0</mockito.version>
<dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-inline</artifactId>
            <scope>test</scope>
        </dependency>

Describe the situation after applying the recipe

Mockito needs to be upgraded to > 5.2.0

       <mockito.version>5.5.0</mockito.version>
  1. If mockito-core is not part of the dependencies, then mockito-inline can be replaced with mockito-core
@@ -80,7 +80,7 @@
         </dependency>
         <dependency>
             <groupId>org.mockito</groupId>
-            <artifactId>mockito-inline</artifactId>
+            <artifactId>mockito-core</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>
  1. If Mockito-core is part of the dependency, then inline can be removed
-        <dependency>
-            <groupId>org.mockito</groupId>
-            <artifactId>mockito-inline</artifactId>
-            <scope>test</scope>
-        </dependency>

Additional context

mockito/mockito#3039
mockito/mockito#2877

@timtebeek
Copy link
Contributor

Thanks for the detailed report @yeikel ! I've added it to the list in

We can keep this one open, as it's easier to pick off individual items, or move your comment there, whichever you prefer.

@timtebeek timtebeek added recipe Recipe request good first issue Good for newcomers labels Nov 30, 2023
@IsaacHu
Copy link

IsaacHu commented Dec 8, 2023

Previously, we can use mockito-inline to mock the final class.
As [Mockito 5] switches the default mockmaker to mockito-inline, we removed the mockito-inline dependency, and then the mock of the final class failed.
Is there any solution for that?
coz mockito-inline no longer upgrades after 5.2.0, thx.

timtebeek added a commit that referenced this issue Dec 8, 2023
@timtebeek timtebeek linked a pull request Dec 8, 2023 that will close this issue
timtebeek added a commit that referenced this issue Dec 8, 2023
* Change Mockito inline to core in Mockito 5.x

Fixes #410

* Use orElseThrow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers recipe Recipe request
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants