Ilya Sosnin
Ilya Sosnin

Reputation: 41

Test running failed: Unable to find instrumentation info for: ComponentInfo

Everytime I try to run my tests the console says this:

Started running tests  
Test running failed: Unable to find instrumentation info for: ComponentInfo{com.rit.andrey.service.test/android.test.InstrumentationTestRunner}
Empty test suite.

My project structure looks like

Build.gradle file

apply plugin: 'com.android.application'

android {
    signingConfigs {
        release {
            <config>
        }
        debug {
            <config>
        }
    }
    compileSdkVersion 25
    buildToolsVersion '25.0.1'
    defaultConfig {
        applicationId "com.rit.andrey.service"
        minSdkVersion 16
        versionCode 1
        versionName "1.3.0"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
        }
    }
    packagingOptions {
        /----/
    }
    dexOptions {
        preDexLibraries = false
        javaMaxHeapSize "5g"
    }
}

dependencies {
    /---/
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    }
    testCompile 'junit:junit:4.12'
}

Test class looks like this

@LargeTest
@RunWith(AndroidJUnit4.class)
public class LoginActivityTest {
    @Rule
    public ActivityTestRule<LoginActivity> mActivityTestRule = new ActivityTestRule<>(LoginActivity.class);

    @Test
    public void testLoginActivityTest() {
        onView(withId(R.id.synch_button)).check(matches(isDisplayed()));
}

All Build Variants are "Debug"

I tried to test another app on this device and everything was OK

Runners:

shell@P350:/ $ pm list instrumentation
        instrumentation:com.mu.rit.mmlib.test/android.test.InstrumentationTestRunner (target=com.mu.rit.mmlib.test)
        instrumentation:com.rit.andrey.service/android.test.InstrumentationTestRunner (target=com.rit.andrey.service)
        instrumentation:com.rit.andrey.service.test/android.support.test.runner.AndroidJUnitRunner (target=com.rit.andrey.service)
        instrumentation:com.rit.unittestingapp.test/android.support.test.runner.AndroidJUnitRunner (target=com.rit.unittestingapp)

P.S. Android Studio 2.3.3

Upvotes: 2

Views: 2053

Answers (2)

Suhyun Kim
Suhyun Kim

Reputation: 121

According to the documentation from here (https://developer.android.com/training/testing/espresso/setup.html#set-instrumentation-runner), you are missing annotations and runner.

// App's dependencies, including test
compile 'com.android.support:support-annotations:22.2.0'

// Testing-only dependencies
androidTestCompile 'com.android.support.test:runner:1.0.1'
androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.1'

Upvotes: 0

Bjelis
Bjelis

Reputation: 116

Happened to me. Uninstalling the app on that device, reinstalling fresh build and then running the tests seems to have helped.

Upvotes: 1

Related Questions