Android Studio Instrumentation testing build variant

You can do testing on a different build variant; but only on one. The default is debug. See this: https://developer.android.com/studio/build/gradle-tips#change-the-test-build-type Currently only one Build Type is tested. By default it is the debug Build Type, but this can be reconfigured with: android { … testBuildType “staging” }

Mocking library/framework that works best in Android? [closed]

(Update: Mockito has added Android support as of version 1.9.5 and EasyMock has added Android support as of version 3.2 by factoring out those bits that generate code at runtime and making them pluggable, e.g. by using dexmaker instead of cglib.) Except for android-mock mentioned by DixonD (which is a fairly young, unproven library), there … Read more

Espresso intent test failing

I had the same problem and solved it by using IntentsTestRule instead of ActivityTestRule. IntentsTestRule is a subclass of ActivityTestRule. Set up your @Rule which creates the activity like so: @Rule public IntentsTestRule<MyActivity> mActivity = new IntentsTestRule<MyActivity>(MyActivity.class) { @Override protected Intent getActivityIntent() { … } }; See the following project for more information: https://github.com/googlesamples/android-testing/tree/master/ui/espresso/IntentsBasicSample