"Empty suite" 浓缩咖啡测试

"Empty suite" with espresso test

我正在尝试 运行 一个简单的 "hello!" 测试,但我得到的是空测试服,我可以找到问题,这是我的 gradle:

apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"

defaultConfig {
    applicationId "sku1l.eccc"
    minSdkVersion 17
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner
    "android.support.test.runner.AndroidJUnitRunner"
    packagingOptions {

        exclude 'LICENSE.txt'

    }
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:support-annotations:22.2.0'
androidTestCompile 'com.android.support:support-annotations:22.2.0'

androidTestCompile ('com.android.support.test.espresso:espresso-core:2.2'){
    exclude group: 'javax.inject'
}
androidTestCompile 'com.android.support.test:runner:0.3'
// androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2'
}

这是测试:

import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;




 @RunWith(AndroidJUnit4.class)

 public class ApplicationTest   {


@Rule
public ActivityTestRule<MainActivity> mActivityTestRule= new     ActivityTestRule<>(MainActivity.class);

@Test
public void testVisibility() {
    onView(withText("Hello"))
            .check(matches(isDisplayed()));
    onView(withId(R.id.Hello)).check(matches(withText("Hello")));
}

}

这是logcat

Success


  Uploading file
local path:     C:\Users\sku1l\AndroidStudioProjects\elparche\app\build\outputs\apk\app-debug-androidTest-unaligned.apk
remote path: /data/local/tmp/sku1l.elparche.test
No apk changes detected. Skipping file upload, force stopping package instead.
DEVICE SHELL COMMAND: am force-stop sku1l.elparche.test
Running tests
Test running startedFinish
Empty test suite.

我还编辑配置并设置特定仪器 运行ner : android.support.test.runner.AndroidJUnitRunner

当我这样做时,我在 logcat

中得到了这个
Running tests
Test running startedTest running failed: Unable to find instrumentation info for:     ComponentInfo{sku1l.elparche.test/android.support.test.runner.AndroidJUnitRunner}
 Empty test suite.

希望你能帮助我...谢谢

好的,我终于找到了解决方案,proguard 是问题所在,您可以在测试时排除或删除 proguard,一切都会 运行 就好了,希望它能帮助更多人