Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between mockito-core vs mockito-inline

In my project we already have mockito-core dependency. I want to stub static method for which I need to add mockito-inline dependency. So want to understand the difference between them. Can they co-exists?

like image 758
malav.parikh Avatar asked Feb 01 '21 01:02

malav.parikh


People also ask

Is mockito inline part of mockito-core?

0 it looks like mockito community has come up with mockito-inline for some experimental features like mocking final classes and methods, mocking static methods etc. So once they get feedback from community they will merge those changes in mockito-core and abolished mockito-inline.

What is the difference between mockito-core and mockito-all?

mockito-core only contains mockito classes, while mockito-all contain mockito classes as well as some dependencies, one of them being hamcrest. “mockito-all” distribution has been discontinued in Mockito 2.

What is the use of mockito inline?

With the inline mock maker, you can mock final classes and methods. You can do this using mock(SomeClazz. class) like you would with every other object you want to mock. In the example, we see it is the same as with non-final classes and methods.

What is the latest version of mockito?

Current version is 4. Mockito 3 does not introduce any breaking API changes, but now requires Java 8 over Java 6 for Mockito 2.


2 Answers

As per latest documentation of version 4.2.0 it looks like mockito community has come up with mockito-inline for some experimental features like mocking final classes and methods, mocking static methods etc. So once they get feedback from community they will merge those changes in mockito-core and abolished mockito-inline. Eventually it will be mockito-core only.

https://javadoc.io/doc/org.mockito/mockito-core/latest/org/mockito/Mockito.html#mockito-inline https://javadoc.io/doc/org.mockito/mockito-core/latest/org/mockito/Mockito.html#39

like image 130
Prakash Boda Avatar answered Sep 16 '22 21:09

Prakash Boda


At least with mockito 3.9 mockito-inline "depends on" mockito-core so...you can declare just mockito-inline...they're not mutually exclusive phew.

https://mvnrepository.com/artifact/org.mockito/mockito-inline/3.9.0

like image 38
rogerdpack Avatar answered Sep 19 '22 21:09

rogerdpack