Questions tagged [android-espresso]

Espresso is a library which is used to write Android UI tests. It is also known as Google's Testing Tools For Android

Also called android-test-kit, Espresso helps to create faster UI tests for Android.

The core API is small, predictable, and easy to learn and yet remains open for customization. Espresso tests state expectations, interactions, and assertions clearly without the distraction of boilerplate content, custom infrastructure, or messy implementation details getting in the way.

Espresso tests run optimally fast! Leave your waits, syncs, sleeps, and polls behind and let Espresso gracefully manipulate and assert on the application UI when it is at rest. Enjoy writing and executing your tests today - try a shot of Espresso!

Useful links

3335 questions
22
votes
2 answers

Unable to run parameterized tests with Android Test Orchestrator

I'm trying to run parameterized tests using Android Test Orchestrator. But for some reason parameterized tests won't start. I can run all tests properly without Orchestrator but I need it to clear some data between tests. This is output from Gradle.…
Aleksander Mielczarek
  • 2,787
  • 1
  • 24
  • 43
22
votes
6 answers

How to take screenshot at the point where test fail in Espresso?

I am looking for a way to take a screenshot of device after test failed and before get closed.
think_better
  • 343
  • 1
  • 2
  • 11
22
votes
4 answers

How to enable Espresso Test Recording

As of yesterday's Google IO Keynote, there seems to be a major update in the way we do UI testing in our projects. Automated testing is about to see a huge step forward thanks to a new test recorder feature. Developers will be able to start a…
22
votes
4 answers

Android - Independent Fragment UI testing tool

I've been looking for a way to test the UI of my Fragments separately (ie, independently from other fragments and activities) but I can't find a way to do it. In particular, let's say I have Fragment A, Fragment B and Fragment C. The only way…
22
votes
1 answer

Espresso: How to test SwipeRefreshLayout?

My app reloads data when a down-swipe is done on a SwipeRefreshLayout. Now I try to test this with Android Test Kit / Espresso like this: onView(withId(R.id.my_refresh_layout)).perform(swipeDown()); Unfortunately this fails…
Thomas Keller
  • 5,933
  • 6
  • 48
  • 80
22
votes
1 answer

Espresso test fails after successful click and blocking for 60 seconds

I have tried using Espresso testing framework and wrote a simple test. Nothing fancy there, just this code: onView(withId(R.id.login_button_stub)).perform(click()); Test runs fine on a Nexus 5 device and Genymotion with Android 5.0, but fails on…
MaciejGórski
  • 22,187
  • 7
  • 70
  • 94
21
votes
5 answers

java.lang.Exception: Custom runner class AndroidJUnit4 should have a public constructor with signature AndroidJUnit4(Class testClass)

gradle looks like: apply plugin: 'com.android.application' android { compileSdkVersion 25 buildToolsVersion "25.0.2" defaultConfig { applicationId "com.google.developer.taskmaker" minSdkVersion 19 …
Aman Srivastava
  • 1,007
  • 1
  • 13
  • 25
21
votes
3 answers

Espresso Recyclerview scroll to end

I have an Android application which has a RecyclerView with N elements, and when this RecyclerView reaches to end when scrolling, then more elements are added (so, it's an infinite list which loads data when scroll reached the bottom). I would like…
LordWater
  • 345
  • 1
  • 2
  • 6
21
votes
2 answers

How to debug instrumentation tests in Android Studio?

In Android Studio when I debug instrumentation test, the test won't stop on any breakpoint. Debugging unit tests works. I have a simple instrumented test that only checks if username edittext is displayed: @RunWith(AndroidJUnit4.class) public class…
Tomask
  • 2,344
  • 3
  • 27
  • 37
21
votes
5 answers

How do I test a Fragment in isolation using Espresso?

I have a Fragment that I want to test. I created a test Activity to which I add this Fragment and run some Espresso tests. However, Espresso does not find any of the views inside the Fragment. It dumps the view hierarchy and it is all empty. I do…
greenrobo
  • 781
  • 1
  • 6
  • 9
21
votes
6 answers

Test if soft keyboard is visible using espresso

I want to test keyboard visibility when an activity calls onCreate() and onResume(). How can i test whether or not the keyboard is shown using espresso?
Vinay Nagaraj
  • 1,162
  • 14
  • 26
21
votes
3 answers

openDrawer from espresso contrib is deprecated

Espresso contrib (com.android.support.test.espresso:espresso-contrib:2.2.1) openDrawer method is deprecated then how should I open a drawer?
20
votes
3 answers

Android Test Orchestrator not working with Android X

I have recently migrated my project to use AndroidX, and have configured test orchestrator for my espresso tests on gradle using the following docs: https://developer.android.com/training/testing/junit-runner#using-android-test-orchestrator I have…
20
votes
3 answers

Android espresso test pass locally but fails on Firebase Test Lab

I have issue with android espresso test. Test pass locally but fail on FTL. It's simple test onView(allOf(withId(R.id.text_supercategory_name), withText("Air conditioners"))). check(matches(withText("Air conditioners"))); this test pass locally. On…
20
votes
2 answers

Espresso test passes individually, fails when run in the suite

I have the following Espresso test. It always passes if I run it by itself, but always fails when I run all the tests in the class together. What's also a bit strange is that it used to work even as part of the suite. I'm not sure why now it stopped…
Michael Vescovo
  • 3,741
  • 4
  • 32
  • 45