简体   繁体   中英

Using InstrumentTest for an Activity which calls an Intent automatically

I am developing an Android app which uses Skobbler SDK(AKA skmaps). I am using InstrumentationTestRunner in order to tess my Activities. I have got two test classes extending ActivityInstrumentationTestCase2<MyActivity> . But my first tested activity(MainActivity) already calls an Intent in order to start a second activity(MapActivity). So it's a kind of SplashActivity. The test of MainActivity runs into an endless loop after testPreconditions() . If I remove the Intent from the MainActivity, then the test keeps on running. So how can I test an Activity with it's lifecycles if it calls an Intent without running into the endless loop?

Regards unlimited101

The problem was that InstrumentationTestRunner execute the activity tests in a non-deterministic order. So sometimes the second activity was tested before the first activity. And due to loops which wait for results of the first activity, the second one was fallen into an endless loop. Building test suites solves this problem. Because there you can specify the order in which the activities are tested.

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