我需要嘲笑这个:
void handleCellPreview(CellPreviewEvent<List<String>> event) {
Element cellElement = event.getNativeEvent().getEventTarget().cast();
}
我正在这样做:
CellPreviewEvent<List<String>> cellPreviewEvent = Mockito.mock(
CellPreviewEvent.class, Mockito.RETURNS_DEEP_STUBS);
Element cellElement = Mockito.mock(Element.class, Mockito.RETURNS_DEEP_STUBS);
EventTarget eventTarget = Mockito.mock(EventTarget.class);
Mockito.when(cellPreviewEvent.getNativeEvent().getEventTarget().cast()).thenReturn(cellElement);
我收到以下错误:
testHandleCellPreview(client.view.MyViewTest)java.lang.NullPointerException
at com.google.gwt.dom.client.NativeEvent.getEventTarget(NativeEvent.java:137)
atclient.view.MyViewTest.testHandleCellPreview(MyViewTest.java:76)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
我也看到了,下面同样的问题:
mock or stub for chained call
有人可以指出我缺少什么吗?
谢谢,
莫希特