Last active
September 22, 2016 13:50
-
-
Save dhoskins/98afa6976c87cb20328d42065c7292ee to your computer and use it in GitHub Desktop.
Combined JUnit, Cucumber and MultiDex instrumentation test runner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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