我有一个emailservice@spy对象,它有发送功能。我想这样做。
when(emailClientService.send(any())).thenCallRealMethod().thenCallMyCustomMethod(...)
zsbz8rwp1#
我找到答案了!
Mockito.doAnswer((Answer<Object>) invocation -> { invocation.callRealMethod(); // calling emailService.send() callMyCustomMethod(); ... return null; }).when(emailService).send(any());
1条答案
按热度按时间zsbz8rwp1#
我找到答案了!