vendredi 20 octobre 2017

Espresso - How to handle IdlingResources with multiple activities?

I have a flow made out of 3 Activities. All of them set an idle state to 'false' until a specific element is loaded. How to register more than one IdlingResource in one Test Class?

@Rule
public ActivityTestRule<Activity1> mActivityRule = new ActivityTestRule<>(Activity1.class, false, false);

private IdlingResource mIdlingResource1;
private IdlingResource mIdlingResource2;
private IdlingResource mIdlingResource3;

@Test
public void welcomeFlow() {
    mActivityRule.launchActivity(null);

    mIdlingResource = mActivityRule.getActivity().getIdlingResource();
    IdlingRegistry.getInstance().register(mIdlingResource);

    click(R.id.continueButton);

    // In here i have to register another idlingResource from Activity2
    click(R.id.continueButton);

    // In here i have to register another idlingResource from Activity3
    click(R.id.continueButton);
}

Aucun commentaire:

Enregistrer un commentaire