错误=无法找到以下仪器信息:ComponentInfo{ }

2024-03-14

我试图通过浓缩咖啡测试,但我不断收到此错误:

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

and

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

测试启动屏幕.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!")));
        }
    }

构建.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 无法识别它们一样。

任何帮助都很棒,谢谢!


您需要检查您的设备上安装了哪些仪器包:

 adb shell pm list instrumentation

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

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

错误=无法找到以下仪器信息:ComponentInfo{ } 的相关文章

  • 如何以编程方式启用小米应用程序的自动启动

    我想知道小米是否可以提供任何应用程序的后台服务 我的应用程序中有需要始终在后台运行的服务 在除小米之外的所有设备中都工作正常 如何以编程方式完成 也适用于小米 oppo vivo 和 oneplus 手机 try Intent intent
  • 当 Android 上的脸部靠近屏幕时,以编程方式关闭屏幕

    我的应用程序是一个拨号器 当用户将手机靠近头部时 我需要关闭屏幕并防止单击控件 就像本机 Android 拨号器行为一样 我需要什么 API 级别以及如何以正确的方式做到这一点 我通过反汇编一个非常著名的 VoIP 应用程序找到了解决方案
  • 如何组合 3 个或更多 CompletionStages?

    如果有 2 个 CompletionStages 我可以将它们与thenCombine method CompletionStage a aCompletionStage getA CompletionStage b bCompletion
  • Android 生命周期哪个事件在生命周期中只触发一次?

    我读过一些博客并访问了一些网站 我想知道哪个事件在生命周期中只触发了一次 阅读博客后我意识到onCreate 方法在生命周期内仅触发一次 我不知道我是对还是错 现在我的问题是 我想触发任何仅在我更改横向或纵向方向时触发一次的事件 而不是在启
  • Java:如果数组大小未知,如何初始化?

    我要求用户输入 1 到 100 之间的一些数字并将它们分配到一个数组中 数组大小未初始化 因为它取决于用户输入数字的次数 我应该如何分配数组长度 如果用户输入 5 6 7 8 9 5 个数字 则 int list becomes int l
  • 直接在应用程序中评价 Google Play 应用程序 [重复]

    这个问题在这里已经有答案了 我需要在我的 Android 应用程序中设置费率选项 我找到了这个link http www androidsnippets com prompt engaged users to rate your app i
  • SwingUtilities.invokeLater

    我的问题与SwingUtilities invokeLater 我应该什么时候使用它 每次需要更新 GUI 组件时都必须使用吗 它到底有什么作用 是否有替代方案 因为它听起来不直观并且添加了看似不必要的代码 Do I have to use
  • 如何从MediaCodec获取解码格式?

    我正在与MediaCodec 我用它来解码 mp4 video MediaCodec 将视频解码为YUV格式 但我需要得到RGBA 一切都很好 但我发现有几种可能的格式 例如YUV420 YUV422等等 因此 据我所知 要进行转换 我需要
  • 如何修补更新 Android Studio (0.80 -> 0.81)?

    我安装了 Android Studio Beta v0 8 0 并下载了 v0 8 1 因为 IDE 不会自动下载 v0 80 并使用新版本修补 Android Studio 的预览系列自动做到了这一点 从他们的网页 http tools
  • 从 Java 应用程序读取的文件是否会调用系统调用?

    我的理解是 请求文件系统路径 例如 aFile 的用户应用程序将调用文件系统并获取所请求文件的虚拟地址 然后应用程序将尝试以该地址作为参数 即作为 CPU 指令 进行读 写操作 执行读取命令时 内存管理单元会将该地址转换为物理地址 并查看页
  • Java 中的连接路径

    In Python我可以连接两条路径os path join os path join foo bar gt foo bar 我正在尝试在 Java 中实现相同的目标 而不用担心是否OS is Unix Solaris or Windows
  • 尝试通过 Java 8 中的 JDBC-ODBC 连接到 .accdb 文件时出现 ClassNotFoundException

    我正在 Eclipse EE IDE 中的 Java 项目中工作 我必须在其中查询 accdb文件 问题是当我尝试加载驱动程序然后连接到数据库时 它给了我一个异常错误 My code try String filePath myfilepa
  • Android - 按下后退按钮时停止 AsyncTask 并返回到上一个 Activity

    我有一个 AsyncTask 我希望它在按下后退按钮时停止执行 我还希望应用程序返回到之前显示的 Activity 看来我已经成功停止了任务 但应用程序没有返回到之前的活动 有任何想法吗 这是我的代码的摘录 private class My
  • 如何获取在代码中 attrs.xml 中创建的枚举

    我创建了一个自定义视图 找到它here https bitbucket org informatic0re awesome font iconview 具有枚举类型的可声明样式属性 在 xml 中 我现在可以为我的自定义属性选择枚举条目之一
  • Java环境变量设置方法

    我已将以下行插入 bash profile export GOOGLE APPLICATION CREDENTIALS Users jun Downloads export PATH PATH GOOGLE APPLICATION CRED
  • Zookeeper 未启动,nohup 错误

    我已经下载了zookeeper 3 4 5 tar gz 解压后我将conf zoo cfg写为 tickTime 2000 dataDir var zookeeper clientPort 2181 现在我尝试通过 bin zkServe
  • Bipush 在 JVM 中如何工作?

    我知道 iload 接受整数 1 到 5 但是如何使用 bipush 指令扩展到更高的数字 特定整数如何与字节码一起存储 有几种不同的指令可用于推送整数常量 最小的是iconst 指令 这些只是一个字节 因为该值是在操作码本身中编码的 ic
  • 在edittext android中插入imageview

    我想将 imageview 放在 edittext 中 可能吗 我检查了 evernote 应用程序 它能够将照片放在编辑文本部分 我想让我的应用程序完全相同 我如何才能将从图库中选择的图像视图放入编辑文本中 我首先尝试将 imagevie
  • ImageIO.read(...) - 非常慢,有更好的方法吗?

    我正在加载大量将在我的应用程序中使用的图标 我计划在服务器启动时从 jar 中加载所有这些 然而 由于数百张图像加起来刚刚超过 9MB 执行此任务仍然需要 30 秒多的时间 我现在正在一个单独的线程中执行此操作 但这让我想知道我是否在代码中
  • RetentionPolicy CLASS 与 RUNTIME

    两者之间有什么实际区别RetentionPolicy CLASS and RetentionPolicy RUNTIME 看起来两者都被记录到字节码中 并且无论如何都可以在运行时访问 无论如何 两者都可以在运行时访问 那不是那个javado

随机推荐