Tag : mocking

I need mock as when(new A(any(B.class))).thenReturn(any(A.class));
because my code have function:
B b = new B; A a = new A(b); C c = a.processing();
but return error:
org.mockito.exceptions.misusing.InvalidUseOfMatchersException:
Misplaced or misused argument matcher detected here:
-> at …….
You cannot use argument matchers outside of verification or stubbing.
Examples of correct usage of argument matchers:
when(mock.get(anyInt())).thenReturn(null); doThrow(new RuntimeException()).when(mock).someVoidMethod(anyObject()); verify(mock).someMethod(contains("foo"))<..

Read more