I'm having an issue with Android Espresso testing. I can't seem to be able to have access to "AndroidJUnit4.class". The code below is giving me "@RunWith(AndroidJUnit4.class)" as "Cannot resolve symbol AndroidJUnit4" .
import android.test.suitebuilder.annotation.LargeTest;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
@LargeTest
public class HelloWorldEspressoTest {
@Rule
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule(MainActivity.class);
@Test
public void listGoesOverTheFold() {
onView(withText("Hello world!")).check(matches(isDisplayed()));
}
}
I know this is is related to the build.gradle file settings but I don't know whats wrong. Below is a copy of what I'm using.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "example.com.myapp"
minSdkVersion 22
targetSdkVersion 22
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'
testCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
androidTestCompile 'com.android.support.test:runner:0.4.1'
androidTestCompile 'com.android.support.test:rules:0.4'
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
compile project(':volleylibrarygitpull')
}
configurations.all {
resolutionStrategy.force 'com.android.support:support-annotations:22.2.0'
}
I would really appreciate if someone could tell me what's wrong with my build.gradle file in order for me to use Espresso testing framework. I need to support material design so a lower API level then 23.0.1 that has cardview, recyclerview will do.
Aucun commentaire:
Enregistrer un commentaire