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

Attempted to use AndroidJUnit4 with standard JUnit runner and delegate runner 'org.robolectric.RobolectricTestRunner'could not be loaded

I am using espresso to run some tests but I don't know why roboelectric is included in this error since the tests are for espresso only, below is the error : java.lang.Exception: Attempted to use AndroidJUnit4 with standard JUnit runner and delegate…
Idris Stack
  • 546
  • 1
  • 14
  • 36
14
votes
3 answers

AndroidX.Test ActivityScenario: java.lang.AssertionError: Activity never becomes requested state "[RESUMED]" (last lifecycle transition = "STOPPED")

ActivityScenario is a replacement of ActivityController in Robolectric and ActivityTestRule in ATSL. When refactoring from ATSL to AndroidX Test, I am using this code to start my IndexActivity before each espresso test. @Before public void…
Mark Han
  • 2,785
  • 2
  • 16
  • 31
14
votes
1 answer

Espresso Tests cannot access class file

I get the following errors where i try to run a ui test. /Users/etiennelawlor/workspace/MovieHub/app/src/androidTest/java/com/etiennelawlor/moviehub/MoviesFragmentTest.java Error:(34, 28) error: cannot access AppCompatActivity class file for…
Etienne Lawlor
  • 6,817
  • 18
  • 77
  • 89
14
votes
4 answers

Espresso, Dagger2 set ViemodelProvider.Factory on BaseActivity

I have an abstract AccountRequiredActivity that looks like this (and works fine): public abstract class AccountRequiredActivity extends LifecycleActivity { @Inject ViewModelProvider.Factory viewModelFactory; private AccountViewModel…
html_programmer
  • 18,126
  • 18
  • 85
  • 158
14
votes
0 answers

connectedAndroidtest mergeAndroidReports not working

I'm trying to run two different sets of instrumentation tests in two different modules. It's my understanding that if I add the mergeAndroidReports command to each of these test tasks that in the root project in the build folder I should see a test…
14
votes
2 answers

What id name convention is good for Kotlin android extensions

Using Kotin android extensions I can avoid using findViewById, but Im not sure how to name the ids to use it propertly. I found two options are: Use simple names for ids but then I can get in trouble with espresso if I use it with…
Daniel Gomez Rico
  • 15,026
  • 20
  • 92
  • 162
14
votes
1 answer

Flaky Android Espresso Test - Snackbar

1) All devices/emulators being tested have animations disabled. 2) I have an @BeforeClass which builds my Credentials object. 3) I have an IntenServiceIdlingResource and an EventBusIdlingResource, registered in @Before. 4) When the sign in button is…
14
votes
2 answers

Activity in androidTest not getting launched by ActivityTestRule

I want to test a fragment in test activity. I added TestTragmentActivity to androidTest along with AndroidManifest.xml file. But when I try to use this activity via an ActivityTestRule it gives following error: java.lang.RuntimeException: Could not…
14
votes
3 answers

How can I check the expected intent sent without actually launching activity in Espresso?

I have a UI test which clicks a button, and then launch a new Activity in its onClickListener. The test checks whether expected intent is sent or not. My problem is, I want to test whether expected intent is sent without actually launching the…
14
votes
2 answers

Espresso Tests in Library Module 'com.android.library'

I have a library module that is used by two android applications and I want to add espresso tests to the Library module so that both apps can run common set of tests. Is there an example available where espresso tests are added in library module?
WorkingSmile
  • 191
  • 4
14
votes
4 answers

No ID for my Android UI Testing

I would like to write some UI Test on my Android application in order to take automated screenshots. My application is written with React-Native. In order to write my tests in need to know the resource-id of my component but as you can see in this…
G.Sabathier
  • 377
  • 1
  • 4
  • 13
14
votes
2 answers

Espresso-web import causes duplicateFileException

I am using Android Espresso. I needed espresso-web to work with webviews. I set my espresso according to google website. https://google.github.io/android-testing-support-library/downloads/index.html My dependencies looks like that: dependencies { …
F1sher
  • 7,140
  • 11
  • 48
  • 85
14
votes
3 answers

Correct way to use IdlingResource in Espresso Android

I'm writing UI tests with Espresso. App cooperates tightly with server, so in many cases, I need to wait for either value to be calculated, or data is got and displayed, etc. Espresso suggests using IdlingResource for this. My IdlingResource…
Lanitka
  • 922
  • 1
  • 10
  • 20
14
votes
2 answers

Dagger code giving NoClassDefFoundError when Espresso Tests are run, normal run works fine

Started exploring Espresso 2.0, but seem to have run into a hiccup. I cannot get the tests to successfully run against any project which includes Dagger. When I run the tests I get the following Exception (entire stacktrace at the…
pturner
  • 686
  • 5
  • 14
14
votes
1 answer

Android Espresso: Wait for Activity to finish/start

Is there a canonical solution using Espresso to wait for a specific Activity to finish or start? I have a SplashActivity that appears for a few seconds, then a MainActivity. I want Espresso to interact with the MainActivity, not the SplashActivity,…
SuperDeclarative
  • 1,609
  • 4
  • 18
  • 32