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
20
votes
3 answers

Reset app state between InstrumentationTestCase runs

One of my QA engineers is supporting an app with a fairly large codebase and a lot of different SharedPreferences files. He came to me the other day asking how to reset the application state between test runs, as if it had been…
Turnsole
  • 3,422
  • 5
  • 30
  • 52
20
votes
2 answers

Android - How to click on an item on a navigation drawer using Espresso?

I am new to Android development. I want to use Espresso to test that my drawer opens, then click on an item and check that it opens a new activity. I've been searching for examples about this but haven't had any luck.
josmenag
  • 253
  • 1
  • 3
  • 6
20
votes
4 answers

Testing progress bar on Android with Espresso

The workflow should be the following: Activity starts Progress bar is visible Network request fires (idling resource is already registered so espresso knows how to wait for it). Progress bar is hidden Text from network is shown. Up to this point,…
Christopher Francisco
  • 15,672
  • 28
  • 94
  • 206
20
votes
1 answer

Android Espresso not working with Multidex gives "No tests found"

My Espresso tests were running until I had to support multidex. My build.gradle, I have minSdkVersion 14 targetSdkVersion 23 multiDexEnabled = true testInstrumentationRunner "com.android.test.runner.MultiDexTestRunner" androidTestCompile…
Sayooj Valsan
  • 536
  • 5
  • 16
20
votes
1 answer

Test Android Activity with different Application class

I´m looking for a way to test an Activity with JUnit4 and the ActivityTestRule, but with a different application class (e.g. mocked or inherited). I was able to get this for library projects using the manifest merge and tools:replace="android:name"…
Fabian
  • 541
  • 1
  • 6
  • 15
20
votes
4 answers

How to use Espresso Idling Resource for network calls

Im trying to use Espresso to test my UI. When i login into my application, i do a call to Parse API (network call) to verify the username and password. If all is well the user gets directed to a new activity. I want to test this, but i cant seems to…
Dennis Anderson
  • 1,348
  • 2
  • 14
  • 33
20
votes
7 answers

Android tests build error: Multiple dex files define Landroid/support/test/BuildConfig

I'm trying to add Espresso 2 to my project (which also has lots of other dependencies), but I'm hitting this error when trying to run tests: UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define…
Dan J
  • 25,433
  • 17
  • 100
  • 173
19
votes
5 answers

How to correctly mock ViewModel on androidTest

I'm currently writing some UI unit tests for a fragment, and one of these @Test is to see if a list of objects is correctly displayed, this is not an integration test, therefore I wish to mock the ViewModel. The fragment's vars: class…
19
votes
2 answers

How do I make Espresso wait until Data Binding has updated the View with the data-model?

I am running Espresso tests on my Android application. The test is flaky. It can reliable assert that the data-model is updated. My problem is that the ViewMatchers can't match the same value in the View because the ViewDataBinding has not yet…
Rene
  • 4,033
  • 2
  • 24
  • 29
19
votes
5 answers

How to check Toolbar title in android instrumental test?

I found great instrumental test tutorial on YT Advanced Android Espresso. I took code from there with small adjustment to my needs. import static android.support.test.InstrumentationRegistry.getInstrumentation; import static…
19
votes
4 answers

Appium vs Espresso for automated testing framework

For last few weeks, I was using Appium(python) for android testing but yesterday we have decided to shift to Expresso(Java) for automated testing. There are couple of reasons why we are making this shift: We want to scale out our automated testing,…
python
  • 4,403
  • 13
  • 56
  • 103
19
votes
1 answer

Android: checking a button is enabled

I am having problems testing my app. I created an espresso test which is supposed to fail, since whenever I launch my app in the emulator, I get the expected behavior. There is my test: onView(withText("wrong answer")).perform(click()); …
Loïs Talagrand
  • 810
  • 2
  • 13
  • 32
19
votes
8 answers

Android Espresso Issue - Dependency conflict

I'm trying to integrate espresso into my application for ui testing. Here are my dependencies in Gradle dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:22.2.0' compile…
DJ-DOO
  • 4,545
  • 15
  • 58
  • 98
19
votes
2 answers

Espresso AmbiguousViewMatcherException when trying to click a navigation button

Test I'm attempting to do: make a purchase, note the title, then return to the home activity, and press "home_image" which is an image button. My issue is I can't navigate home_image. I press it and I get a bogus duplicate ID. I believe the…
StarWind0
  • 1,554
  • 2
  • 17
  • 46
19
votes
6 answers

Espresso: How to do custom swipe e.g. swipeTop or swipeBottom

So far we can do: swipeLeft swipeRight swipeUp swipeDown How can we swipeTop(all the way to the Top) or swipeBottom(all the way to the bottom) is expresso. Please give me an example if these methods already exists.
Testing Singh
  • 1,347
  • 1
  • 15
  • 26