0
我有情況時,我想嘲笑的方法與此參數,我的方法看起來像下面的Mockito使用此參數嘲諷方法
this.listener = myCustomFactory.buildCustomListener(this);
下面
@Mock
MyCustomFactory myCustomFactory;
給出我曾經嘲笑myCustomFactory實例有沒有可能用這個參數來模擬方法。 「這」指的是我正在寫單元測試類,我該類
Mockito.when(this.myCustomFactory.buildCustomListener(this.myClassObjectToBeTested).thenReturn(this.mockedListener);
是的,你試過嗎?是否有錯誤?應該可以使用 – Tunaki
是的,它返回null,我也試過使用Mockito.any() – Pradeep
@ Tunaki,謝謝你的回覆,請看答案 – Pradeep