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
27
votes
4 answers

How to scroll down the screen in the android espresso test? I need to validate the text present on the screen

I am performing the below test to validate the text on screen , The text is present on the view but need to page scroll to see the text manually. onView(withText("Launch")).check(ViewAssertions.matches(isDisplayed())); onView(withText("January…
Bhupendra Singh Rautela
  • 3,406
  • 6
  • 21
  • 25
27
votes
4 answers

Android Espresso - How to check EditText hint?

I'm starting to play with Espresso, got my basic tests running. Now trying to figure out how to check that my edit text has a specific hint text? Thanks. onView(withId(R.id.locationInput)).check(matches...?)
Eduard
  • 3,482
  • 2
  • 27
  • 45
26
votes
3 answers

What is Android Test Orchestrator?

Google released Android Testing Support Library 1.0 recently. After reading the overview, I'm a little confused with Android Test Orchestrator. It said Typically, AndroidJUnitRunner runs all tests in the same instrumentation process, which can…
cmoaciopm
  • 2,076
  • 2
  • 22
  • 30
26
votes
1 answer

Android Espresso : How to match grand parent? without giving exact hierarchy

onView(allOf( withText(activityUnderTest), withParent(withId(R.id.llh_root_record_activity_3_item)))) .check(matches(anything())) ; In above code snippet withParent matcher is failing because view id given is not immediate…
user7154703
26
votes
2 answers

Create DummyActivity inside androidTest folder for testing

I have created a dummy activity inside androidTest folder and declared that activity in AndroidManifest file in androidTest folder. My basic intention is to test a reusable fragment by putting it into a dummy activity with a framelayout…
26
votes
4 answers

How to get a view from within Espresso to pass into an IdlingResource?

I essentially have a custom IdlingResource that takes a View a constructor argument. I can't find anywhere that really talks about how to implement it. I'm trying to use this answer: https://stackoverflow.com/a/32763454/1193321 As you can see, it…
EGHDK
  • 17,818
  • 45
  • 129
  • 204
25
votes
5 answers

Android Navigation Instrumentation test throws Method addObserver must be called on the main thread

I have two Fragments, one being a home fragment in my graph. The User will be navigated to the second fragment upon clicking a button. It works as expected by navigating the user to the second fragment and displaying the text. So the graph is…
The_Martian
  • 3,684
  • 5
  • 33
  • 61
25
votes
4 answers

Espresso test error: AppNotIdleException

I turned off all animations on developer options. But I still get this exception when trying to click on one of the buttons. My app is indeed active and not idle entirely, but I can't change it. android.support.test.espresso.AppNotIdleException:…
user5174803
  • 261
  • 1
  • 3
  • 5
25
votes
2 answers

connectedAndroidTest how to run specific tests

I am a QA with a start up company. My Developer setup Instrumentation tests in the Android Project. He also setup the Jenkins Jobs to run these tests in CI env. This is the command given in "Tasks" field in Jenkins job under Build --> Invoke Gradle…
jellyBeans
  • 293
  • 2
  • 4
  • 12
25
votes
2 answers

Android Espresso Intents test randomly fail with ``init() must be called prior to using this method``

I am working on pushing a project into espresso testing currently. I have read a bunch of documents and follow the given practises to get started. Everything works fine, However, when it comes to Intents related test, the result is strange. Most of…
longkai
  • 3,598
  • 3
  • 22
  • 24
25
votes
5 answers

ProgressBars and Espresso

When I have a ProgressBar in layouts that are displayed when running some espresso-tests - then I run into: Caused by: android.support.test.espresso.AppNotIdleException: Looped for 1670 iterations over 60 SECONDS. The following Idle Conditions…
ligi
  • 39,001
  • 44
  • 144
  • 244
25
votes
3 answers

Android IllegalStateException No instrumentation registered! Must run under a registering instrumentation

I am struggling to make this functional test with Espresso work on Android. My App is a Multdex app so I am following the instructions written at this link as follows : (https://developer.android.com/tools/building/multidex.html). I have already…
25
votes
2 answers

Espresso - withEffectiveVisibility vs isDisplayed

Whats´s the difference between isDisplayed and withEffectiveVisibility? onView(withText("Much Dagger")).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))); onView(withText("Much…
Daniel Gomez Rico
  • 15,026
  • 20
  • 92
  • 162
25
votes
3 answers

Why would adding espresso-contrib cause an InflateException?

In my build.gradle file I have the support library dependencies: compile "com.android.support:appcompat-v7:22.2.0" compile "com.android.support:recyclerview-v7:22.2.0" compile "com.android.support:design:22.2.0" I also have dependencies for…
rosegrink
  • 333
  • 4
  • 9
25
votes
7 answers

AndroidTest folder doesn't show on AndroidStudio

I'm setting up Android app structure with Gradle and Android Studio and Espresso UI testing for a project. No matter what I try, the androidTest folder never appears in AndroidStudio's project structure. Project (root) build.gradle: buildscript { …
RecuencoJones
  • 2,747
  • 3
  • 22
  • 21