I'm trying to set up a simple test using espresso and the following errors appear:
Code:
importandroid.content.Context;importandroid.os.Bundle;importandroid.support.annotation.Nullable;importandroid.support.test.InstrumentationRegistry;importandroid.support.test.espresso.core.deps.guava.annotations.VisibleForTesting;importandroid.support.test.rule.ActivityTestRule;importandroid.support.test.runner.AndroidJUnit4;importandroid.support.v4.app.Fragment;importandroid.support.v7.app.AppCompatActivity;importandroid.test.suitebuilder.annotation.LargeTest;importandroid.test.suitebuilder.annotation.MediumTest;importandroid.test.suitebuilder.annotation.SmallTest;importandroid.widget.FrameLayout;importcom.google.gson.JsonObject;importcom.holandago.urbbox.b.LoginActivity;importcom.holandago.urbbox.b.MainActivity;importcom.holandago.urbbox.b.R;importcom.holandago.urbbox.b.model.user.User;importcom.holandago.urbbox.b.ride_details.RideDetailsFragment;importcom.holandago.urbbox.b.utils.JsonUtils;importcom.mapbox.mapboxsdk.maps.SupportMapFragment;importorg.junit.Before;importorg.junit.Rule;importorg.junit.Test;importorg.junit.runner.RunWith;importstaticandroid.support.test.espresso.Espresso.onView;importstaticandroid.support.test.espresso.action.ViewActions.click;importstaticandroid.support.test.espresso.action.ViewActions.closeSoftKeyboard;importstaticandroid.support.test.espresso.action.ViewActions.typeText;importstaticandroid.support.test.espresso.assertion.ViewAssertions.matches;importstaticandroid.support.test.espresso.matcher.ViewMatchers.withId;importstaticandroid.support.test.espresso.matcher.ViewMatchers.withText;importstaticorg.hamcrest.CoreMatchers.equalTo;importstaticorg.hamcrest.CoreMatchers.is;importstaticorg.hamcrest.MatcherAssert.assertThat;@RunWith(AndroidJUnit4.class)@LargeTestpublicclassMapsActivityTestextendsAppCompatActivity{@RulepublicActivityTestRule<LoginActivity>activityTestRule=newActivityTestRule<>(LoginActivity.class);@TestpublicvoidTestEmail(){onView(withId(R.id.contact)).perform(click()).check(matches(withId(R.id.contact_us_container)));}}
Gradle:
buildscript{repositories{maven{url'https://maven.fabric.io/public'}}dependencies{classpath'io.fabric.tools:gradle:1.+'}}applyplugin:'com.android.application'applyplugin:'com.neenbedankt.android-apt'applyplugin:'io.fabric'repositories{maven{url'https://maven.fabric.io/public'}}android{signingConfigs{config{keyAlias'bAndroid'keyPassword'abraao123'storePassword'abraao123'storeFilefile('../cer/android.jks')}}compileSdkVersion23buildToolsVersion"23.0.3"
lintOptions {
// but continue the build even when errors are found:
abortOnError false
}
defaultConfig {
applicationId "com.holandago.urbbox.b"
minSdkVersion 15
targetSdkVersion 23
versionCode 66
versionName "2.9.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
debug {
debuggable true
testCoverageEnabled = true
}
release {
debuggable false
signingConfig signingConfigs.config
ext.betaDistributionEmails = "[email protected], [email protected], [email protected], [email protected]"
ext.betaDistributionReleaseNotes = "Release Notes for this build."
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'LICENSE.txt'
exclude 'META-INF/maven/com.google.guava/guava/pom.properties'
exclude 'META-INF/maven/com.google.guava/guava/pom.xml'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
compile('com.crashlytics.sdk.android:crashlytics:2.5.6@aar') {
transitive = true;
}
testCompile 'junit:junit:4.12'
testCompile 'org.robolectric:robolectric:3.0'
testCompile 'org.mockito:mockito-all:1.10.19'
androidTestCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support:support-annotations:23.4.0'
androidTestCompile 'com.android.support.test:runner:0.4.1'
androidTestCompile 'com.android.support.test:rules:0.4.1'
apt 'com.jakewharton:butterknife-compiler:8.0.1'
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.koushikdutta.ion:ion:1.3.8'
compile 'com.google.code.gson:gson:2.4'
compile 'com.parse.bolts:bolts-android:1.+'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.mixpanel.android:mixpanel-android:4.6.4'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.jakewharton:butterknife:8.0.1'
androidTestCompile 'com.android.support.test:runner:0.3'
androidTestCompile 'com.android.support.test:rules:0.3'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.+'
androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.+'
androidTestCompile 'com.android.support.test.espresso:espresso-web:2.+'
compile('com.mapbox.mapboxsdk:mapbox-android-sdk:4.1.0-beta.1@aar') {
transitive = true
}
compile('com.mapbox.mapboxsdk:mapbox-android-services:1.1.0@aar') {
transitive = true
}
}
Someone who knows or has solved please help me. Many thanks!
testEmail error:
java.lang.RuntimeException: Can not create handler inside thread that has not called Looper.prepare ()