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.