Skip to content

Instantly share code, notes, and snippets.

@rafakob
Last active June 14, 2016 10:45
Show Gist options
  • Save rafakob/d4df8a6b3ffeffbd929aa2ff915e189f to your computer and use it in GitHub Desktop.
Save rafakob/d4df8a6b3ffeffbd929aa2ff915e189f to your computer and use it in GitHub Desktop.

Revisions

  1. rafakob revised this gist Jun 14, 2016. 1 changed file with 11 additions and 1 deletion.
    12 changes: 11 additions & 1 deletion Test.java
    Original file line number Diff line number Diff line change
    @@ -28,4 +28,14 @@ public void testLogin() throws Exception {
    loginPresenter.register();
    verify(loginPresenter).blablaMethod();
    }
    }
    }

    /////// RESULT /////

    Wanted but not invoked:
    loginPresenter.blablaMethod();
    -> at io.tsh.spincar.ui.login.LoginPresenterTest.testLogin(LoginPresenterTest.java:23)

    However, there were other interactions with this mock:
    loginPresenter.register();
    -> at io.tsh.spincar.ui.login.LoginPresenterTest.testLogin(LoginPresenterTest.java:22)
  2. rafakob created this gist Jun 14, 2016.
    31 changes: 31 additions & 0 deletions Test.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    public class LoginPresenter extends MvpPresenter<LoginView> {
    public void register() {
    blablaMethod();
    }


    public void blablaMethod(){

    }
    }


    ///////// TEST /////////

    public class LoginPresenterTest {
    private LoginPresenter loginPresenter;
    private LoginView view;

    @Before
    public void setUp() throws Exception {
    loginPresenter = Mockito.mock(LoginPresenter.class);
    view = Mockito.mock(LoginView.class);
    loginPresenter.bindView(view);
    }

    @Test
    public void testLogin() throws Exception {
    loginPresenter.register();
    verify(loginPresenter).blablaMethod();
    }
    }