android-espresso

Create Unit and Instrumentation test for Android project with dynamic features

喜你入骨 提交于 2021-01-29 19:47:42
问题 I have a project where I have main :app package. Besides that, the app contains of two dynamic features inside the same package, :features:A and :features:B. The issue here is that I can't run Unit and Instrumentation tests (Espresso, UI Automator) because of the following error(s): “AAPT: error: resource string/app_name (aka com.app.A.test:string/app_name) not found.” When I run tests(UI tests in this case) App compiles and works without any issues. I figured out that error occurs on

AlertDialog is not getting launched properly(distorting app UI) when i am trying to launch it while doing Espresso test

妖精的绣舞 提交于 2021-01-29 15:00:22
问题 I am trying to test Alert dialog launch code on a fragment button click and as mentioned in the question title it is distorting up the UI whenever i run this test. the layout doesn't appear properly just some icons without the background of the Alertdialog box appears and no text is being displayed. Here's the test: @Test fun mytest() { //on this click dialog should launch onView(withId(R.id.button)).perform(click()) //below line verifies whether the dialog has been launched or not onView

How to check the current Activity in a UI test

五迷三道 提交于 2021-01-29 14:08:42
问题 For tests I use Espresso and Barista I have a test in which I need to open another screen by pressing a button. How can I check if this screen opens? Did the screen I need open? Can I somehow check the chain of screens? To understand that the screens open in the order I need? If someone throws links to good tutorials on UI tests in Android, I will be very grateful. 回答1: An easy solution would be to just check for an element of the new screen to be shown like this: onView(withId(R.id.id_of

How to stub Intent.createChooser Intent using Espresso

≡放荡痞女 提交于 2021-01-28 23:18:48
问题 Problem I have an image inside my app, and am sharing it to any other app that can handle image sharing, and the feature is working perectlty. I am writing an Espresso UI test to intercept the intent and ensure it has the correct action and extras, but cannot seem to get it to work. Code Here is the code when creating the intent: Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_STREAM, uri); intent.setType(MediaType.PNG.toString()); startActivity(Intent

How to stub Intent.createChooser Intent using Espresso

℡╲_俬逩灬. 提交于 2021-01-28 23:11:43
问题 Problem I have an image inside my app, and am sharing it to any other app that can handle image sharing, and the feature is working perectlty. I am writing an Espresso UI test to intercept the intent and ensure it has the correct action and extras, but cannot seem to get it to work. Code Here is the code when creating the intent: Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_STREAM, uri); intent.setType(MediaType.PNG.toString()); startActivity(Intent

Testing multiple build variants simultaneously

老子叫甜甜 提交于 2021-01-28 14:32:42
问题 I created a Test case (using Espresso 2) for an application with multiple Flavors and I would like to run that Test for all the flavors simultaneously (or at least one after the other). Is that possible? At the moment I am only able to run the test for the current Build Variant selected, so I have to manually change the Build Variant and run the test again, one by one. Thank you very much. 来源: https://stackoverflow.com/questions/35917632/testing-multiple-build-variants-simultaneously

NullPointerException in RecyclerViewMatcher when try run my Espresso Test

一曲冷凌霜 提交于 2021-01-27 12:20:22
问题 I want to run Espresso Testing on my Android project Step 1- Find my RecyclerView Step 2- check an Item on the RecyclerView The first Step ran Successfully, but the second which should check the recycler view Item Failed.. This is my test: onView(withRecyclerView(R.id.recyclerView_recipes).atPosition(0)) .check(matches(isDisplayed())); onView(withRecyclerView(R.id.recyclerView_recipes).atPositionOnView(0, R.id.tv_recipe_name)) .check(matches(isDisplayed())) .check(matches(withText("Nutella

Espresso test blocked with background thread. Application not idle Exception: “AppNotIdleException.”

北战南征 提交于 2021-01-27 11:28:05
问题 My android espresso unit test blocked due to some background thread not idle. How can i figure out which thread is blocking my application to execute? android.support.test.espresso.AppNotIdleException: Looped for 246 iterations over 60 SECONDS. The following Idle Conditions failed ASYNC_TASKS_HAVE_IDLED. at dalvik.system.VMStack.getThreadStackTrace(Native Method) at java.lang.Thread.getStackTrace(Thread.java:580) at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyError

Espresso test blocked with background thread. Application not idle Exception: “AppNotIdleException.”

谁说胖子不能爱 提交于 2021-01-27 11:26:42
问题 My android espresso unit test blocked due to some background thread not idle. How can i figure out which thread is blocking my application to execute? android.support.test.espresso.AppNotIdleException: Looped for 246 iterations over 60 SECONDS. The following Idle Conditions failed ASYNC_TASKS_HAVE_IDLED. at dalvik.system.VMStack.getThreadStackTrace(Native Method) at java.lang.Thread.getStackTrace(Thread.java:580) at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyError

How to surpass location enabler dialogue in UI testing Espresso android?

余生颓废 提交于 2021-01-27 06:47:33
问题 I am using Espresso for UI testing android. I wanted to run a test with location off in the settings and I got stuck with the location enabler dialogue as it fails other test. I have mentioned my observations and what I have tried so far Used UiAutomator, it works only on single test case but it fails on complete run of test suite. Used Grant permission rule, it gave permission but the dialogue still exists. Used Roboelectric, it had no effect on the problem. Used Shadow operation, it had no