Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lack of any*() static methods in Mockito 1. How to replace them reasonably?

Tags:

java

mockito

I have following jar in my project and I haven't seen any problems up to now:

mockito-all-1.10.19.jar

Due to project maturity I am not able to shift to newer Mockito version.

I am lacking any*() methods that I need: these are anyObject() and anyString(). These are static methods of Mockito 2.2.7 API. Are they missing in 1.10 version and subversions.

Source: https://static.javadoc.io/org.mockito/mockito-core/2.2.7/org/mockito/ArgumentMatchers.html#anyList()

How can I replace those methods - maybe there had been present some deprecated methods I could use?

like image 887
Sinny Avatar asked Oct 18 '25 01:10

Sinny


1 Answers

You should use:

any(Object.class);
any(String.class);

https://static.javadoc.io/org.mockito/mockito-core/1.10.19/org/mockito/Matchers.html#any(java.lang.Class)

Since Mockito extends Matchers you can get all the matchers with:

import static org.mockito.Mockito.*

... which is the style recommended by Mockito.

like image 93
slim Avatar answered Oct 20 '25 15:10

slim



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!