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

Android Espresso test error: No static method loadSingleServiceOrNull()

When I ran my tests 1 week ago every was fine, but now I get this error: java.lang.NoSuchMethodError: No static method loadSingleServiceOrNull(Ljava/lang/Class;)Ljava/lang/Object; in class Landroidx/test/internal/platform/ServiceLoaderWrapper; or…
Captain Jacky
  • 888
  • 1
  • 12
  • 26
18
votes
3 answers

How to enter text in Jetpack compose TextField through UI tests?

In Jetpack compose I have a TextField and I'm trying to write Espresso UI tests. I didn't find how I can enter text in the TextField, any ideas, please? TextField( value = textState.value, modifier = Modifier.fillMaxWidth(), …
18
votes
5 answers

Android studio - androidTest folder is missing

I'm working on automation test using Espresso. The folder in which Instrumentation test classes can be written is missing Screenshot of the project I tried by adding android{ sourceSets{ main { java.srcDirs = ['src/main/java'] } …
Suhas
  • 231
  • 1
  • 3
  • 10
18
votes
1 answer

Espresso --> Java.lang.SecurityException: test fails due to Package does not belong to

I have an Android Espresso code that attempts to click a button and it fails with a security error. This is the Espresso command: Espresso.onData(Matchers.allOf(Matchers.is(Matchers.instanceOf(Preference.class)),…
Pavel Zagalsky
  • 1,620
  • 7
  • 22
  • 52
18
votes
2 answers

Global code coverage in multi-module Android project: merge code coverage reports (Unit & UI tests)

I have an Android app which is made up of 2 modules: App - UI Submodule - has most of the business logic For each of them I have a gradle task to validate code coverage: App: UI Code coverage (Espresso) Submodule: Unit tests code coverage As a…
Renato Almeida
  • 369
  • 4
  • 14
18
votes
2 answers

Why is Espresso's registerIdlingResources deprecated, and what replaces it?

I'm working on UI tests with Espresso for Android, and following the Google's code sample it is used, even though it's deprecated. So my questions are: why is it deprecated? what replaces it?
Marvin Effing
  • 2,693
  • 3
  • 20
  • 35
18
votes
2 answers

What does the testOptions.animationsDisabled property in Android Gradle plugin do?

I recently discovered the property testOptions.animationsDisabled in the Android Gradle plugin. I was hoping it would be helpful to disable the animations on my devices when executing UI tests with Espresso, but it's not, i.e. I still have to…
18
votes
7 answers

Android revoke permission at start of each test

I'm using Espresso and UIAutomator to write my test cases. I'm testing external storage permissions when it's denied and when it's allowed. I have different test cases which all require the permission to be revoked at the start of the test…
18
votes
4 answers

Espresso testing NestedScrollView - "Error performing 'scroll to' on view 'with id:"

I need to scroll down through my NestedScrollView in order to test my xml file with Espresso, but I get the error message: "Error performing 'scroll to' on view 'with id:" Several other posts that seem to have a similar problem. I have followed…
Silas
  • 181
  • 1
  • 1
  • 5
18
votes
6 answers

Espresso AutoCompleteTextView click

So I recently started messing around with Espresso in one of my existing Android projects. Everything went pretty decently, until I came to find AutoCompleteTextView in my program. I don't seem to understand how to properly click the first thing in…
18
votes
1 answer

Android UI test Fingerprint with Espresso

I have an Android fingerprint implementation working and I was looking to add UI tests with Espresso. One problem I can't find a solution to is how to emulate the scanning of a finger. There is an adb command adb -e emu finger touch which should…
QuirijnGB
  • 811
  • 1
  • 9
  • 18
18
votes
1 answer

ActivityTestRule - how to call code before Application's onCreate

I am using Espresso 2.1 with ActivityTestRule, and I am looking for a way to set some static flags before onCreate() in my application will be called. I have some init code that I don't want called during instrumentation tests.
18
votes
8 answers

Testing background color espresso Android

Is it possible to check if the background color matches a given color with espresso? Update: I made a custom matcher, similar to what @Irfan suggested, thanks! public static Matcher backgroundShouldHaveColor(int expectedColor) { return…
HowieH
  • 2,612
  • 2
  • 23
  • 26
18
votes
2 answers

Android Espresso Tests for phone and tablet

My setup: - Android App with Phone and Tablet Version - I am using Android Espresso for UI-Tests (now only for phone version, with phone at buildagent) What I want to do: - Now I want Espresso to distinguish between tests for phone and tablet - So…
true-mt
  • 347
  • 3
  • 12
18
votes
5 answers

Espresso - Set SeekBar

does anybody know, how to set a seekBar to a specific value or just a click on that view on Espresso UI Testing ? I just get an exception: Error performing 'single click' on view with id... onView(withId(R.id.FilterPriceMax)).perform(click());
Luser_k
  • 514
  • 1
  • 4
  • 18