Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Testing - Issue with ActivityInstrumentationTestCase2?

I am running UIAutomation for android using Robotium and ActivityInstrumentationTestCase2. I have a test suite with 5 tests. Sometimes my test randomly crash because a test starts, once the previous test has not ended yet. Is there a way to avoid this? is it possible to manually add a 10 second delay before every test to get away from this horrible annoying bug?

EDIT:

public class MyTest<T extends RoboActivity> extends ActivityInstrumentationTestCase2<T>
{

    protected Solo solo;

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        solo = new Solo(getInstrumentation(), getActivity());
    }

    @Override
    protected void tearDown() throws Exception {
        solo.finishOpenedActivities();

        try {
            solo.finalize();
        }
        catch (Throwable e) {
            Assert.fail(e.getMessage()+ e.toString());
            e.printStackTrace();
        }

        super.tearDown();
    }
}
like image 772
aryaxt Avatar asked Nov 13 '22 13:11

aryaxt


1 Answers

Maybe this could work :

mSolo = new Solo(getInstrumentation(), getActivity());
mSolo.waitForActivity(AccountDetail.class);

Seems that waitFor* methods are managing that better than a "sleep" http://robotium.googlecode.com/svn/doc/com/robotium/solo/Solo.html#waitForActivity(java.lang.Class, int)

like image 171
ıɾuǝʞ Avatar answered Nov 16 '22 02:11

ıɾuǝʞ