Jardo
Jardo

Reputation: 2093

Mockito verify method call with generic collection argument

I have this method:

public void myMethod(Set<Item> items);

When I try to call:

Mockito.verify(instance.myMethod(Mockito.anySet());

I get this compilation error:

The method verify(T) in the type Mockito is not applicable for the arguments (void)

I get the same error even when I define an argument captor. How can I fix this?

Upvotes: 2

Views: 1367

Answers (1)

Jardo
Jardo

Reputation: 2093

I figured it out. It has to be like this:

Mockito.verify(instance).myMethod(Mockito.anySet());

The parentheses were wrongly placed.

Upvotes: 5

Related Questions