2015-08-28 32 views

回答

1

是的,這是可以做到的。你會使用間諜。

ChecksUtil service = spy(new ChecksUtil()); 

when(service.method()).thenReturn(someObject); 
//or if method is a void 
doNothing().when(service).method(); 

有意識的對象會將對象留下,除了您想要模擬的任何方法外。

相關問題