Skip to content

Incompletion of workable test case in RealWorldAppInjector application #93

@roman-yu

Description

@roman-yu

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions