Keep tool active after test

Suppose you create a test case for the Android platform using a class with a signature like:

public class AccountTest extends ActivityInstrumentationTestCase2<MainActivity> { ... }

Say we have a testing method similar to this using the Robotium framework:

public void testCreateAccount() {
    solo.clickOnButton("Add Account");
    solo.clickOnButton("Next");

    ...
}

When the test case is completed, the instrumental activity is quickly destroyed. Is there a way to save it after completion, at least in order to determine what you want to do next, and encode the next few lines?

+3
source share
3 answers

As it turned out, it's easy to accomplish what I want using the Nativedriver library:

http://code.google.com/p/nativedriver/

driver.quit() , .

+1

Android JUnit Test JUnit, , JUnit:

  • setUp()
  • tearDown() .

, .

ActivityInstrumentationTestCase2 :

@Override
protected void tearDown() throws Exception {
  // Finish the Activity off (unless was never launched anyway)
  Activity a = super.getActivity();
  if (a != null) {
    a.finish();
    setActivity(null);
  }

  // Scrub out members - protects against memory leaks in the case where someone 
  // creates a non-static inner class (thus referencing the test case) and gives it to
  // someone else to hold onto
  scrubClass(ActivityInstrumentationTestCase2.class);

  super.tearDown();
}

, , , , ?

:

  • teardown() AccountTest ( ActivityInstrumentationTestCase2), super.tearDown();
  • ActivityInstrumentationTestCase3 ( ActivityTestCase), teardown().

teardown(), .

, .

+2

I have the same problem. Finally i useSleep().

while(true)
{
   Thread.Sleep(1000);
   // do other things when the main thread wake
}

you can put the above code in an arbitrary testing method, then the tool Activitywill not be completed.

Hope this helps you.

0
source

All Articles