【发布时间】:2017-08-23 12:50:40
【问题描述】:
在下面的代码中,我无法使用 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();
}
}
请在这方面给我建议。
【问题讨论】:
-
您能否提供错误信息,或者提供一些关于确切问题的提示