I use mockito 3
as follow:
Mockito.when(webServiceTemplate.marshalSendAndReceive(Mockito.anyString(),
ArgumentMatchers.<JAXBElement<TypeA>>any()))
.thenReturn(responseA);
Mockito.when(webServiceTemplate.marshalSendAndReceive(Mockito.anyString(),
ArgumentMatchers.<JAXBElement<TypeB>>any()))
.thenReturn(responseB);
The problem is that mockito returns always the responseB
. Where is the problem?
I see that you are mocking the same method marshalSendAndReceive
in both cases.
It appears therefore that the response is always responseB
, because the code that is returning responseB
is invoked last.
Is the method overloaded using different types of parameters, or do TypeA
and TypeB
share the same parent class?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.