Android 为什么我找不到测试?

Android 为什么我找不到测试?,android,android-activity,android-testing,android-espresso,Android,Android Activity,Android Testing,Android Espresso,使用以下配置执行/gradlew clean connectedAndroidTest时。。。我发现未找到任何测试 这是我的身材。格雷德尔: buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:0.14.1' classpath 'com.github.jcandksolutions

使用以下配置执行
/gradlew clean connectedAndroidTest
时。。。我发现
未找到任何测试

这是我的身材。格雷德尔:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.14.1'
        classpath 'com.github.jcandksolutions.gradle:android-unit-test:2.0.1'
    }
}

allprojects {
    repositories {
        maven { url "http://dl.bintray.com/populov/maven" }
        jcenter()
    }
}

apply plugin: 'com.android.application'

android {
    packagingOptions {
        exclude 'LICENSE.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/LGP2.1'
        exclude 'META-INF/LGPL2.1'
    }
    compileSdkVersion 21
    buildToolsVersion "21.1.0"

    lintOptions {
        abortOnError false
    }
    defaultConfig {
        applicationId "com.example"
        minSdkVersion 9
        targetSdkVersion 21
        versionCode 2
        versionName "0.1"
        testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
    }

    buildTypes {
        release {
            runProguard false
        }
    }

    sourceSets {
        androidTest {
            setRoot('src/espressoTest')
        }
    }
}

apply plugin: 'android-unit-test'

dependencies {
    // App
    compile 'com.android.support:support-v4:21.0.0'
    compile 'com.android.support:appcompat-v7:21.0.0'
    compile 'com.android.support:gridlayout-v7:18.0.0'
    compile 'joda-time:joda-time:2.3'
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'de.greenrobot:eventbus:2.0.2'
    compile 'com.squareup.dagger:dagger:1.1.0'
    compile 'com.squareup.dagger:dagger-compiler:1.1.0'
    compile 'com.google.android.gms:play-services:6.1.71'
    compile 'com.squareup.okhttp:okhttp:2.0.0'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
    compile 'com.squareup.retrofit:retrofit:1.6.1'
    compile 'com.squareup.picasso:picasso:2.3.4'
    compile 'com.squareup:otto:1.3.5'
    compile 'com.google.guava:guava:18.0'
    compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
    compile 'com.viewpagerindicator:library:2.4.1@aar'
    compile 'com.wrapp.floatlabelededittext:library:0.0.3'
    compile 'com.daimajia.swipelayout:library:1.0.7@aar'
    compile 'com.github.flavienlaurent.datetimepicker:library:0.0.2'
    compile 'info.hoang8f:android-segmented:1.0.2'
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.daimajia.easing:library:1.0.0@aar'
    compile 'com.daimajia.androidanimations:library:1.1.2@aar'
    compile 'com.balysv.materialmenu:material-menu-toolbar:1.4.0'

    // Espresso
    androidTestCompile files('lib/espresso-1.1.jar', 'lib/testrunner-1.1.jar', 'lib/testrunner-runtime-1.1.jar')
    androidTestCompile 'com.google.guava:guava:14.0.1'
    androidTestCompile 'org.hamcrest:hamcrest-integration:1.1'
    androidTestCompile 'org.hamcrest:hamcrest-core:1.1'
    androidTestCompile 'org.hamcrest:hamcrest-library:1.1'

    // Robolectric
    testCompile('junit:junit:4.11') {
        exclude module: 'hamcrest-core'
    }
    testCompile files('lib/robolectric-2.4-SNAPSHOT-jar-with-dependencies.jar')
    testCompile 'org.mockito:mockito-all:1.9.5'
    testCompile 'com.squareup:fest-android:1.0.+'
    testCompile 'com.googlecode.catch-exception:catch-exception:1.2.0'
}

tasks.findByName("assembleDebug").dependsOn("testDebugClasses")
这是src/espressoTest下的测试等级:

package com.example;

import android.test.ActivityInstrumentationTestCase2;
import android.test.suitebuilder.annotation.LargeTest;

import com.betavalue.myvalue.MainActivity;
import com.betavalue.myvalue.R;

import static com.google.android.apps.common.testing.ui.espresso.Espresso.onView;
import static com.google.android.apps.common.testing.ui.espresso.assertion.ViewAssertions.matches;
import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withId;
import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withText;

@LargeTest
public class MainEspressoTest extends ActivityInstrumentationTestCase2<MainActivity> {

    @SuppressWarnings("deprecation")
     public MainEspressoTest() {
       // This constructor was deprecated - but we want to support lower API levels.
       super(MainActivity.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 testCheckText() {
        onView(withId(R.id.text))
            .check(matches(withText("Hello Espresso!")));
      }
}
package.com.example;
导入android.test.ActivityInstrumentationTestCase2;
导入android.test.suitebuilder.annotation.LargeTest;
导入com.betavalue.myvalue.main活动;
导入com.betavalue.myvalue.R;
导入静态com.google.android.apps.common.testing.ui.espresso.espresso.onView;
导入静态com.google.android.apps.common.testing.ui.espresso.assertion.viewsassertions.matches;
导入静态com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withId;
导入静态com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withText;
@最大的
公共类MainEspressoTest扩展ActivityInstrumentationTestCase2{
@抑制警告(“弃用”)
公共主咖啡馆(){
//此构造函数已被弃用-但我们希望支持较低的API级别。
超级(MainActivity.class);
}
@凌驾
public void setUp()引发异常{
super.setUp();
//Espresso不会为我们启动活动,我们必须通过getActivity()启动活动。
getActivity();
}
公共void testCheckText(){
onView(带id(R.id.text))
.检查(匹配(使用文本(“Hello Espresso!”));
}
}
MainActivity
是一个空活动,只是为了尝试测试


有什么想法吗?
AndroidManifest.xml上是否有我可能丢失的内容?

如果有人出现此问题。。。它只是在再次从我的存储库中提取时自动解决的


它必须和Android Studio cache做些什么。

我用的是杰克·沃顿的双份浓缩咖啡。如果没有别的办法,也许可以试试。androidTestCompile('com.jakewharton.espresso:espresso:1.1-r3')、androidTestCompile('com.jakewharton.espresso:espresso-support-v4:1.1-r3')此用户使其正常工作