Skip to content

Instantly share code, notes, and snippets.

@tassioauad
Created May 5, 2014 14:02
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 tassioauad/a89c4463424f6486249d to your computer and use it in GitHub Desktop.
Save tassioauad/a89c4463424f6486249d to your computer and use it in GitHub Desktop.
Android JUnit4 Test Example
package com.zaal.quiosque.test;
import android.test.ActivityInstrumentationTestCase2;
import com.zaal.quiosque.presenter.impl.AccessPresenter;
import com.zaal.quiosque.view.AccessViewInterface;
import com.zaal.quiosque.view.activity.AccessView;
public class AccessPresenterTest extends ActivityInstrumentationTestCase2<AccessView>{
private AccessPresenter mPresenter;
public AccessPresenterTest() {
super(AccessView.class);
}
@Override
protected void setUp() throws Exception {
super.setUp();
mPresenter = new AccessPresenter(getInstrumentation().getTargetContext(), getActivity());
}
public void testAccessFailed() {
mPresenter.access(-1);
if(mPresenter.thereIsLoggedFuncionario()) {
fail("Acesso deveria ter falhado!");
}
}
public void testAccessSuccessful() {
mPresenter.access(1);
if(!mPresenter.thereIsLoggedFuncionario()) {
fail("Acesso deveria ter sido aceito!");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment