ServerFoundActivity extends BaseActivity implements ServerFoundView { @Override public void showError(@NonNull String errorMessage) { Toast.makeText(this, errorMessage, Toast.LENGTH_LONG).show(); }  static Intent getCallingIntent(Context context, ServerModel serverModel); @Override boolean onOptionsItemSelected(MenuItem item); @Override void renderServer(@NonNull ServerModel serverModel); @Override void showError(@NonNull String errorMessage); @Override void navigateBack(boolean isSuccess, ServerModel serverModel); @OnClick(R.id.button_connect) void onConnectButtonClick(View view); static final String KEY_SERVER; }
@Test public void shouldDisplayError() throws Exception { serverFoundActivity.showError("Something came up"); Toast latestToast = ShadowToast.getLatestToast(); String textOfLatestToast = ShadowToast.getTextOfLatestToast(); assertThat(latestToast, notNullValue()); assertThat(latestToast.getDuration(), is(Toast.LENGTH_LONG)); assertThat(textOfLatestToast, notNullValue()); assertThat(textOfLatestToast, is("Something came up")); }