Created
March 10, 2019 17:32
-
-
Save topera/2e2697b48ee0373e45db7aa2fc67c462 to your computer and use it in GitHub Desktop.
Example of unit test of Android presenters (MVP architecture)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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