Created
November 1, 2017 19:47
-
-
Save drawers/ad65659b8502685c1d6050ce601b5355 to your computer and use it in GitHub Desktop.
An integration test for the RegistrationActivity
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 RegistrationTest { | |
//mocks | |
@Mock Storage mockStorage; | |
@Mock RegistrationService mockRegistrationService; | |
@Mock RegistrationContract.View mockView; | |
//system under test | |
RegistrationContract.Interactor interactor; | |
RegistrationContract.Presenter presenter; | |
@Before | |
public void setUp() { | |
MockitoAnnotations.initMocks(this); | |
presenter = new RegistrationPresenter(mockRegistrationService, mockStorage); | |
presenter.takeView(mockView); | |
interactor = new RegistrationInteractor(presenter); | |
} | |
@Test | |
public void givenNoInternet_whenClickRegisterButton_thenShowsAlertDialogWithMessage() { | |
//arrange | |
when(mockRegistrationService.register(any(RegistrationDTO.class)).thenThrow(new ConnectException()); | |
//act | |
interactor.onRegisterButtonClick("username", "password"); | |
//assert | |
verify(view).showMessage("No internet available."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment