我需要在PowerMockito中调用后进行存根。

appAcceptedDoc.getAppointmentAccepted().getRequestResponse().getRequestersID().getStringValue()


我知道可以在调用ockock时使用RETURNS_DEEP_STUBS作为附加参数在Mockito中完成,但如何使用PowerMockito /做到这一点却似乎不接受Mockito接受的相同arg。

AppointmentAcceptedDocument appAcceptedDoc = Mockito.mock(AppointmentAcceptedDocument.class, RETURNS_DEEP_STUBS); - Possible

AppointmentAcceptedDocument appAcceptedDoc = PowerMockito.mock(AppointmentAcceptedDocument.class, <?RETURNS_DEEP_STUBS?>); - Not possible

最佳答案

实际上发现您可以像使用Mockito一样执行此powermockito

以下将起作用

AppointmentAcceptedDocument appAcceptedDoc = PowerMockito.mock(AppointmentAcceptedDocument.class,  Mockito.RETURNS_DEEP_STUBS);


希望它能对某人有所帮助!

关于java - 在PowerMockito中 stub 链式方法,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16536119/

10-15 10:48