Unit Test - Verify Observable is subscribed

前端 未结 4 2101
攒了一身酷
攒了一身酷 2021-02-08 00:19

I have got the java code like this

 mDataManager.getObservable(\"hello\").subscribe( subscriber );

and I want to verify the follow

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-08 01:13

    I spent hours today and realize it was a silly mistake. Please check your @PrepareForTest if you are using PowerMockito.

    @PrepareForTest({Observable.class})
    

    also don't forget to mock it. I did it on @before :

    PowerMockito.mockStatic(Observable.class);
    

    I hope it can help. Thank you

提交回复
热议问题