在PowerMockito中存根链接方法

时间:2013-05-14 05:59:36

标签: java unit-testing mocking mockito powermock

我需要在PowerMockito中跟随调用。

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

我知道这可以在Mockito中使用RETURNS_DEEP_STUBS作为调用mock时的附加参数来完成,但是怎么可以使用PowerMockito来完成呢?但似乎不接受与Mockito相同的arg。

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

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

1 个答案:

答案 0 :(得分:1)

实际上发现你可以像Mockito那样做这个powermockito

以下工作

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

希望它有所帮助!