org.mockito
public class ArgumentMatchers extends Object
AdditionalMatchers
.
Mockito
extends ArgumentMatchers so to get access to all matchers just import Mockito class statically.
//stubbing using anyInt() argument matcher
when(mockedList.get(anyInt())).thenReturn("element");
//following prints "element"
System.out.println(mockedList.get(999));
//you can also verify using argument matcher
verify(mockedList).get(anyInt());
Since Mockito any(Class)
and anyInt
family matchers perform a type check, thus they won't
match null
arguments. Instead use the isNull
matcher.
// stubbing using anyBoolean() argument matcher
when(mock.dryRun(anyBoolean())).thenReturn("state");
// below the stub won't match, and won't return "state"
mock.dryRun(null);
// either change the stub
when(mock.dryRun(isNull())).thenReturn("state");
mock.dryRun(null); // ok
// or fix the code ;)
when(mock.dryRun(anyBoolean())).thenReturn("state");
mock.dryRun(true); // ok
The same apply for verification.
Scroll down to see all methods - full list of matchers.
Warning:
If you are using argument matchers, all arguments have to be provided by matchers.
E.g: (example shows verification but the same applies to stubbing):
verify(mock).someMethod(anyInt(), anyString(), eq("third argument"));
//above is correct - eq() is also an argument matcher
verify(mock).someMethod(anyInt(), anyString(), "third argument");
//above is incorrect - exception will be thrown because third argument is given without argument matcher.
Matcher methods like anyObject()
, eq()
do not return matchers.
Internally, they record a matcher on a stack and return a dummy value (usually null).
This implementation is due to static type safety imposed by java compiler.
The consequence is that you cannot use anyObject()
, eq()
methods outside of verified/stubbed method.
The class AdditionalMatchers
offers rarely used matchers, although they can be useful, when
it is useful to combine multiple matchers or when it is useful to negate a matcher necessary.
It is important to understand the use cases and available options for dealing with non-trivial arguments
before implementing custom argument matchers. This way, you can select the best possible approach
for given scenario and produce highest quality test (clean and maintainable).
Please read on in the javadoc for ArgumentMatcher
to learn about approaches and see the examples.
AdditionalMatchers
Constructor and Description |
---|
ArgumentMatchers() |
Modifier and Type | Method and Description |
---|---|
static <T> T |
any()
Matches anything, including nulls and varargs.
|
static <T> T |
any(Class<T> type)
Matches any object of given type, excluding nulls.
|
static boolean |
anyBoolean()
Any
boolean or non-null Boolean |
static byte |
anyByte()
Any
byte or non-null Byte . |
static char |
anyChar()
Any
char or non-null Character . |
static <T> Collection<T> |
anyCollection()
Any non-null
Collection . |
static <T> Collection<T> |
anyCollectionOf(Class<T> clazz)
Deprecated.
With Java 8 this method will be removed in Mockito 3.0. This method is only used for generic
friendliness to avoid casting, this is not anymore needed in Java 8.
|
static double |
anyDouble()
Any
double or non-null Double . |
static float |
anyFloat()
Any
float or non-null Float . |
static int |
anyInt()
Any int or non-null
Integer . |
static <T> Iterable<T> |
anyIterable()
Any non-null
Iterable . |
static <T> Iterable<T> |
anyIterableOf(Class<T> clazz)
Deprecated.
With Java 8 this method will be removed in Mockito 3.0. This method is only used for generic
friendliness to avoid casting, this is not anymore needed in Java 8.
|
static <T> List<T> |
anyList()
Any non-null
List . |
static <T> List<T> |
anyListOf(Class<T> clazz)
Deprecated.
With Java 8 this method will be removed in Mockito 3.0. This method is only used for generic
friendliness to avoid casting, this is not anymore needed in Java 8.
|
static long |
anyLong()
Any
long or non-null Long . |
static <K,V> Map<K,V> |
anyMap()
Any non-null
Map . |
static <K,V> Map<K,V> |
anyMapOf(Class<K> keyClazz,
Class<V> valueClazz)
Deprecated.
With Java 8 this method will be removed in Mockito 3.0. This method is only used for generic
friendliness to avoid casting, this is not anymore needed in Java 8.
|
static <T> T |
anyObject()
Deprecated.
This will be removed in Mockito 3.0 (which will be java 8 only)
|
static <T> Set<T> |
anySet()
Any non-null
Set . |
static <T> Set<T> |
anySetOf(Class<T> clazz)
Deprecated.
With Java 8 this method will be removed in Mockito 3.0. This method is only used for generic
friendliness to avoid casting, this is not anymore needed in Java 8.
|
static short |
anyShort()
Any
short or non-null Short . |
static String |
anyString()
Any non-null
String |
static <T> T |
anyVararg()
Deprecated.
as of 2.1.0 use
any() |
static <T> T |
argThat(ArgumentMatcher<T> matcher)
Allows creating custom argument matchers.
|
static boolean |
booleanThat(ArgumentMatcher<Boolean> matcher)
Allows creating custom
boolean argument matchers. |
static byte |
byteThat(ArgumentMatcher<Byte> matcher)
Allows creating custom
byte argument matchers. |
static char |
charThat(ArgumentMatcher<Character> matcher)
Allows creating custom
char argument matchers. |
static String |
contains(String substring)
String argument that contains the given substring. |
static double |
doubleThat(ArgumentMatcher<Double> matcher)
Allows creating custom
double argument matchers. |
static String |
endsWith(String suffix)
String argument that ends with the given suffix. |
static boolean |
eq(boolean value)
boolean argument that is equal to the given value. |
static byte |
eq(byte value)
byte argument that is equal to the given value. |
static char |
eq(char value)
char argument that is equal to the given value. |
static double |
eq(double value)
double argument that is equal to the given value. |
static float |
eq(float value)
float argument that is equal to the given value. |
static int |
eq(int value)
int argument that is equal to the given value. |
static long |
eq(long value)
long argument that is equal to the given value. |
static short |
eq(short value)
short argument that is equal to the given value. |
static <T> T |
eq(T value)
Object argument that is equal to the given value.
|
static float |
floatThat(ArgumentMatcher<Float> matcher)
Allows creating custom
float argument matchers. |
static int |
intThat(ArgumentMatcher<Integer> matcher)
Allows creating custom
int argument matchers. |
static <T> T |
isA(Class<T> type)
Object argument that implements the given class. |
static <T> T |
isNotNull()
Not
null argument. |
static <T> T |
isNotNull(Class<T> clazz)
Deprecated.
With Java 8 this method will be removed in Mockito 3.0. This method is only used for generic
friendliness to avoid casting, this is not anymore needed in Java 8.
|
static <T> T |
isNull()
null argument. |
static <T> T |
isNull(Class<T> clazz)
Deprecated.
With Java 8 this method will be removed in Mockito 3.0. This method is only used for generic
friendliness to avoid casting, this is not anymore needed in Java 8.
|
static long |
longThat(ArgumentMatcher<Long> matcher)
Allows creating custom
long argument matchers. |
static String |
matches(Pattern pattern)
Pattern argument that matches the given regular expression. |
static String |
matches(String regex)
String argument that matches the given regular expression. |
static <T> T |
notNull()
Not
null argument. |
static <T> T |
notNull(Class<T> clazz)
Deprecated.
With Java 8 this method will be removed in Mockito 3.0. This method is only used for generic
friendliness to avoid casting, this is not anymore needed in Java 8.
|
static <T> T |
nullable(Class<T> clazz)
Argument that is either
null or of the given type. |
static <T> T |
refEq(T value,
String... excludeFields)
Object argument that is reflection-equal to the given value with support for excluding
selected fields from a class.
|
static <T> T |
same(T value)
Object argument that is the same as the given value.
|
static short |
shortThat(ArgumentMatcher<Short> matcher)
Allows creating custom
short argument matchers. |
static String |
startsWith(String prefix)
String argument that starts with the given prefix. |
public static <T> T any()
See examples in javadoc for ArgumentMatchers
class
This is an alias of: anyObject()
and any(java.lang.Class)
Notes :
anyChar()
family or isA(Class)
or any(Class)
.any(Class)
is not anymore an alias of this method.null
.any(Class)
,
anyObject()
,
anyVararg()
,
anyChar()
,
anyInt()
,
anyBoolean()
,
anyCollectionOf(Class)
@Deprecated public static <T> T anyObject()
null
.
This is an alias of: any()
and any(java.lang.Class)
.
See examples in javadoc for ArgumentMatchers
class.
null
.any()
,
any(Class)
,
notNull()
,
notNull(Class)
public static <T> T any(Class<T> type)
This matcher will perform a type check with the given type, thus excluding values.
See examples in javadoc for ArgumentMatchers
class.
This is an alias of: isA(Class)
}
Since Mockito 2.1.0, only allow non-null instance of , thus
null
is not anymore a valid value.
As reference are nullable, the suggested API to match null
would be isNull()
. We felt this change would make tests harness much safer that it was with Mockito
1.x.
Notes :
anyChar()
family.null
values are not authorized.any()
and anyObject()
are not anymore aliases of this method.T
- The accepted typetype
- the class of the accepted type.null
.any()
,
anyObject()
,
anyVararg()
,
isA(Class)
,
notNull()
,
notNull(Class)
,
isNull()
,
isNull(Class)
public static <T> T isA(Class<T> type)
Object
argument that implements the given class.
See examples in javadoc for ArgumentMatchers
class
T
- the accepted type.type
- the class of the accepted type.null
.any(Class)
@Deprecated public static <T> T anyVararg()
any()
Example:
//verification:
mock.foo(1, 2);
mock.foo(1, 2, 3, 4);
verify(mock, times(2)).foo(anyVararg());
//stubbing:
when(mock.foo(anyVararg()).thenReturn(100);
//prints 100
System.out.println(mock.foo(1, 2));
//also prints 100
System.out.println(mock.foo(1, 2, 3, 4));
See examples in javadoc for ArgumentMatchers
class.
null
.any()
,
any(Class)
public static boolean anyBoolean()
boolean
or non-null Boolean
Since Mockito 2.1.0, only allow valued Boolean
, thus null
is not anymore a valid value.
As primitive wrappers are nullable, the suggested API to match null
wrapper
would be isNull()
. We felt this change would make tests harness much safer that it was with Mockito
1.x.
See examples in javadoc for ArgumentMatchers
class.
false
.isNull()
,
isNull(Class)
public static byte anyByte()
byte
or non-null Byte
.
Since Mockito 2.1.0, only allow valued Byte
, thus null
is not anymore a valid value.
As primitive wrappers are nullable, the suggested API to match null
wrapper
would be isNull()
. We felt this change would make tests harness much safer that it was with Mockito
1.x.
See examples in javadoc for ArgumentMatchers
class.
0
.isNull()
,
isNull(Class)
public static char anyChar()
char
or non-null Character
.
Since Mockito 2.1.0, only allow valued Character
, thus null
is not anymore a valid value.
As primitive wrappers are nullable, the suggested API to match null
wrapper
would be isNull()
. We felt this change would make tests harness much safer that it was with Mockito
1.x.
See examples in javadoc for ArgumentMatchers
class.
0
.isNull()
,
isNull(Class)
public static int anyInt()
Integer
.
Since Mockito 2.1.0, only allow valued Integer
, thus null
is not anymore a valid value.
As primitive wrappers are nullable, the suggested API to match null
wrapper
would be isNull()
. We felt this change would make tests harness much safer that it was with Mockito
1.x.
See examples in javadoc for ArgumentMatchers
class.
0
.isNull()
,
isNull(Class)
public static long anyLong()
long
or non-null Long
.
Since Mockito 2.1.0, only allow valued Long
, thus null
is not anymore a valid value.
As primitive wrappers are nullable, the suggested API to match null
wrapper
would be isNull()
. We felt this change would make tests harness much safer that it was with Mockito
1.x.
See examples in javadoc for ArgumentMatchers
class.
0
.isNull()
,
isNull(Class)
public static float anyFloat()
float
or non-null Float
.
Since Mockito 2.1.0, only allow valued Float
, thus null
is not anymore a valid value.
As primitive wrappers are nullable, the suggested API to match null
wrapper
would be isNull()
. We felt this change would make tests harness much safer that it was with Mockito
1.x.
See examples in javadoc for ArgumentMatchers
class.
0
.isNull()
,
isNull(Class)
public static double anyDouble()
double
or non-null Double
.
Since Mockito 2.1.0, only allow valued Double
, thus null
is not anymore a valid value.
As primitive wrappers are nullable, the suggested API to match null
wrapper
would be isNull()
. We felt this change would make tests harness much safer that it was with Mockito
1.x.
See examples in javadoc for ArgumentMatchers
class.
0
.isNull()
,
isNull(Class)
public static short anyShort()
short
or non-null Short
.
Since Mockito 2.1.0, only allow valued Short
, thus null
is not anymore a valid value.
As primitive wrappers are nullable, the suggested API to match null
wrapper
would be isNull()
. We felt this change would make tests harness much safer that it was with Mockito
1.x.
See examples in javadoc for ArgumentMatchers
class.
0
.isNull()
,
isNull(Class)
public static String anyString()
String
Since Mockito 2.1.0, only allow non-null String
.
As this is a nullable reference, the suggested API to match null
wrapper
would be isNull()
. We felt this change would make tests harness much safer that it was with Mockito
1.x.
See examples in javadoc for ArgumentMatchers
class.
isNull()
,
isNull(Class)
public static <T> List<T> anyList()
List
.
Since Mockito 2.1.0, only allow non-null List
.
As this is a nullable reference, the suggested API to match null
wrapper
would be isNull()
. We felt this change would make tests harness much safer that it was with Mockito
1.x.
See examples in javadoc for ArgumentMatchers
class.
anyListOf(Class)
,
isNull()
,
isNull(Class)
public static <T> List<T> anyListOf(Class<T> clazz)
List
.
Generic friendly alias to anyList()
. It's an alternative to
@SuppressWarnings("unchecked")
to keep code clean of compiler warnings.
This method doesn't do type checks of the list content with the given type parameter, it is only there to avoid casting in the code.
Since Mockito 2.1.0, only allow non-null List
.
As this is a nullable reference, the suggested API to match null
wrapper
would be isNull()
. We felt this change would make tests harness much safer that it was with Mockito
1.x.
See examples in javadoc for ArgumentMatchers
class.
clazz
- Type owned by the list to avoid castinganyList()
,
isNull()
,
isNull(Class)
public static <T> Set<T> anySet()
Set
.
Since Mockito 2.1.0, only allow non-null Set
.
As this is a nullable reference, the suggested API to match null
wrapper
would be isNull()
. We felt this change would make tests harness much safer that it was with Mockito
1.x.
See examples in javadoc for ArgumentMatchers
class.
anySetOf(Class)
,
isNull()
,
isNull(Class)
public static <T> Set<T> anySetOf(Class<T> clazz)
Set
.
Generic friendly alias to anySet()
.
It's an alternative to @SuppressWarnings("unchecked")
to keep code clean of compiler warnings.
This method doesn't do type checks of the set content with the given type parameter, it is only there to avoid casting in the code.
Since Mockito 2.1.0, only allow non-null Set
.
As this is a nullable reference, the suggested API to match null
wrapper
would be isNull()
. We felt this change would make tests harness much safer that it was with Mockito
1.x.
See examples in javadoc for ArgumentMatchers
class.
clazz
- Type owned by the Set to avoid castinganySet()
,
isNull()
,
isNull(Class)
public static <K,V> Map<K,V> anyMap()
Map
.
Since Mockito 2.1.0, only allow non-null Map
.
As this is a nullable reference, the suggested API to match null
wrapper
would be isNull()
. We felt this change would make tests harness much safer that it was with Mockito
1.x.
See examples in javadoc for ArgumentMatchers
class.
anyMapOf(Class, Class)
,
isNull()
,
isNull(Class)
public static <K,V> Map<K,V> anyMapOf(Class<K> keyClazz, Class<V> valueClazz)
Map
.
Generic friendly alias to anyMap()
.
It's an alternative to @SuppressWarnings("unchecked")
to keep code clean of compiler warnings.
This method doesn't do type checks of the map content with the given type parameter, it is only there to avoid casting in the code.
Since Mockito 2.1.0, only allow non-null Map
.
As this is a nullable reference, the suggested API to match null
wrapper
would be isNull()
. We felt this change would make tests harness much safer that it was with Mockito
1.x.
See examples in javadoc for ArgumentMatchers
class.
keyClazz
- Type of the map key to avoid castingvalueClazz
- Type of the value to avoid castinganyMap()
,
isNull()
,
isNull(Class)
public static <T> Collection<T> anyCollection()
Collection
.
Since Mockito 2.1.0, only allow non-null Collection
.
As this is a nullable reference, the suggested API to match null
would be isNull()
. We felt this change would make tests harness much safer that it was with Mockito
1.x.
See examples in javadoc for ArgumentMatchers
class.
anyCollectionOf(Class)
,
isNull()
,
isNull(Class)
public static <T> Collection<T> anyCollectionOf(Class<T> clazz)
Collection
.
Generic friendly alias to anyCollection()
.
It's an alternative to @SuppressWarnings("unchecked")
to keep code clean of compiler warnings.
This method doesn't do type checks of the collection content with the given type parameter, it is only there to avoid casting in the code.
Since Mockito 2.1.0, only allow non-null Collection
.
As this is a nullable reference, the suggested API to match null
would be isNull()
. We felt this change would make tests harness much safer that it was with Mockito
1.x.
See examples in javadoc for ArgumentMatchers
class.
clazz
- Type owned by the collection to avoid castinganyCollection()
,
isNull()
,
isNull(Class)
public static <T> Iterable<T> anyIterable()
Iterable
.
Since Mockito 2.1.0, only allow non-null Iterable
.
As this is a nullable reference, the suggested API to match null
would be isNull()
. We felt this change would make tests harness much safer that it was with Mockito
1.x.
See examples in javadoc for ArgumentMatchers
class.
anyIterableOf(Class)
,
isNull()
,
isNull(Class)
public static <T> Iterable<T> anyIterableOf(Class<T> clazz)
Iterable
.
Generic friendly alias to anyIterable()
.
It's an alternative to @SuppressWarnings("unchecked")
to keep code clean of compiler warnings.
This method doesn't do type checks of the iterable content with the given type parameter, it is only there to avoid casting in the code.
Since Mockito 2.1.0, only allow non-null String
.
As strings are nullable reference, the suggested API to match null
wrapper
would be isNull()
. We felt this change would make tests harness much safer that it was with Mockito
1.x.
See examples in javadoc for ArgumentMatchers
class.
clazz
- Type owned by the collection to avoid castinganyIterable()
,
isNull()
,
isNull(Class)
public static boolean eq(boolean value)
boolean
argument that is equal to the given value.
See examples in javadoc for ArgumentMatchers
class
value
- the given value.0
.public static byte eq(byte value)
byte
argument that is equal to the given value.
See examples in javadoc for ArgumentMatchers
class
value
- the given value.0
.public static char eq(char value)
char
argument that is equal to the given value.
See examples in javadoc for ArgumentMatchers
class
value
- the given value.0
.public static double eq(double value)
double
argument that is equal to the given value.
See examples in javadoc for ArgumentMatchers
class
value
- the given value.0
.public static float eq(float value)
float
argument that is equal to the given value.
See examples in javadoc for ArgumentMatchers
class
value
- the given value.0
.public static int eq(int value)
int
argument that is equal to the given value.
See examples in javadoc for ArgumentMatchers
class
value
- the given value.0
.public static long eq(long value)
long
argument that is equal to the given value.
See examples in javadoc for ArgumentMatchers
class
value
- the given value.0
.public static short eq(short value)
short
argument that is equal to the given value.
See examples in javadoc for ArgumentMatchers
class
value
- the given value.0
.public static <T> T eq(T value)
See examples in javadoc for ArgumentMatchers
class
value
- the given value.null
.public static <T> T refEq(T value, String... excludeFields)
This matcher can be used when equals() is not implemented on compared objects. Matcher uses java reflection API to compare fields of wanted and actual object.
Works similarly to EqualsBuilder.reflectionEquals(this, other, exlucdeFields)
from
apache commons library.
Warning The equality check is shallow!
See examples in javadoc for ArgumentMatchers
class
value
- the given value.excludeFields
- fields to exclude, if field does not exist it is ignored.null
.public static <T> T same(T value)
See examples in javadoc for ArgumentMatchers
class
T
- the type of the object, it is passed through to prevent casts.value
- the given value.null
.public static <T> T isNull()
null
argument.
See examples in javadoc for ArgumentMatchers
class
null
.isNull(Class)
,
isNotNull()
,
isNotNull(Class)
public static <T> T isNull(Class<T> clazz)
null
argument.
The class argument is provided to avoid casting.
See examples in javadoc for ArgumentMatchers
class
clazz
- Type to avoid castingnull
.isNull()
,
isNotNull()
,
isNotNull(Class)
public static <T> T notNull()
null
.public static <T> T notNull(Class<T> clazz)
null
argument, not necessary of the given class.
The class argument is provided to avoid casting.
Alias to isNotNull(Class)
See examples in javadoc for ArgumentMatchers
class
clazz
- Type to avoid castingnull
.isNotNull()
,
isNull()
,
isNull(Class)
public static <T> T isNotNull()
null
.isNotNull(Class)
,
isNull()
,
isNull(Class)
public static <T> T isNotNull(Class<T> clazz)
null
argument, not necessary of the given class.
The class argument is provided to avoid casting.
Alias to notNull(Class)
See examples in javadoc for ArgumentMatchers
class
clazz
- Type to avoid castingnull
.public static <T> T nullable(Class<T> clazz)
null
or of the given type.
See examples in javadoc for ArgumentMatchers
class
clazz
- Type to avoid castingnull
.public static String contains(String substring)
String
argument that contains the given substring.
See examples in javadoc for ArgumentMatchers
class
substring
- the substring.public static String matches(String regex)
String
argument that matches the given regular expression.
See examples in javadoc for ArgumentMatchers
class
regex
- the regular expression.AdditionalMatchers.not(boolean)
public static String matches(Pattern pattern)
Pattern
argument that matches the given regular expression.
See examples in javadoc for ArgumentMatchers
class
pattern
- the regular expression pattern.AdditionalMatchers.not(boolean)
public static String endsWith(String suffix)
String
argument that ends with the given suffix.
See examples in javadoc for ArgumentMatchers
class
suffix
- the suffix.public static String startsWith(String prefix)
String
argument that starts with the given prefix.
See examples in javadoc for ArgumentMatchers
class
prefix
- the prefix.public static <T> T argThat(ArgumentMatcher<T> matcher)
This API has changed in 2.1.0, please read ArgumentMatcher
for rationale and migration guide.
NullPointerException auto-unboxing caveat is described below.
It is important to understand the use cases and available options for dealing with non-trivial arguments
before implementing custom argument matchers. This way, you can select the best possible approach
for given scenario and produce highest quality test (clean and maintainable).
Please read the documentation for ArgumentMatcher
to learn about approaches and see the examples.
NullPointerException auto-unboxing caveat.
In rare cases when matching primitive parameter types you *must* use relevant intThat(), floatThat(), etc. method.
This way you will avoid NullPointerException
during auto-unboxing.
Due to how java works we don't really have a clean way of detecting this scenario and protecting the user from this problem.
Hopefully, the javadoc describes the problem and solution well.
If you have an idea how to fix the problem, let us know via the mailing list or the issue tracker.
See examples in javadoc for ArgumentMatcher
class
matcher
- decides whether argument matchesnull
.public static char charThat(ArgumentMatcher<Character> matcher)
char
argument matchers.
Note that argThat(org.mockito.ArgumentMatcher)
will not work with primitive char
matchers due to NullPointerException
auto-unboxing caveat.
See examples in javadoc for ArgumentMatchers
class
matcher
- decides whether argument matches0
.public static boolean booleanThat(ArgumentMatcher<Boolean> matcher)
boolean
argument matchers.
Note that argThat(org.mockito.ArgumentMatcher)
will not work with primitive boolean
matchers due to NullPointerException
auto-unboxing caveat.
See examples in javadoc for ArgumentMatchers
class
matcher
- decides whether argument matchesfalse
.public static byte byteThat(ArgumentMatcher<Byte> matcher)
byte
argument matchers.
Note that argThat(org.mockito.ArgumentMatcher)
will not work with primitive byte
matchers due to NullPointerException
auto-unboxing caveat.
See examples in javadoc for ArgumentMatchers
class
matcher
- decides whether argument matches0
.public static short shortThat(ArgumentMatcher<Short> matcher)
short
argument matchers.
Note that argThat(org.mockito.ArgumentMatcher)
will not work with primitive short
matchers due to NullPointerException
auto-unboxing caveat.
See examples in javadoc for ArgumentMatchers
class
matcher
- decides whether argument matches0
.public static int intThat(ArgumentMatcher<Integer> matcher)
int
argument matchers.
Note that argThat(org.mockito.ArgumentMatcher)
will not work with primitive int
matchers due to NullPointerException
auto-unboxing caveat.
See examples in javadoc for ArgumentMatchers
class
matcher
- decides whether argument matches0
.public static long longThat(ArgumentMatcher<Long> matcher)
long
argument matchers.
Note that argThat(org.mockito.ArgumentMatcher)
will not work with primitive long
matchers due to NullPointerException
auto-unboxing caveat.
See examples in javadoc for ArgumentMatchers
class
matcher
- decides whether argument matches0
.public static float floatThat(ArgumentMatcher<Float> matcher)
float
argument matchers.
Note that argThat(org.mockito.ArgumentMatcher)
will not work with primitive float
matchers due to NullPointerException
auto-unboxing caveat.
See examples in javadoc for ArgumentMatchers
class
matcher
- decides whether argument matches0
.public static double doubleThat(ArgumentMatcher<Double> matcher)
double
argument matchers.
Note that argThat(org.mockito.ArgumentMatcher)
will not work with primitive double
matchers due to NullPointerException
auto-unboxing caveat.
See examples in javadoc for ArgumentMatchers
class
matcher
- decides whether argument matches0
.