Eddy Charry
Eddy Charry

Reputation: 207

"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

Upvotes: 1

Views: 618

Answers (1)

Eddy Charry
Eddy Charry

Reputation: 207

ok finally i get the solution for this, the proguard was the problem, you can exclude or remove the proguard while testing and all will be running just fine, hope it will help more people

Upvotes: 1

Related Questions