I have setup Jake Wharton's double espresso testing utility in my Android project but when I run the test class I get the following error:
junit.framework.AssertionFailedError: Exception in constructor: testClickActionBarItems (java.lang.NoClassDefFoundError: com.example.android.activities.TrialActivity at com.example.android.activities.TrialActivityTest.(TrialActivityTest.java:23)
My test class is as follows:
@LargeTest
public class TrialActivityTest extends ActivityInstrumentationTestCase2<TrialActivity>{
@SuppressWarnings("deprecation")
public SectionsEspressoTest() {
super(TrialActivityTest.class);
}
@Override
public void setUp() throws Exception {
super.setUp();
// Espresso will not launch our activity for us, we must launch it via getActivity().
getActivity();
}
public void testClickActionBarItems() {
onView(withId(R.id.action_search))
.perform(click());
}
}
I have added the necessary components to my build.gradle file:
testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
androidTestCompile('com.jakewharton.espresso:espresso:1.1-r3') {
exclude group: 'org.hamcrest'
}
androidTestCompile('com.jakewharton.espresso:espresso-support-v4:1.1-r3') {
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'org.hamcrest'
}
The groups above are excluded as they are used in other libraries in my project. I'm using version gradle 0.10 and Android Studio 0.5.8. If anyone has any idea what I'm doing wrong I'd greatly appreciate the help.