我是Mockito的新手。我想嘲笑这段用Oracle ADF编写的代码。
else {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO,
"No Cases found in Queue",null));
}
这是我的模拟:
FacesMessage facesMessageMock = mock(FacesMessage.class);
PowerMockito.mockStatic(FacesContext.class);
PowerMockito.when(FacesContext.getCurrentInstance()).thenReturn(facesContextMock);
但是我有这个错误:
org.mockito.exceptions.misusing.MissingMethodInvocationException:
when() requires an argument which has to be 'a method call on a mock'.
你能帮我吗?
您需要在测试类上具有以下注释:
@RunWith(PowerMockRunner.class)
@PrepareForTest(FacesContext.class)
public class YourTest {
...
}
有关详细信息和示例,请参阅此页面。