简体   繁体   中英

Android Automation of Regression Testing using Robotium

I have generated a robotium test case and successfully tested the same on real device. Now, i like to know how can i run the same test case (Class that extends ActivityInstrumentationTestCase2) repeatedly.

Please let me know if any code sample for doing the same.

Thanks

I achieved this 2 ways ..

Method 1 - Same Test case can be called many times from a class that extends InstrumentationTestRunner.

import junit.framework.TestSuite;
import android.test.InstrumentationTestRunner;
import android.test.InstrumentationTestSuite;

public class MediaFrameworkTestRunner extends InstrumentationTestRunner {

    @Override
    public TestSuite getAllTests() {
        InstrumentationTestSuite suite = new InstrumentationTestSuite(this);

        suite.addTestSuite(MainActivityTest.class);
        suite.addTestSuite(MainActivityTest.class);
        return suite;
    }

    @Override
    public ClassLoader getLoader() {
        return MediaFrameworkTestRunner.class.getClassLoader();
    }
}

Method 2 - Add a loop statement inside the testRecorded() method

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM