mercredi 21 mars 2018

Start espresso from a different activity

I have an app that launches splash activity screen when recording a test for espresso. However, I only want to start the espresso from another activity that starts after signing in and everything (NavDrawerActivity). Basically I want to skip signing in and all that. Here is the beginning of my code. Does anyone know how to start the testing from NavDrawerActivity?

@Rule
public ActivityTestRule<SplashScreenActivity> mActivityTestRule =
        new ActivityTestRule<>(SplashScreenActivity.class);

@Test
public void avatarActivityEspressoTest() {
    try {
        Thread.sleep(3000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }

    ViewInteraction appCompatButton = onView(
            allOf(withId(R.id.btn_skip), withText("SKIP"),
                    childAtPosition(
                            childAtPosition(
                                    withId(android.R.id.content),
                                    0),
                            4),
                    isDisplayed()));
    appCompatButton.perform(click());

    try {
        Thread.sleep(3000);
    } catch (InterruptedException e) {
        e.printStackTrace();
..
..

Aucun commentaire:

Enregistrer un commentaire