错误=无法找到以下设备的检测信息:ComponentInfo {} [英] Error=Unable to find instrumentation info for: ComponentInfo{ }

查看:128
本文介绍了错误=无法找到以下设备的检测信息:ComponentInfo {}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试接受意式浓缩咖啡测试,但我不断收到此错误:

I am trying to stand up espresso tests but I keep getting this error:

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

它曾经工作过一次,但是我无法正确重新创建报告.他们只是空白,没有进行任何测试. 我已经尝试了许多命令,包括

It worked once, but I can't get the reports to recreate correctly. They are just blank, didn't test anything. I've tried a plethora of commands including

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

这是我的代码段:

    <?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"/>

    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无法识别它们.


If it means anything - the attributes of <instrumentation> in the manifest are colored red as if IntelliJ does not recognize them.

任何帮助都很好,谢谢!

Any help is great, thanks!

推荐答案

您需要检查设备上已安装了哪些检测包:

You need to check which instrumentation packages have been installed on your device:

 adb shell pm list instrumentation

然后验证 com.mikeestrada.test 是否在那里实际列出.

Then verify whether com.mikeestrada.test is actually listed there.

这篇关于错误=无法找到以下设备的检测信息:ComponentInfo {}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆