I'm writing a UI integration test that clicks a context menu item and
checks the appropriate activity was launched - reminiscent of selenium
testing.

I can't get my test to work.  It hangs after executing
testContextMenuOption() - apparently completing execution of "tearDown
()" - and hanging before calling setup() for the next test case (I
forget...somewhere in InstrumentationTestRunner or
AndroidTestRunner).  The emulator shows the context menu being clicked
and a new activity being launched.  Then the test output just sits
there.

What am I doing wrong trying to get this kind of test written?

I have code like this in my "InstrumentationTestCase" subclass:
...
    /**
     * @inheritDoc
     */
    @Override
    protected void setUp() throws Exception {
        super.setUp();
        activityInstance = new MyActivity();
        this.launchActivity(getInstrumentation().getTargetContext
().getPackageName(), MyActivity.class, new Bundle());
        this.getInstrumentation().waitForIdleSync();
    }

    /**
     * @inheritDoc
     */
    @Override
    protected void tearDown() throws Exception {
        Log.d(LOG_TAG, "test finished");
        getInstrumentation().waitForIdleSync();
        activityInstance = null;
        super.tearDown();
    }

    public void testContextMenuOption()  {
        Log.d(LOG_TAG, "testContextMenu started");
        sendKeys(KeyEvent.KEYCODE_MENU);
        sendKeys(KeyEvent.KEYCODE_DPAD_LEFT);
        sendKeys(KeyEvent.KEYCODE_DPAD_CENTER);
        getInstrumentation().waitForIdleSync();
        sendKeys(KeyEvent.KEYCODE_BACK);
    }

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to