dimanche 30 avril 2017

Clicking button results in displaying Activity- Test fails

I'm new writting test code and I'm trying to create a test case that when i click a button verify is an Activity is displayed but it fails.

Here is my code:

@Test
public void mainActivityTest() {
    ViewInteraction floatingActionButton = onView(
            allOf(withId(R.id.fab), isDisplayed()));
    floatingActionButton.perform(click());

    intended(hasComponent(SecondActivity.class.getName()));
}

The Exception i'm getting is the follow:

java.lang.RuntimeException: Could not launch intent Intent { 
act=android.intent.action.MAIN flg=0x10000000 
cmp=com.google.developer.bugmaster/.MainActivity } 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 1493545934967 and now the last time the queue 
went idle was: 1493545937373. If these numbers are the same your activity 
might be hogging the event queue.atandroid.support.test.runner.MonitoringInstrumentation.startActivitySync(MonitoringInstrumentation.java:360)
at android.support.test.rule.ActivityTestRule.launchActivity(ActivityTestRule.java:

Aucun commentaire:

Enregistrer un commentaire