Espresso testing disable animation

Make sure to keep your plugin updated: buildscript { repositories { google() gradlePluginPortal() } dependencies { classpath ‘com.android.tools.build:gradle:3.3.0’ } } Use the new flag in testOptions called animationsDisabled: android { … testOptions { animationsDisabled = true } } Source: https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.TestOptions.html#com.android.build.gradle.internal.dsl.TestOptions:animationsDisabled You can try turning off animations on your device/emulator manually: To avoid flakiness, we highly … Read more

Espresso – Click by text in List view

The problem is, that you try to match the list view itself with the instanceOf(ListView.class) as argument for onData(). onData() requires a data matcher that matches the adapted data of the ListView, not the ListView itself, and also not the View that Adapter.getView() returns, but the actual data. If you have something like this in … Read more

How to turn on console output in Android Unit tests?

android { … testOptions { unitTests.all { // All the usual Gradle options. testLogging { events “passed”, “skipped”, “failed”, “standardOut”, “standardError” outputs.upToDateWhen {false} showStandardStreams = true } } } } In my case, I followed this document and added the testLogging option as above. This should printout the log for the unit tests written under … Read more

How do I allow android app alpha/beta testers to download the app for free?

Here is my conclusion (in short, no solution): 1- (Edit: unfortunately this point is not correct, you wont get the updates unless you download directly from the store.) The only issue is delivering the first APK to the testers, as they wont be able to download the application from the Play Store, however, downloading updates … Read more

Unit testing a Kotlin coroutine with delay

If you don’t want any delay, why don’t you simply resume the continuation in the schedule call?: class TestUiContext : CoroutineDispatcher(), Delay { override fun scheduleResumeAfterDelay(time: Long, unit: TimeUnit, continuation: CancellableContinuation<Unit>) { continuation.resume(Unit) } override fun dispatch(context: CoroutineContext, block: Runnable) { //CommonPool.dispatch(context, block) // dispatch on CommonPool block.run() // dispatch on calling thread } } … Read more

What’s the difference between getTargetContext() and getContext (on InstrumentationRegistry)?

InstrumentationRegistry is an exposed registry instance that holds a reference to the instrumentation running in the process and it’s arguments and allows injection of the following instances: InstrumentationRegistry.getInstrumentation(), returns the Instrumentation currently running. InstrumentationRegistry.getContext(), returns the Context of this Instrumentation’s package. InstrumentationRegistry.getTargetContext(), returns the application Context of the target application. InstrumentationRegistry.getArguments(), returns a copy of … Read more

launchFragmentInContainer unable to resolve Activity in Android

The error was related to the way I did import the dependencies on Gradle. Before: androidTestImplementation(“androidx.fragment:fragment-testing:1.1.0-beta01”) implementation(“androidx.fragment:fragment-ktx:1.1.0-beta01”) androidTestImplementation(“androidx.test:core:1.2.0”) androidTestImplementation(“androidx.test:rules:1.2.0”) androidTestImplementation(“androidx.test:runner:1.2.0”) After: debugImplementation(“androidx.fragment:fragment-testing:1.1.0-beta01”) debugImplementation(“androidx.fragment:fragment-ktx:1.1.0-beta01”) debugImplementation(“androidx.test:core:1.2.0”) debugImplementation(“androidx.test:rules:1.2.0”) debugImplementation(“androidx.test:runner:1.2.0”) Changed from androidTestImplementation to debugImplementation and it solved the issue. Compiling and running, and green test as result.

Testing Snackbar show with Espresso

This worked for me, please try. onView(allOf(withId(android.support.design.R.id.snackbar_text), withText(“My text”))) .check(matches(isDisplayed())); If you use AndroidX, please use the following: onView(withId(com.google.android.material.R.id.snackbar_text)) .check(matches(withText(R.string.whatever_is_your_text)))

Espresso: return boolean if view exists

Conditional logic in tests is undesirable. With that in mind, Espresso’s API was designed to guide the test author away from it (by being explicit with test actions and assertions). Having said that, you can still achieve the above by implementing your own ViewAction and capturing the isDisplayed check (inside the perform method) into an … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)