Skip to content

Instantly share code, notes, and snippets.

@topera
Created March 10, 2019 17:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save topera/2e2697b48ee0373e45db7aa2fc67c462 to your computer and use it in GitHub Desktop.
Save topera/2e2697b48ee0373e45db7aa2fc67c462 to your computer and use it in GitHub Desktop.
Example of unit test of Android presenters (MVP architecture)
public class WordPresenterTest {
@Mock
WordPresenter.View view;
@Mock
WordService wordService;
private WordPresenter presenter;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
presenter = new WordPresenter(view, wordService);
}
@Test
public void randomWord() {
when(wordService.randomWordType()).thenReturn(WordType.SUB);
presenter.randomWord();
verify(view).setWordType(WordType.SUB.getFullName());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment