Created
August 17, 2016 11:05
-
-
Save hoombar/201a10a4a82a189dc3a1ef07452c4187 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 CustomTestRunner extends RobolectricTestRunner { | |
/** | |
* Creates a runner to run {@code testClass}. Looks in your working directory for your AndroidManifest.xml file | |
* and res directory by default. Use the {@link Config} annotation to configure. | |
* | |
* @param testClass the test class to be run | |
* @throws org.junit.runners.model.InitializationError if junit says so | |
*/ | |
public CustomTestRunner(Class<?> testClass) throws InitializationError { | |
super(testClass); | |
} | |
@Override | |
protected AndroidManifest getAppManifest(Config config) { | |
String path = "src/main/AndroidManifest.xml"; | |
// android studio has a different execution root for tests than pure gradle | |
// so we avoid here manual effort to get them running inside android studio | |
if (!new File(path).exists()) { | |
path = "judo-reference/" + path; | |
} | |
config = overwriteConfig(config, "manifest", path); | |
return super.getAppManifest(config); | |
} | |
protected Config.Implementation overwriteConfig( | |
Config config, String key, String value) { | |
Properties properties = new Properties(); | |
properties.setProperty(key, value); | |
return new Config.Implementation(config, | |
Config.Implementation.fromProperties(properties)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment