Skip to content

Instantly share code, notes, and snippets.

@nontravis
Created February 19, 2017 08:17
Show Gist options
  • Save nontravis/2a506bffced2c5fa4e4e29e1bc6ae3c3 to your computer and use it in GitHub Desktop.
Save nontravis/2a506bffced2c5fa4e4e29e1bc6ae3c3 to your computer and use it in GitHub Desktop.
Example_MainPresenterUnitTest
@RunWith(JUnit4.class)
class MainPresenterUnitTest{
@Before
public void setup(){
...
}
@Test
public void calculate(){
assertThat( presenter.calculate(10), is(equalTo(20)));
...
}
@Test
public void clickGotoSecondActivity(){
presenter.clickGotoSecondActivity();
verify(RxBus.get(),times(1)).post(any(GoToSecondEvent.class));
...
}
@Test
public void requestService(){
presenter.requestService();
// test some logic
...
}
@Test
public void onReceiveSuccessEvent(SuccessEvent event){
presenter.onReceiveSuccessEvent(new SuccessEvent());
// test some logic
...
}
@Test
public void onReceiveFailEvent(FailEvent event){
presenter.onReceiveFailEvent(new FailEvent());
// test some logic
...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment