在下面的代碼中,我無法使用PowerMock模擬構造函數。 我想要MOK以下語句。無法使用PowerMock模擬構造函數
APSPPortletRequest wrappedRequest = new APSPPortletRequest(request);
下面
是我的嘲諷步驟
@PrepareForTest({APSPPortletRequest.class})
@RunWith(PowerMockRunner.class)
public class ReminderPortletControllerTest {
private PortletRequest requestMock;
private APSPPortletRequest apspPortletRequestMock;
public void setUp() throws Exception {
requestMock = EasyMock.createNiceMock(PortletRequest.class);
apspPortletRequestMock = EasyMock.createNiceMock(APSPPortletRequest.class);
}
@Test
public void testExecuteMethod() throws Exception {
PowerMock.expectNew(APSPPortletRequest.class, requestMock).andReturn(apspPortletRequestMock).anyTimes();
EasyMock.replay(apspPortletRequestMock, requestMock);
PowerMock.replayAll();
}
}
請建議我上。
您能否提供錯誤或某些提示,指出確切問題是什麼 – Pratik