Hi, I am new to testing programming, and cannot solve a probably easy problem. I have written the following test code:
public class RegisterPresenterTest { private DispatchAsync mockDispatch; private HandlerManager mockEventBus; private RegisterView<String> mockView; private RegisterPresenter registerPresenter; private User user = null; @Before public void setUp() throws Exception { mockDispatch = createStrictMock(DispatchAsync.class); mockEventBus = new HandlerManager(null); mockView = createStrictMock(RegisterView.class); } @After public void tearDown() throws Exception { } @Test public void testOnSubmitButtonClickedNewUserSave() { registerPresenter = new RegisterPresenter(mockView, mockEventBus, mockDispatch, user); expect((String)mockView.getName().getValue()).andReturn("nikos"); expect(mockView.getSurname().getValue()).andReturn("tester"); expect(mockView.getEmail().getValue()).andReturn("t...@gmail.com"); expect(mockView.getMobile().getValue()).andReturn("1699876778"); mockDispatch.execute(isA(Action.class), isA(AsyncCallback.class)); expectLastCall().andAnswer(new IAnswer<Object>() { @Override public Object answer() throws Throwable { final Object[] arguments = getCurrentArguments(); AsyncCallback<CreateUserResult> callback = (AsyncCallback<CreateUserResult>) arguments[arguments.length - 1]; callback.onSuccess(new CreateUserResult()); return null; } }); replay(mockView); replay(mockDispatch); registerPresenter.onSubmitButtonClicked(); verify(mockView); verify(mockDispatch); } } The logic is that when a new user pushes the submit button, the presenter will begin the save process. In this process in presenter, the user gets the field values from the view. But when I mock the view, and add the needed behavior, I get an error like the following. When I run it, I am getting null pointer exception at expect((String)mockView.getName().getValue()).andReturn("nikos"); So what I am doing wrong? -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.