Skip to content

Instantly share code, notes, and snippets.

@dhoskins
Last active September 22, 2016 13:50
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 dhoskins/98afa6976c87cb20328d42065c7292ee to your computer and use it in GitHub Desktop.
Save dhoskins/98afa6976c87cb20328d42065c7292ee to your computer and use it in GitHub Desktop.
Combined JUnit, Cucumber and MultiDex instrumentation test runner
public class MultiDexCucumberJUnitRunner extends AndroidJUnitRunner {
private final CucumberInstrumentationCore mInstrumentationCore = new CucumberInstrumentationCore(this);
@Override
public void onCreate(Bundle arguments) {
MultiDex.install(getTargetContext());
mInstrumentationCore.create(arguments);
super.onCreate(arguments);
}
@Override
public void onStart() {
super.onStart();
waitForIdleSync();
mInstrumentationCore.start();
allFinished();
}
private int mResultCode;
private Bundle mResults = new Bundle();
/**
* Catch calls to finish() and aggregate results into a bundle
*/
@Override
public void finish(int resultCode, Bundle results) {
mResultCode = resultCode;
mResults.putAll(results);
}
private void allFinished() {
super.finish(mResultCode, mResults);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment