├── NewAndroidModule ├── globals.xml.ftl ├── recipe.xml.ftl ├── root │ ├── AndroidManifest.xml.ftl │ ├── app │ │ └── Application.java.ftl │ ├── build.gradle.ftl │ ├── module_ignore │ ├── proguard-rules.txt.ftl │ ├── res │ │ ├── drawable-hdpi │ │ │ └── ic_launcher.png │ │ ├── drawable-mdpi │ │ │ └── ic_launcher.png │ │ ├── drawable-xhdpi │ │ │ └── ic_launcher.png │ │ ├── drawable-xxhdpi │ │ │ └── ic_launcher.png │ │ ├── values-v21 │ │ │ └── styles.xml │ │ └── values │ │ │ ├── strings.xml.ftl │ │ │ └── styles.xml.ftl │ ├── settings.gradle.ftl │ └── test │ │ ├── app_package │ │ ├── ApplicationTest.java.ftl │ │ ├── EspressoBasicActivityTest.java.ftl │ │ ├── RobolectricBasicActivityTest.java.ftl │ │ ├── RobotiumBasicActivityTest.java.ftl │ │ └── RobotiumTest │ │ └── runner │ │ └── RobolectricGradleTestRunner.java.ftl ├── template.xml └── template_new_project.png ├── NewAndroidProject ├── globals.xml.ftl ├── recipe.xml.ftl ├── root │ ├── build.gradle.ftl │ ├── gradle.properties.ftl │ ├── local.properties.ftl │ ├── project_ignore │ └── settings.gradle.ftl ├── template.xml └── template_new_project.png └── README.md /NewAndroidModule/globals.xml.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /NewAndroidModule/recipe.xml.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <#if appCompat?has_content> 6 | 7 | <#if !createActivity> 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 19 | 21 | 23 | 24 | <#if copyIcons> 25 | 27 | 29 | 31 | 33 | 34 | <#if makeIgnore> 35 | 37 | 38 | <#if enableProGuard> 39 | 41 | 42 | <#if !(isLibraryProject??) || !isLibraryProject> 43 | 45 | <#if buildApi gte 21> 46 | 48 | 49 | 50 | 51 | 53 | 54 | 56 | 57 | 59 | 60 | 62 | 64 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /NewAndroidModule/root/AndroidManifest.xml.ftl: -------------------------------------------------------------------------------- 1 | 3 | 4 | android:allowBackup="true" 5 | android:name=".MyApplication" 6 | android:label="@string/app_name"<#if copyIcons> 7 | android:icon="@drawable/ic_launcher"<#else> 8 | android:icon="@drawable/${assetName}" 9 | <#if baseTheme != "none" && !isLibraryProject> 10 | android:theme="@style/AppTheme"> 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /NewAndroidModule/root/app/Application.java.ftl: -------------------------------------------------------------------------------- 1 | package ${packageName}; 2 | 3 | import android.app.Application; 4 | 5 | public class MyApplication extends Application { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /NewAndroidModule/root/build.gradle.ftl: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenCentral() 4 | jcenter() 5 | <#if mavenUrl != "mavenCentral"> 6 | maven { 7 | url '${mavenUrl}' 8 | } 9 | 10 | } 11 | 12 | dependencies { 13 | classpath 'com.android.tools.build:gradle:${gradlePluginVersion}' 14 | classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.+' 15 | classpath 'org.jesko.robolectric:robolectric-androidstudio-plugin:1.1.3' 16 | } 17 | } 18 | 19 | <#if isLibraryProject?? && isLibraryProject> 20 | apply plugin: 'com.android.library' 21 | <#else> 22 | apply plugin: 'android-sdk-manager' 23 | apply plugin: 'com.android.application' 24 | apply plugin: 'robolectric' 25 | 26 | 27 | repositories { 28 | mavenCentral() 29 | jcenter() 30 | <#if mavenUrl != "mavenCentral"> 31 | maven { 32 | url '${mavenUrl}' 33 | } 34 | 35 | } 36 | 37 | configurations { 38 | all*.exclude group: 'org.json' 39 | all*.exclude group: 'asm', module: 'asm' 40 | all*.exclude group: 'stax' 41 | all*.exclude group: 'xpp3' 42 | } 43 | 44 | android { 45 | compileSdkVersion <#if buildApiString?matches("^\\d+$")>${buildApiString}<#else>'${buildApiString}' 46 | buildToolsVersion "${buildToolsVersion}" 47 | 48 | defaultConfig { 49 | applicationId "${packageName}" 50 | minSdkVersion <#if minApi?matches("^\\d+$")>${minApi}<#else>'${minApi}' 51 | targetSdkVersion <#if targetApiString?matches("^\\d+$")>${targetApiString}<#else>'${targetApiString}' 52 | versionCode 1 53 | versionName "1.0" 54 | testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner" 55 | 56 | } 57 | packagingOptions { 58 | exclude 'META-INF/LICENSE.txt' 59 | exclude 'LICENSE.txt' 60 | exclude 'META-INF/NOTICE.txt' 61 | } 62 | lintOptions { 63 | abortOnError false 64 | } 65 | 66 | sourceSets { 67 | androidTest.java.srcDirs = ['src/androidTest/java', 'src/androidTestRobotium/java', 'src/androidTestEspresso/java'] 68 | androidTest.assets.srcDirs = ['src/androidTest/assets', 'src/androidTestRobotium/assets', 'src/androidTestEspresso/assets'] 69 | } 70 | 71 | <#if javaVersion?? && javaVersion != "1.6"> 72 | 73 | compileOptions { 74 | sourceCompatibility JavaVersion.VERSION_${javaVersion?replace('.','_','i')} 75 | targetCompatibility JavaVersion.VERSION_${javaVersion?replace('.','_','i')} 76 | } 77 | 78 | 79 | } 80 | 81 | dependencies { 82 | <#if dependencyList?? > 83 | <#list dependencyList as dependency> 84 | compile '${dependency}' 85 | 86 | 87 | 88 | compile('org.roboguice:roboguice:2.0') { 89 | exclude group: 'aopalliance' 90 | exclude group: 'org.sonatype.sisu.inject' 91 | } 92 | compile 'com.android.support:support-v4:21.0.0' 93 | androidTestCompile('com.google.dexmaker:dexmaker-mockito:1.0') { 94 | exclude group: 'com.google.dexmaker', module: 'dexmaker' 95 | } 96 | compile 'com.squareup.retrofit:retrofit:1.5.1' 97 | compile 'com.squareup:otto:1.3.+' 98 | compile 'com.squareup.picasso:picasso:2.3.+' 99 | androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.2.1' 100 | androidTestProvided 'com.jeskeshouse:injected-test-runner:1.0' 101 | androidTestCompile'com.jakewharton.espresso:espresso:1.1-r3' 102 | androidTestCompile 'com.jakewharton.espresso:espresso-support-v4:1.1-r3' 103 | robolectricCompile 'junit:junit:4.10' 104 | robolectricCompile 'org.mockito:mockito-all:1.9.0' 105 | robolectricCompile 'com.google.android:android:4.1.1.4' 106 | robolectricCompile('org.roboguice:roboguice:2.0') { 107 | exclude group: 'aopalliance' 108 | exclude group: 'org.sonatype.sisu.inject' 109 | } 110 | 111 | androidTestProvided 'junit:junit:4.10' 112 | 113 | compile fileTree(dir: 'libs', include: ['*.jar']) 114 | <#if WearprojectName?has_content && NumberOfEnabledFormFactors?has_content && NumberOfEnabledFormFactors gt 1> 115 | wearApp project(':${WearprojectName}') 116 | compile 'com.google.android.gms:play-services-wearable:+' 117 | 118 | } 119 | robolectric { 120 | imlFile 'app.iml' 121 | dotIdeaDir '../.idea' 122 | inProcessBuilds = false 123 | } 124 | 125 | tasks.withType(Test) { 126 | scanForTestClasses = false 127 | include "**/*Test.class" 128 | } 129 | 130 | gradle.projectsEvaluated { 131 | generateDebugSources.doLast { 132 | tasks['addRobolectricTestSourcesToIml'].execute() 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /NewAndroidModule/root/module_ignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /NewAndroidModule/root/proguard-rules.txt.ftl: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in ${sdkDir}/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /NewAndroidModule/root/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emmano/android-studio-testing-project-template/6fc01e9d8ba3d4a8cb09a37a003c90478f45a963/NewAndroidModule/root/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /NewAndroidModule/root/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emmano/android-studio-testing-project-template/6fc01e9d8ba3d4a8cb09a37a003c90478f45a963/NewAndroidModule/root/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /NewAndroidModule/root/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emmano/android-studio-testing-project-template/6fc01e9d8ba3d4a8cb09a37a003c90478f45a963/NewAndroidModule/root/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /NewAndroidModule/root/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emmano/android-studio-testing-project-template/6fc01e9d8ba3d4a8cb09a37a003c90478f45a963/NewAndroidModule/root/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /NewAndroidModule/root/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | -------------------------------------------------------------------------------- /NewAndroidModule/root/res/values/strings.xml.ftl: -------------------------------------------------------------------------------- 1 | 2 | ${escapeXmlString(appTitle)} 3 | 4 | -------------------------------------------------------------------------------- /NewAndroidModule/root/res/values/styles.xml.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /NewAndroidModule/root/settings.gradle.ftl: -------------------------------------------------------------------------------- 1 | include ':${projectName}' 2 | -------------------------------------------------------------------------------- /NewAndroidModule/root/test/app_package/ApplicationTest.java.ftl: -------------------------------------------------------------------------------- 1 | package ${packageName}; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /NewAndroidModule/root/test/app_package/EspressoBasicActivityTest.java.ftl: -------------------------------------------------------------------------------- 1 | package ${packageName}; 2 | 3 | import android.test.ActivityInstrumentationTestCase2; 4 | 5 | import ${packageName}.${activityClass}; 6 | 7 | import static com.google.android.apps.common.testing.ui.espresso.Espresso.onView; 8 | import static com.google.android.apps.common.testing.ui.espresso.action.ViewActions.click; 9 | import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withText; 10 | 11 | public class ${activityClass}EspressoTest extends ActivityInstrumentationTestCase2<${activityClass}> { 12 | 13 | public ${activityClass}EspressoTest() { 14 | super(${activityClass}.class); 15 | } 16 | 17 | public void setUp() throws Exception { 18 | getActivity(); 19 | } 20 | 21 | public void testSomeTest() throws Exception { 22 | onView(withText("Hello world!")).perform(click()); 23 | } 24 | } -------------------------------------------------------------------------------- /NewAndroidModule/root/test/app_package/RobolectricBasicActivityTest.java.ftl: -------------------------------------------------------------------------------- 1 | package ${packageName}; 2 | 3 | import com.jeskeshouse.injectedtestrunner.InjectedTestRunner; 4 | 5 | import android.app.Activity; 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | import org.robolectric.Robolectric; 9 | import org.robolectric.annotation.Config; 10 | 11 | import static junit.framework.Assert.assertTrue; 12 | @Config(emulateSdk = 18) 13 | @RunWith(InjectedTestRunner.class) 14 | public class ${activityClass}RobolectricTest { 15 | 16 | @Test 17 | public void testSomething() throws Exception { 18 | Activity activity = Robolectric.buildActivity(${activityClass}.class).create().get(); 19 | assertTrue(activity != null); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /NewAndroidModule/root/test/app_package/RobotiumBasicActivityTest.java.ftl: -------------------------------------------------------------------------------- 1 | package ${packageName}; 2 | 3 | import com.robotium.solo.Solo; 4 | 5 | import android.test.ActivityInstrumentationTestCase2; 6 | 7 | import ${packageName}.${activityClass}; 8 | 9 | public class ${activityClass}RobotiumTest extends ActivityInstrumentationTestCase2<${activityClass}> { 10 | 11 | private Solo solo; 12 | 13 | public ${activityClass}RobotiumTest() { 14 | super(${activityClass}.class); 15 | } 16 | 17 | public void setUp() throws Exception { 18 | solo = new Solo(getInstrumentation(), getActivity()); 19 | } 20 | 21 | public void testSomeTest() throws Exception { 22 | assertTrue(solo.searchText("Hello world")); 23 | } 24 | 25 | @Override 26 | public void tearDown() throws Exception { 27 | solo.finishOpenedActivities(); 28 | } 29 | } -------------------------------------------------------------------------------- /NewAndroidModule/root/test/app_package/RobotiumTest: -------------------------------------------------------------------------------- 1 | package ${packageName}.robotium; 2 | 3 | import com.robotium.solo.Solo; 4 | 5 | import android.test.ActivityInstrumentationTestCase2; 6 | 7 | import ${packageName}.${activityClass} 8 | 9 | public class ${activityClass}Test extends ActivityInstrumentationTestCase2<${activityClass}> { 10 | 11 | private Solo solo; 12 | 13 | public ${activityClass}Test() { 14 | super(${activityClass}.class); 15 | } 16 | 17 | 18 | public void setUp() throws Exception { 19 | solo = new Solo(getInstrumentation(), getActivity()); 20 | } 21 | 22 | public void testSomeTest() throws Exception { 23 | assertTrue(solo.searchText("Hello world")); 24 | } 25 | 26 | @Override 27 | public void tearDown() throws Exception { 28 | solo.finishOpenedActivities(); 29 | } 30 | } -------------------------------------------------------------------------------- /NewAndroidModule/root/test/runner/RobolectricGradleTestRunner.java.ftl: -------------------------------------------------------------------------------- 1 | package ${packageName}; 2 | 3 | import org.junit.runners.model.InitializationError; 4 | import org.robolectric.AndroidManifest; 5 | import org.robolectric.RobolectricTestRunner; 6 | import org.robolectric.res.Fs; 7 | 8 | public class RobolectricGradleTestRunner extends RobolectricTestRunner { 9 | public RobolectricGradleTestRunner(Class testClass) throws InitializationError { 10 | super(testClass); 11 | } 12 | 13 | 14 | 15 | @Override 16 | protected AndroidManifest getAppManifest(org.robolectric.annotation.Config config) { 17 | String pwd = MyApplication.class.getProtectionDomain().getCodeSource().getLocation().getPath(); 18 | String root = pwd + "../../../../src/main/"; 19 | 20 | return new AndroidManifest( 21 | Fs.fileFromPath(root + "AndroidManifest.xml"), 22 | Fs.fileFromPath(root + "res"), 23 | Fs.fileFromPath(root + "assets")); 24 | } 25 | } -------------------------------------------------------------------------------- /NewAndroidModule/template.xml: -------------------------------------------------------------------------------- 1 | 2 | 116 | -------------------------------------------------------------------------------- /NewAndroidModule/template_new_project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emmano/android-studio-testing-project-template/6fc01e9d8ba3d4a8cb09a37a003c90478f45a963/NewAndroidModule/template_new_project.png -------------------------------------------------------------------------------- /NewAndroidProject/globals.xml.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /NewAndroidProject/recipe.xml.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | <#if makeIgnore> 7 | 9 | 10 | 11 | 13 | 14 | 16 | 17 | 19 | 20 | <#if sdkDir??> 21 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /NewAndroidProject/root/build.gradle.ftl: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | <#if mavenUrl != "mavenCentral"> 7 | maven { 8 | url '${mavenUrl}' 9 | } 10 | 11 | } 12 | dependencies { 13 | classpath 'com.android.tools.build:gradle:${gradlePluginVersion}' 14 | } 15 | } 16 | 17 | 18 | allprojects { 19 | repositories { 20 | <#if mavenUrl != "mavenCentral"> 21 | maven { 22 | url '${mavenUrl}' 23 | } 24 | 25 | } 26 | 27 | task wrapper(type: Wrapper) { 28 | gradleVersion = '1.12' 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /NewAndroidProject/root/gradle.properties.ftl: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Settings specified in this file will override any Gradle settings 5 | # configured through the IDE. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /NewAndroidProject/root/local.properties.ftl: -------------------------------------------------------------------------------- 1 | ## This file is automatically generated by Android Studio. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file should *NOT* be checked into Version Control Systems, 5 | # as it contains information specific to your local configuration. 6 | # 7 | # Location of the SDK. This is only used by Gradle. 8 | # For customization when using a Version Control System, please read the 9 | # header note. 10 | sdk.dir=${escapePropertyValue(sdkDir)} -------------------------------------------------------------------------------- /NewAndroidProject/root/project_ignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/workspace.xml 4 | .DS_Store 5 | /build 6 | -------------------------------------------------------------------------------- /NewAndroidProject/root/settings.gradle.ftl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emmano/android-studio-testing-project-template/6fc01e9d8ba3d4a8cb09a37a003c90478f45a963/NewAndroidProject/root/settings.gradle.ftl -------------------------------------------------------------------------------- /NewAndroidProject/template.xml: -------------------------------------------------------------------------------- 1 | 2 | 24 | -------------------------------------------------------------------------------- /NewAndroidProject/template_new_project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emmano/android-studio-testing-project-template/6fc01e9d8ba3d4a8cb09a37a003c90478f45a963/NewAndroidProject/template_new_project.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-android--studio--testing--project--template-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/941) 2 | android-studio-testing-project-template 3 | ======================================= 4 | 5 | The goal of this project is to speed up the setup of Robolectric, Robotuim, Double Espresso, Roboguice, and Mockito (along with some other nice libraries) in Android Studio. Since there is not built in support for Robolectric (just yet, hopefully) there is a lot of manual set up that has to be done. This project uses [jeske717's](https://github.com/jeske717) Robolectric-gralde plugin as well as his InjectedTestRunner (more about it later) found on Java Center. 6 | 7 | 8 | ### How is this different than the [Deckard-Gradle](https://github.com/robolectric/deckard-gradle) template provided by Robolectric? 9 | 10 | Deckard requires you to download their template and then customize things like the name of your project, module name, etc. This template is configured with the information provided when you go through the project creation flow. 11 | 12 | Tested on: 13 | 14 | - Mac OSX (Mavericks) 15 | - Android Studio 0.8.1, 0.8.5 and 1.0 16 | 17 | 18 | Set Up 19 | ======================================== 20 | 1. Clone the repo 21 | 2. Go to your Android Studio installation fodler, and then to `plugins/android/lib/templates/gradle-projects` 22 | 3. Create a backup of the `NewAndroidProject` and `NewProjectTemplate` folders (just in case you want to revert the changes) 23 | 4. Copy the two folders you just cloned into the `plugins/android/lib/templates/gradle-projects` 24 | 5. Open Android Studio and create a new project 25 | 6. After build.gradle gets executed by Android Studio, you would get a dialog saying that the *.iml file was updated and the project needs to be reloaded. Click on OK. (if the dialog doesn't show automatically you should manually run the `addRobolectricTestSourcesToIml` Gradle task (see below on how to run Gradle tasks)). 26 | 7. Upon restart the `robolectricTest/java` directory should be green. Now you need to run the `configureJUnitDefaultToUseRobolectricClasspath` Gradle task. To do so, go to `View-> Tool Windows->Gradle`. Expand the menu that has the name of your app, and double click on the `configureJUnitDefaultToUseRobolectricClasspath` task. Android studio will prompt the same message as before (requesting to reload the project). Click OK. 27 | 8. After Android Studio reloads, you should syncronize your project. `File->Syncrhonize`. 28 | 9. Run the `MyActivityRobolectricTest.java` inside the robolectricTest module. Right click on the method, `Run>testMethodName()` (the second option on the dropdown; the JUnit one). 29 | 10. Go to Android Studio > Preferences > Compiler > uncheck "Use in-process build" 30 | 11. As part of the Espresso configuration a custom Run Configuration is needed. They show how to do it on their docs [here](https://code.google.com/p/android-test-kit/wiki/Espresso) (look at the Android Studio picture). Make sure you check the "Show chooser dialog". It defaults to Emulator. 31 | 12. If everything is set up correclty, the test should run and pass. 32 | 13. Apparently Android Studio 1.0 defaults to `ActionBarActivity` regardless of your `minSdkVersion` selection. Make sure your `MainActivity` extends `Activity` or that you fix the Instrumentation tests to run on older versions of Android. 33 | 34 | InjectedTestRunner 35 | ======================================== 36 | 37 | `InjectedTestRunner` is the "glue" between Mockito and Roboguice. It basically looks for all `@Mock` on the test and automagically(thanks to jeske717) binds the mock instance to the correct `@Inject` on the implementation class. For more information go [here](https://github.com/jeske717/injected-test-runner) 38 | 39 | Known Limitations (We will try to fix) 40 | ======================================== 41 | 1. You might encounter some problems when trying to add a new package under `robolectricTest/java/your.app.package` 42 | 2. After you create a new test on a class that already contains tests, sometimes you will need to run the tests twice if you are running all the tests on the class. Synchronizing the project also works. It seems that gralde doesn't pick up the new added test on the first run. It works on the second run. (Step 10 above should fix this) 43 | 3. Make sure you create the project setting KitKat as `minSdk` to begin with. Tried using a different `minSdk` during the project creation flow and it broke the template. You can change your `minSdk` after you follow the steps above. 44 | 4. Specifying to use the GoogleInstrumentationTestRunner in `build.gradle`, as required by Espresso, makes the whole test suite run. Removing `testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"` from `build.gradle`, allows to run Robotium tests independently, but Espresso tests will not run. I will try to find a way to separate the runs. 45 | 5. In order to see the `robolectricTest` folder, you need to switch Android Studio from the `Android View` to the `Project View` 46 | 47 | 48 | TODO 49 | ======================================== 50 | 1. Be able to run Robotium and Espresso tests independently 51 | 52 | 53 | --------------------------------------------------------------------------------