Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompletion of workable test case in RealWorldAppInjector application #93

Open
roman-yu opened this issue Jan 14, 2019 · 1 comment
Open

Comments

@roman-yu
Copy link

It is currently in below version:

@Test
    public void testOnCreate() {
        when(restService.executeServerCall()).thenReturn(true);

        Robolectric.setupActivity(MainActivity.class);
    }

which I changed to below version:

@Mock MainPresenter presenter;

@Test
    public void testOnCreate() {
        when(restService.executeServerCall()).thenReturn(true);

        MainActivity activity = Robolectric.setupActivity(MainActivity.class);
        activity.findViewById(R.id.reload).performClick();

        verify(presenter).loadData();
    }

But it failed due to fail to mock presenter. It seems failed to mock the MainPresenter or I am doing some wrong?

@fabioCollini
Copy link
Owner

It should work, which error do you get? Can you try to change it to understand the single change that makes it fail?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants