Skip to content

Instantly share code, notes, and snippets.

@jabKnowsNothing
Created November 4, 2015 21:07
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 jabKnowsNothing/8a5ff1a96be867ad5979 to your computer and use it in GitHub Desktop.
Save jabKnowsNothing/8a5ff1a96be867ad5979 to your computer and use it in GitHub Desktop.
Custom Rule For Espresso Blog bost
public class MyCustomRule<A extends MyActivity> extends ActivityTestRule<A> {
public MyCustomRule(Class<A> activityClass) {
super(activityClass);
}
@Override
protected void beforeActivityLaunched() {
super.beforeActivityLaunched();
// Maybe prepare some mock service calls
// Maybe override some depency injection modules with mocks
}
@Override
protected Intent getActivityIntent() {
Intent customIntent = new Intent();
// add some custom extras and stuff
return customIntent;
}
@Override
protected void afterActivityLaunched() {
super.afterActivityLaunched();
// maybe you want to do something here
}
@Override
protected void afterActivityFinished() {
super.afterActivityFinshed();
// Clean up mocks
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment