androidtestingandroid-espressobarista

pressBack() is ignored in a Espresso Test


The Espresso's method pressBack() is totally ignored. I'm running the test on the emulator.

What I'm testing? Just calling an Activity, launching a second one, performing two backs, and checking that I'm out of the app.


Solution

  • Use

    import static android.support.test.espresso.Espresso.pressBack;

    or

    import static androidx.test.espresso.Espresso.pressBack;

    instead of

    import static android.support.test.espresso.action.ViewActions.pressBack;