我正在尝试使用Espresso编写测试用例.
我使用的是Android Studio 1.5.1(稳定频道),Gradle插件1.5,Gradle 2.7.
问题是Android Studio无法识别与Espresso(而不仅仅是)相关的任何导入
所以,我试图清理项目,重建,使缓存无效并重新启动,但没有.
我在我的app模块中添加了这些依赖项:
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1' androidTestCompile 'com.android.support:support-annotations:23.1.1' androidTestCompile 'com.android.support.test:runner:0.4.1' androidTestCompile 'com.android.support.test:rules:0.4.1'
我在defaultConfig中添加了runner:
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
我在androidTest文件夹下创建了测试套件类:
我做错了什么?
UPDATE
这是我的build.gradle的(部分):
apply plugin: 'com.android.application' apply plugin: 'com.neenbedankt.android-apt' android { compileSdkVersion 23 buildToolsVersion '23.0.2' defaultConfig { minSdkVersion 15 targetSdkVersion 23 versionCode 5 versionName '1.4' testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 } buildTypes { //my build type configs } packagingOptions { exclude 'Meta-INF/services/javax.annotation.processing.Processor' exclude 'Meta-INF/LICENSE' exclude 'Meta-INF/LICENSE.txt' exclude 'Meta-INF/NOTICE' exclude 'Meta-INF/NOTICE.txt' } lintOptions { disable 'InvalidPackage' } dexOptions { incremental true preDexLibraries = false jumboMode = false javaMaxHeapSize "2g" } } dependencies { compile fileTree(include: ['*.jar'],dir: 'libs') compile 'com.viewpagerindicator:library:2.4.1' compile project(':libraries:RITracking') compile 'com.android.support:support-v4:23.1.1' compile 'com.android.support:design:23.1.1' compile 'com.android.support:support-annotations:23.1.1' compile 'com.android.support:recyclerview-v7:23.1.1' compile 'com.android.support:cardview-v7:23.1.1' compile 'com.android.support:gridlayout-v7:23.1.1' compile 'com.google.code.gson:gson:2.5' compile 'com.google.android.gms:play-services-plus:8.4.0' compile 'com.google.android.gms:play-services-base:8.4.0' compile 'de.greenrobot:eventbus:2.4.1' compile 'com.squareup.retrofit:retrofit:1.9.0' compile 'com.squareup.okhttp:okhttp:2.7.2' compile 'com.facebook.android:facebook-android-sdk:4.9.0' compile 'com.cocosw:bottomsheet:1.2.0@aar' //Bottom Sheet that implement material design used for ShareDialog compile 'com.github.bumptech.glide:glide:3.6.1' //Glide library compile 'com.googlecode.libphonenumber:libphonenumber:7.2.3' //Library used to parse/merge phones number to E164 format compile 'me.leolin:ShortcutBadger:1.1.3@aar' //Used to show badge on application icon,library is optimized to work on most of devices compile 'com.stripe:stripe-android:1.0.3' //Stripe payment gateway,used to integrate credit card payment provided 'org.projectlombok:lombok:1.16.6' apt "org.projectlombok:lombok:1.16.6" compile 'com.jakewharton:butterknife:7.0.1' apt "com.jakewharton:butterknife:7.0.1" compile 'de.greenrobot:greendao:2.1.0' //Green Dao library is ORM implementation for Android sql lite compile files('libs/libammsdk.jar') compile files('libs/apptimize-android-2.9.1.jar') testCompile 'junit:junit:4.12' androidTestCompile "com.android.support:support-annotations:23.1.1" androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1' androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2.1' androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.1') { exclude group: 'com.android.support',module: 'appcompat' exclude group: 'com.android.support',module: 'support-v4' exclude module: 'recyclerview-v7' } androidTestCompile 'com.android.support.test:runner:0.4.1' androidTestCompile 'com.android.support.test:rules:0.4.1' }