Skip to content

Instantly share code, notes, and snippets.

@nyamwaya
Last active August 29, 2015 14:26
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 nyamwaya/5e94822457d9f767b2e5 to your computer and use it in GitHub Desktop.
Save nyamwaya/5e94822457d9f767b2e5 to your computer and use it in GitHub Desktop.
//After creating your class extend, RobolectricTestRunner
//Create a cunstructor
//then inside your constructer, put this code inside it
super(testClass);
String buildVariant = (BuildConfig.FLAVOR.isEmpty()
? "" : BuildConfig.FLAVOR+ "/") + BuildConfig.BUILD_TYPE;
String intermediatesPath = BuildConfig.class.getResource("")
.toString().replace("file:", "");
intermediatesPath = intermediatesPath
.substring(0, intermediatesPath.indexOf("/classes"));
System.setProperty("android.package",
BuildConfig.APPLICATION_ID);
System.setProperty("android.manifest",
intermediatesPath + "/manifests/full/"
+ buildVariant + "/AndroidManifest.xml");
System.setProperty("android.resources",
intermediatesPath + "/res/" + buildVariant);
System.setProperty("android.assets",
intermediatesPath + "/assets/" + buildVariant);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment