简体   繁体   中英

“Empty suite” with espresso test

I am trying to run a simple "hello!" test but I get the empty test suit, I can find the problem this is my 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'
}

And this is the test:

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")));
}

}

this is the 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.

I also edit configuration an set the specific instrument runner : android.support.test.runner.AndroidJUnitRunner

when I do it I get this in the 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.

I hope you can help me... Thanks

好的,最后我得到了解决方案,问题是proguard,您可以在测试时排除或删除proguard,并且一切都会正常进行,希望它将对更多人有所帮助

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM