Подтвердить что ты не робот

Ошибка = Невозможно найти информацию о приборе для: ComponentInfo {}

Я пытаюсь встать на тесты эспрессо, но я продолжаю получать эту ошибку:

INSTRUMENTATION_STATUS: Error=Unable to find instrumentation info for: ComponentInfo{com.mikeestrada.test/android.test.InstrumentationTestRunner}

Он работал один раз, но я не могу правильно восстановить отчеты. Они просто пустые, ничего не тестировали. Я пробовал множество команд, включая

adb shell am instrument -w -r com.mikeestrada.test/android.test.InstrumentationTestRunner

и

adb shell am instrument -w -r   com.mikeestrada.test/com.google.android.apps.common.testing.testrunner.GoogleInstrumentation TestRunner

Вот мои фрагменты кода:

AndroidManifest.xml

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.myapplication"
        android:versionCode="1"
        android:versionName="1.0" >

        <uses-sdk
            android:minSdkVersion="7"
            android:targetSdkVersion="19" />

        <application
            android:allowBackup="true"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" >
            <activity
                android:name="com.example.myapplication.MainActivity"
                android:label="@string/app_name" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />

                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
        </application>
                <instrumentationandroid:name="com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"                   
    android:targetPackage="com.mikeestrada.test"/>

TestStartScreen.java

    package com.mikeestrada.test;

    import android.test.ActivityInstrumentationTestCase2;
    import android.test.ActivityUnitTestCase;
    import android.test.AndroidTestCase;
    import android.test.suitebuilder.annotation.LargeTest;
    import android.view.View;

    import com.example.myapplication.MainActivity;
    import com.example.myapplication.R;
    import com.google.android.apps.common.testing.ui.espresso.Espresso;
    import com.google.android.apps.common.testing.ui.espresso.ViewAssertion;
    import com.google.android.apps.common.testing.ui.espresso.ViewInteraction;
    import com.google.android.apps.common.testing.ui.espresso.action.ViewActions;
    import com.google.android.apps.common.testing.ui.espresso.assertion.ViewAssertions;
    import com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers;

    import junit.framework.Assert;
    import org.hamcrest.Matcher;


    public class TestStartScreen extends ActivityInstrumentationTestCase2<MainActivity> {

        public TestStartScreen() {
            super(MainActivity.class);
        }

        @LargeTest
        public void testHelloWorld(final Matcher<View> viewMatcher) {
            // Find
            //ViewInteraction button1 = onView(ViewMatchers.withId(R.id.button1)); // Find the button
            ViewInteraction helloWorldText = Espresso.onView(ViewMatchers.withText("Hello world!")); // Find the text

            // Action
            //button1.perform(ViewActions.click()); // Click the button
            helloWorldText.perform(ViewActions.typeText("Bye World!"));
            Espresso.onView(ViewMatchers.withText(R.id.withText));

            // Check
            helloWorldText.check(ViewAssertions.matches((ViewMatchers.isDisplayed())));  // Hello world text is hidden

            //Espresso.onView(withId(R.id.my_view)).check(matches(withText("Hello  world!")));
        }
    }

build.gradle

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.7.+'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.0"

    defaultConfig {
        minSdkVersion 7
        targetSdkVersion 19
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            assets.srcDirs = ['assets']
        }
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:+'
    instrumentTestCompile files('libs/espresso-1.1-bundled.jar')
}
android {
    defaultConfig {
        testInstrumentationRunner     "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
    }
}
task wrapper (type: Wrapper) {
    gradlerVersion = '1.9'
}

Если это означает что-либо - атрибуты <instrumentation> в манифесте окрашены в красный цвет, как если бы IntelliJ не распознавал их.

Любая помощь велика, спасибо!

4b9b3361

Ответ 1

Вам нужно проверить, какие аппаратные пакеты установлены на вашем устройстве:

 adb shell pm list instrumentation

Затем проверьте, действительно ли там указан com.mikeestrada.test.

Ответ 2

Если пакет инструментария отсутствует, установите его с помощью следующей команды:

$ gradle :{$project}:installDebugAndroidTest

gradle task showing location of installDebugAndroidTest

Ответ 3

Глядя на ваш файл build.gradle, проблема в том, что в разделе defaultConfig у вас нет следующей конфигурации:

testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"

Для работы Espresso требуется GoogleInstrumentationTestRunner.

Также с системой сборки gradle вам не нужно использовать AndroidManifest.xml для тестового проекта, потому что он сгенерирован автоматически.

Ответ 4

Кроме того, выглядит как ваш пакет приложений com.mikeestrada. Поэтому в AndroidManifest установите android:targetPackage как android:targetPackage="com.mikeestrada".

Надеюсь, это поможет.

Ответ 5

Проблема в том, что вам не хватает места:

instrumentationandroid:name

должен быть

instrumentation android:name