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
318
votes
5 answers

Kotlin and new ActivityTestRule : The @Rule must be public

I'm trying to make UI test for my android app in Kotlin. Since the new system using ActivityTestRule, I can't make it work: it compiles correctly, and at runtime, I get: java.lang.Exception: The @Rule 'mActivityRule' must be public. at…
Geob-o-matic
  • 5,940
  • 4
  • 35
  • 41
128
votes
9 answers

Using Espresso to click view inside RecyclerView item

How can I use Espresso to click a specific view inside a RecyclerView item? I know I can click the item at position 0 using: onView(withId(R.id.recyclerView)) .perform(RecyclerViewActions.actionOnItemAtPosition(0, click())); But I need to click on a…
Filipe Ramos
  • 1,755
  • 2
  • 18
  • 24
128
votes
14 answers

Thread.sleep( ) with Espresso

Espresso claims that there is no need for Thread.sleep() but my code doesn't work unless I include it. I am connecting to an IP and, while connecting, a progress dialog is shown. I need a Thread.sleep() call to wait for the dialog to dismiss. This…
Chad Bingham
  • 32,650
  • 19
  • 86
  • 115
119
votes
9 answers

Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (23.1.0) and test app (23.0.1) differ

When building I get the following error: Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (23.1.0) and test app (23.0.1) differ. These are my gradle dependencies dependencies { compile…
barq
  • 3,681
  • 4
  • 26
  • 39
118
votes
2 answers

Google Espresso or Robotium

I have to use Automated UI test tool and I am confused between using Robotium vs Google Espresso. What are the major differences between the two? Are there features that exist in one but not the other?
Androidme
  • 3,145
  • 3
  • 24
  • 27
109
votes
3 answers

What is the purpose of @SmallTest, @MediumTest, and @LargeTest annotations in Android?

I'm new to Android and I've seen example code using these annotations. For example: @SmallTest public void testStuff() { TouchUtils.tapView(this, anEditTextView); sendKeys("H E L P SPACE M E PERIOD"); assertEquals("help me.",…
Eric Palakovich Carr
  • 22,701
  • 8
  • 49
  • 54
103
votes
5 answers

matches(not(isDisplayed())) fails with NoMatchingViewException

I am trying to test the absence of the UI view. The view selector is as follows: public static ViewInteraction onMyTestUi() { return onView(withId(R.id.myTestId)); } The selector works fine to check if the view is displayed, but gives error on…
101
votes
7 answers

Check if a dialog is displayed with Espresso

I'm trying to write some tests with the new android-test-kit (Espresso). But I can't find any information on how to check if a dialog is displayed and perform some actions on it (like clicking the positive and negative buttons, e.t.c.). Note that a…
Serj Lotutovici
  • 4,370
  • 5
  • 32
  • 41
89
votes
14 answers

Checking toast message in android espresso

Would anyone know how to test for the appearance of a Toast message in android espresso? In robotium its easy & I used but started working in espresso but dont getting the exact command.
Humayun Rana
  • 937
  • 1
  • 7
  • 14
87
votes
14 answers

AndroidX : No instrumentation registered! Must run under a registering instrumentation

I'm trying to run a local unit test that depends on the context, and was following this guide: https://developer.android.com/training/testing/unit-testing/local-unit-tests#kotlin and I set up my project like this (following this link :…
87
votes
10 answers

Why can't I import AndroidJUnit4 and ActivityTestRule into my unit test class?

I'm having trouble importing some of the Android UI testing framework classes - I just can't figure out what is going wrong! This is my class: @RunWith(AndroidJUnit4.class) @LargeTest public class ExampleUnitTest { @Rule public…
Hallupa
  • 1,155
  • 1
  • 9
  • 14
84
votes
13 answers

PerformException: Error performing 'single click'

I got a error when i run android espresso test: com.google.android.apps.common.testing.ui.espresso.PerformException: Error performing 'single click' on view 'with id: is <2131034173>'. My code is…
Winton Hou
  • 861
  • 1
  • 6
  • 4
82
votes
15 answers

How to assert inside a RecyclerView in Espresso?

I am using espresso-contrib to perform actions on a RecyclerView, and it works as it should, ex: //click on first item onView(withId(R.id.recycler_view)) .perform(RecyclerViewActions.actionOnItemAtPosition(0, click())); and I need to perform…
juhlila
  • 1,114
  • 1
  • 10
  • 16
81
votes
7 answers

Android Testing: UIAutomator vs Espresso

I was seeking for test frameworks for Android UI automation and I stumbled upon UI Automator and Espresso and this is the part I am confused about - Both are maintained by Google Both are used for functional UI testing Both are Android only…
Shikhar
  • 1,411
  • 1
  • 11
  • 17
77
votes
3 answers

Espresso - TextView contains String

Quite simply, how do I say if a given TextView contains a specific string in Espresso. The equivalent of: myStrings.contains("Subby");
Subby
  • 5,370
  • 15
  • 70
  • 125
1
2 3
99 100