[cucumber-jvm][Android][Gradle] Tests fail because startActivitySync() blocks

122 views
Skip to first unread message

tim.ha...@grandcentrix.net

unread,
Jun 28, 2015, 7:06:09 PM6/28/15
to cu...@googlegroups.com
Hallo,

I'm trying to get cucumber-jvm running on Android. The Android gradle example is running fine, but I've some problems with tests in my own project.
I have implemented multiple test scenarios without cucumber-jvm first. Those tests run fine. Now I'm converting them to cucumber-jvm.

The first scenario runs fine, all following scenarios are started and then they block in startActivtySync() until they are aborted:

        java.lang.RuntimeException: Could not launch intent Intent { flg=0x14000000 cmp=xx.xxxxx.app/.misc.MasterActivity } within 45 seconds. Perhaps the main thread has not gone idle within a reasonable amount of time? There could be an animation or something constantly repainting the screen. Or the activity is doing network calls on creation? See the threaddump logs. For your reference the last time the event queue was idle before your activity launch request was 1435366760013 and now the last time the queue went idle was: 1435366767441. If these numbers are the same your activity might be hogging the event queue.
        at android.support.test.runner.MonitoringInstrumentation.startActivitySync(MonitoringInstrumentation.java:274)
        at android.test.InstrumentationTestCase.launchActivityWithIntent(InstrumentationTestCase.java:119)
        at android.test.ActivityInstrumentationTestCase2.getActivity(ActivityInstrumentationTestCase2.java:106)
        at xx.xxxxx.app.cucumber.ProductListFeatureSteps.der_Nutzer_befindet_sich_auf_dem_Home_Bildschirm(ProductListFeatureSteps.java:39)
        at xx.xxxxx.app.cucumber.ProductListFeatureSteps.der_Nutzer_befindet_sich_auf_den_Home_Bildschirm(ProductListFeatureSteps.java:46)
        at ✽.Angenommen der Nutzer befindet sich auf den Home-Bildschirm(features/home/anzeige_von_produktlisten.feature:14)


If I add a @After method and finish the current Activity all scenarios are started and there is no blocking any more. But tests with multiple Activities still do not run successfully because not all Activities are stopped.

    @cucumber.api.java.After
    public void after() {
        getActivity().finish();
    }

It seems odd to me that I have to finish the Activies myself. Why is startActivitySync() blocking in my tests?

/Tim



grandcentrix GmbH
Schanzenstrasse 6-20
51063 Köln, Deutschland

phone: +49 221 677 860 0

Amtsgericht Köln | HRB  70119 | Geschäftsführer: R. Rottmann, M. Willnow | USt.-IdNr.: DE266333969
Reply all
Reply to author
Forward
0 new messages