Google Espresso java.lang.RuntimeException:无法启动意图Intent {act = android.intent.action.MAIN

use*_*003 9 eclipse android runtimeexception android-espresso

我是Espresso UI测试的新手.

我在运行测试时遇到此错误(ADT Eclipse IDE).

该应用程序已经开发,启动应用程序时会有很多请求.无法重写应用程序.但我需要找到测试此UI的方法,即使组件的加载有任何延迟.

        java.lang.RuntimeException: Could not launch intent Intent { act=android.intent.action.MAIN flg=0x14000000 cmp=com.xx.android/com.yy.core.android.map.MapActivity } within 45 seconds. Perhaps the main thread has not gone idle within a reasonable amount of time? There could be an animation or something constantly repainting the screen. Or the activity is doing network calls on creation? See the threaddump logs. For your reference the last time the event queue was idle before your activity launch request was 1390913271702 and and now the last time the queue went idle was: 1390913271767. If these numbers are the same your activity might be hogging the event queue.
        at com.google.android.apps.common.testing.testrunner.GoogleInstrumentation.startActivitySync(GoogleInstrumentation.java:277)
        at android.test.InstrumentationTestCase.launchActivityWithIntent(InstrumentationTestCase.java:119)
        at android.test.InstrumentationTestCase.launchActivity(InstrumentationTestCase.java:97)
        at android.test.ActivityInstrumentationTestCase2.getActivity(ActivityInstrumentationTestCase2.java:104)
        at com.gulesider.android.test.UItest.setUp(UItest.java:25)
        at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:190)
        at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:175)
        at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555)
        at com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner.onStart(GoogleInstrumentationTestRunner.java:167)
        at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1799)
Run Code Online (Sandbox Code Playgroud)
  1. 我有一个名为"Core"的库项目 - 它不会生成任何.apk
  2. 我还有一个名为"AA"的Android项目,它将访问"Core". - 这是AA.apk
  3. 现在我创建了一个名为"UItest"的测试项目

表现:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.AA.android.test"
        android:versionCode="1"
        android:versionName="1.0" >
    <uses-sdk android:minSdkVersion="8" 
            android:targetSdkVersion="18" />
    <instrumentation
      android:name="com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
      android:targetPackage="com.AA.android"/>
    <application
            android:allowBackup="true"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name" >
    <activity
                android:name="com.core.android.map.MapActivity"
                android:label="@string/app_name" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
            <uses-library android:name="android.test.runner" />
        </application>
    </manifest>
Run Code Online (Sandbox Code Playgroud)

我的测试:

    public class UItest extends ActivityInstrumentationTestCase2<MapActivity> {
        public UItest() {
            super(MapActivity.class);
        }

        @Override
        public void setUp() throws Exception {
            super.setUp();

            getActivity();

        }

        public void testSearchBox() {

            Espresso.onView(ViewMatchers.withId(R.id.menu_button_logo)).perform(ViewActions.click());

        }

    }
Run Code Online (Sandbox Code Playgroud)

tes*_*ngh 10

对于Espresso测试,强烈建议您关闭用于测试的虚拟或物理设备上的系统动画.因此,您可以按照以下步骤手动关闭动画:

在:设置 - >
开发人员选项 - >绘图

  1. 窗口动画缩放为OFF
  2. 将动画比例转换为OFF
  3. 动画师持续时间缩放为OFF

  • 我正面临着同样的问题。开发人员选项中的动画已关闭。 (3认同)
  • 我想知道是否有关于为什么发生这种情况的描述以及如何解决这个没有动画的问题 (2认同)

Mur*_*rat 5

如果在创建活动时运行了进度条,则会出现这样的错误.您应该停止进度条以继续运行测试.


aji*_*rma 0

在第一页,您将调用太多请求,这将花费超过 15 秒的时间,第一页应该非常轻量级。只需尝试创建一个新的欢迎页面,然后调用您原来的欢迎页面。希望这对你有用。