Git Product home page Git Product logo

testing-samples's Introduction

Android testing samples

A collection of samples demonstrating different frameworks and techniques for automated testing.

Espresso Samples

BasicSample - Basic Espresso sample

CustomMatcherSample - Shows how to extend Espresso to match the hint property of an EditText

DataAdapterSample - Showcases the onData() entry point for Espresso, for lists and AdapterViews

FragmentScenarioSample - Basic usage of FragmentScenario with Espresso.

IdlingResourceSample - Synchronization with background jobs

IntentsBasicSample - Basic usage of intended() and intending()

IntentsAdvancedSample - Simulates a user fetching a bitmap using the camera

MultiWindowSample - Shows how to point Espresso to different windows

RecyclerViewSample - RecyclerView actions for Espresso

ScreenshotSample - Screenshot capturing and saving using Espresso and androidx.test.core APIs

WebBasicSample - Use Espresso-web to interact with WebViews

BasicSampleBundled - Basic sample for Eclipse and other IDEs

MultiProcessSample - Showcases how to use multiprocess Espresso.

UiAutomator Sample

BasicSample - Basic UI Automator sample

AndroidJUnitRunner Sample

AndroidJunitRunnerSample - Showcases test annotations, parameterized tests and testsuite creation

JUnit4 Rules Sample

**All previous samples use ActivityTestRule or IntentsTestRule but there's one specific to ServiceTestRule:

BasicSample - Simple usage of ActivityTestRule

IntentsBasicSample - Simple usage of IntentsTestRule

ServiceTestRuleSample - Simple usage of ServiceTestRule

Prerequisites

  • Android SDK v28
  • Android Build Tools v28.03

Getting Started

These samples use the Gradle build system. To build a project, enter the project directory and use the ./gradlew assemble command or use "Import Project" in Android Studio.

  • Use ./gradlew connectedAndroidTest to run the tests on a connected emulator or device.
  • Use ./gradlew test to run the unit test on your local host.

There is a top-level build.gradle file if you want to build and test all samples from the root directory. This is mostly helpful to build on a CI (Continuous Integration) server.

AndroidX Test Library

Many of these samples use the AndroidX Test Library. Visit the Testing site on developer.android.com for more information.

Experimental Bazel Support

Build status

Some of these samples can be tested with Bazel on Linux. These samples contain a BUILD.bazel file, which is similar to a build.gradle file. The external dependencies are defined in the top level WORKSPACE file.

This is experimental feature. To run the tests, please install the latest version of Bazel (0.12.0 or later) by following the instructions on the Bazel website.

Bazel commands

# Clone the repository if you haven't.
$ git clone https://github.com/google/android-testing
$ cd android-testing

# Edit the path to your local SDK at the top of the WORKSPACE file
$ $EDITOR WORKSPACE

# Test everything in a headless mode (no graphical display)
$ bazel test //... --config=headless

# Test a single test, e.g. ui/espresso/BasicSample/BUILD.bazel
$ bazel test //ui/uiautomator/BasicSample:BasicSampleInstrumentationTest_21_x86 --config=headless

# Query for all android_instrumentation_test targets
$ bazel query 'kind(android_instrumentation_test, //...)'
//ui/uiautomator/BasicSample:BasicSampleInstrumentationTest_23_x86
//ui/uiautomator/BasicSample:BasicSampleInstrumentationTest_22_x86
//ui/uiautomator/BasicSample:BasicSampleInstrumentationTest_21_x86
//ui/uiautomator/BasicSample:BasicSampleInstrumentationTest_19_x86
//ui/espresso/RecyclerViewSample:RecyclerViewSampleInstrumentationTest_23_x86
//ui/espresso/RecyclerViewSample:RecyclerViewSampleInstrumentationTest_22_x86
//ui/espresso/RecyclerViewSample:RecyclerViewSampleInstrumentationTest_21_x86
//ui/espresso/RecyclerViewSample:RecyclerViewSampleInstrumentationTest_19_x86
//ui/espresso/MultiWindowSample:MultiWindowSampleInstrumentationTest_23_x86
//ui/espresso/MultiWindowSample:MultiWindowSampleInstrumentationTest_22_x86
...

# Test everything with GUI enabled
$ bazel test //... --config=gui

# Test with a local device or emulator. Ensure that `adb devices` lists the device.
$ bazel test //... --config=local_device

# If multiple devices are connected, add --device_serial_number=$identifier where $identifier is the name of the device in `adb devices`
$ bazel test //... --config=local_device --test_arg=--device_serial_number=$identifier

For more information, check out the documentation for Android Instrumentation Tests in Bazel. You may also want to check out Building an Android App with Bazel, and the list of Android Rules in the Bazel Build Encyclopedia.

Known issues:

  • Building of APKs is supported on Linux, Mac and Windows, but testing is only supported on Linux.
  • android_instrumentation_test.target_device attribute still needs to be specified even if --config=local_device is used.
  • If using a local device or emulator, the APKs are not uninstalled automatically after the test. Use this command to remove the packages:
    • adb shell pm list packages com.example.android.testing | cut -d ':' -f 2 | tr -d '\r' | xargs -L1 -t adb uninstall

Please file Bazel related issues against the Bazel repository instead of this repository.

Support

If you've found an error in this sample, please file an issue: https://github.com/googlesamples/android-testing

Patches are encouraged, and may be submitted by forking this project and submitting a pull request through GitHub. Please see CONTRIBUTING.md for more details.

License

Copyright 2015 The Android Open Source Project, Inc.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

testing-samples's People

Contributors

adazh avatar bootstraponline avatar brettchabot avatar cdsap avatar comius avatar cutiko avatar dazza5000 avatar devdengchao avatar fsladkey avatar fstanis avatar hoisie avatar jin avatar jongerrish avatar josealcerreca avatar katre avatar marcodallaba avatar nkoroste avatar otw avatar philwo avatar ralf-at-android avatar slinzner avatar tiembo avatar utzcoz avatar valeraz avatar vinaywadhwa avatar vogella avatar wlowe avatar ytrino avatar yuuki3655 avatar zxx714 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

testing-samples's Issues

More Android testing examples - especially about unit tests

Hi,

I don't feel comfortable writing unit testing in my Android app. I know how important part of writing any code that is, so I would like you @google-admin @googlebot ask of any useful materials to improve my testing skills.

I really like Udacity courses about Android development, design, performance and much more... but there are no courses about writing test cases.

Which tools do you recommend and where I can find some about it materials, tutorials?

Regards.

Taking screenshots while running Espresso test methods

Hi,

I would like to ask you about if it is possible to take a screenshot at specifying time while running Espresso UI tests. For example, I'm clicking on floating action button and instantly after clicking take a screenshot to document an action or an error.

If it is possible, could you explain me how I can do it?

[UiAutomator] Fail to locate UI component by resource-id

Hi,

Given the screen shot below, can you illustrate why it cannot be found by selector below ?

BySelector searchButtonSelector = By.res("com.kddi.android.videopass", "com.kddi.android.videopass:id/search");

screenshot 2015-03-24 16 50 57
I also tried below but none of them are working

BySelector searchButtonSelector = By.res("com.kddi.android.videopass", "id/search");
BySelector searchButtonSelector = By.res("com.kddi.android.videopass", "search");
BySelector searchButtonSelector = By.res("com.kddi.android.videopass:id/search");

UiAutomator sample: UiDevice.pressHome and startActivity timeouts

After code call UiDevice.pressHome(), it can not startActivity for 5 seconds (it gets delayed) unless activity was started from user interaction. So test startup is always slow. That's why you have 5 seconds LAUNCH_TIMEOUT ๐Ÿญ

I did not found easy way to workaround it (there are hacky options). Please point out what can be done or at least document it's behavior.

Related code
https://github.com/googlesamples/android-testing/blob/master/uiautomator/BasicSample/app/src/androidTest/java/com/example/android/testing/uiautomator/BasicSample/ChangeTextBehaviorTest.java#L62
Related readings
https://code.google.com/p/android/issues/detail?id=4536
http://stackoverflow.com/questions/5600084/starting-an-activity-from-a-service-after-home-button-pressed-without-the-5-seco
And I've made scaffolding test of stock dialer where I skip UiDevice.pressHome() https://github.com/logcat/uiautomator-template

[UiAutomator] Permission denied when taking screen shot.

Hi,

I presume that with UiAutomator 2.0 the only way to invoke UI testing is using gradle ($ ./gradlew connectedCheck), however it seems like it doesn't have enough privilege to create new file.

03-25 14:48:37.359: E/UiAutomatorBridge(13955): failed to save screen shot to file
03-25 14:48:37.359: E/UiAutomatorBridge(13955): java.io.FileNotFoundException: /data/local/tmp/uiautomator.png: open failed: EACCES (Permission denied)

But if you create the file via adb shell ($ adb shell touch /data/local/tmp/uiautomator.png) first then everything will works fine.

Could you please have a look on the gradle permission issue ?

Thanks,
Dino

BySelector-hasDescendant Have a Bug

error๏ผš
public static BySelector hasChild(BySelector childSelector) {
return (new BySelector()).hasChild(childSelector);
}

public static BySelector hasDescendant(BySelector descendantSelector) {
    return (new BySelector()).hasDescendant(descendantSelector);
}

public static BySelector hasDescendant(BySelector descendantSelector, int maxDepth) {
    return (new BySelector()).hasDescendant(descendantSelector, maxDepth);
}

They call the constructor error, should call the constructor function to achieve
BySelector(BySelector original)

Running code before Application.onCreate

Does Espresso allow a way to run setup code for tests using AndroidJUnit4.class before Application.onCreate() is called by Instrumentation?

I am using Dagger 2 to inject dependencies in Application.onCreate(). It would be really useful for testing to first be able to set my Components with mock dependencies however I'm finding that Application.onCreate always gets called first before anything else.

I've tried using a static { } block and also @BeforeClass annotation but this doesn't work.

Feature Request: mock network calls

Hi,
can you please provide some samples with MockWebServer and MockResponse and stuff? This will help developers understand how to test REST api's.

Thank you,
Igor

Cannot run test

I cannot run your SharedPreferencesHelperTest. I get an error:

IllegalStateException: Could not find matching mockable platform jar.

CalculatorInstrumentationTest not running

I get the following error:

FAILURE: Build failed with an exception.

  • What went wrong:
    Task 'cleanTest' not found in project ':app'.
  • Try:
    Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
    BUILD FAILED
    Total time: 1.518 secs
    Task 'cleanTest' not found in project ':app'.

uiautomator:BasicSample test fail

I clone the code and run the test with command ./gradlew clean connectedAndroidTest in root project. The uiautomator:BasicSample always fail.

below is the fail message from gradle.

com.example.android.testing.uiautomator.BasicSample.ChangeTextBehaviorTest > checkPreconditions[Nexus 5 - 5.1] FAILED 
    java.lang.IllegalStateException: UiAutomationService android.accessibilityservice.IAccessibilityServiceClient$Stub$Proxy@3ce0391calready registered!
    at android.os.Parcel.readException(Parcel.java:1554)

com.example.android.testing.uiautomator.BasicSample.ChangeTextBehaviorTest > testChangeText_newActivity[Nexus 5 - 5.1] FAILED 
    java.lang.IllegalStateException: UiAutomation not connected!
    at android.app.UiAutomation.throwIfNotConnectedLocked(UiAutomation.java:914)

com.example.android.testing.uiautomator.BasicSample.ChangeTextBehaviorTest > testChangeText_sameActivity[Nexus 5 - 5.1] FAILED 
    java.lang.IllegalStateException: UiAutomation not connected!
    at android.app.UiAutomation.throwIfNotConnectedLocked(UiAutomation.java:914)
Tests on Nexus 5 - 5.1 failed: Instrumentation run failed due to 'java.lang.IllegalStateException'
:uiautomator:BasicSample:app:connectedAndroidTest FAILED

FAILURE: Build failed with an exception.

Provide a listener or hook in ActivityTestRule to run something after a test is run and before an activity is finished

I'm trying to write a TestRule that takes a screenshot after a test is run , the code for taking screenshot is working, I'm extending ActivityTestRule but i don't have any hook to run my takeScreenshot method after a test is done but before an activity is finished.

//in ActivityStatement 
      @Override
        public void evaluate() throws Throwable {
            try {
                if (mLaunchActivity) {
                    mActivity = launchActivity(getActivityIntent());
                }
                mBase.evaluate();
            } finally {
                // I need to take a screenshot here , maybe something like beforeActivityFinished 
                finishActivity();
                afterActivityFinished();
            }
        }

maybe ActivityTestRule could have a beforeActivityFinished listener that is invoked just before finishActivity ?

Issue: ViewAction closeSoftKeyboard() does ensure that soft keyboard is completely gone

Tests always fail on real devices:
Nexus7 (2012), Android 5.0.2, factory image, landscape. (Google keyboard, animations disabled)
Nexus5 - Android 5.0.1 factory image, landscape. (Google keyboard, animations disabled)
And Samsung S2 - Android 4.4.4 etc.

Due Google keyboard needs 50 miliseconds to be dismissed as people explain since a year ago and seems to disable animations doesn't help... Only adding Thread.sleep(50) before the next click solves it.

Bug is already reported here:
PerformException: Error performing 'single click' on view
ViewAction closeSoftKeyboard() does ensure that soft keyboard is completely gone

If you need extra info, I can share it or you can reproduce it. You only need to use landscape mode on a nexus device and run the BasicSample.

Logcat:

com.example.android.testing.espresso.BasicSample.ChangeTextBehaviorTest > testChangeText_newActivity[Nexus 7 - 5.0.2] FAILED 
        android.support.test.espresso.PerformException: Error performing 'single click' on view 'with id: com.example.android.testing.espresso.BasicSample:id/activityChangeTextBtn'.
        at android.support.test.espresso.PerformException$Builder.build(PerformException.java:83)

com.example.android.testing.espresso.BasicSample.ChangeTextBehaviorTest > testChangeText_sameActivity[Nexus 7 - 5.0.2] FAILED 
        android.support.test.espresso.PerformException: Error performing 'single click' on view 'with id: com.example.android.testing.espresso.BasicSample:id/changeTextBt'.
        at android.support.test.espresso.PerformException$Builder.build(PerformException.java:83)
:espresso:BasicSample:app:connectedAndroidTest FAILED          

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':espresso:BasicSample:app:connectedAndroidTest'.
> There were failing tests. See the report at: file:///home/ardock/studio/projects/google/googlesamples/android-testing/espresso/BasicSample/app/build/outputs/reports/androidTests/connected/index.html
--------- beginning of system
D/PackageManager(  455): /data/app/vmdl868807800.tmp already staged; skipping copy
D/Finsky  ( 1594): [1] PackageVerificationReceiver.onReceive: Verification requested, id = 2
D/PackageManager(  455): Renaming /data/app/vmdl868807800.tmp to /data/app/com.example.android.testing.espresso.BasicSample-1
I/art     (  455): DexFile_isDexOptNeeded failed to open oat file '/data/dalvik-cache/arm/data@[email protected]@[email protected]' for file location '/data/app/com.example.android.testing.espresso.BasicSample-1/base.apk': Failed to open oat filename for reading: No such file or directory
I/art     (  455): DexFile_isDexOptNeeded failed to open oat file '/data/app/com.example.android.testing.espresso.BasicSample-1/arm/base.odex' for file location '/data/app/com.example.android.testing.espresso.BasicSample-1/base.apk': Failed to open oat filename for reading: No such file or directory
I/PackageManager(  455): Running dexopt on: /data/app/com.example.android.testing.espresso.BasicSample-1/base.apk pkg=com.example.android.testing.espresso.BasicSample isa=arm vmSafeMode=false
I/dex2oat ( 6252): /system/bin/dex2oat --zip-fd=6 --zip-location=/data/app/com.example.android.testing.espresso.BasicSample-1/base.apk --oat-fd=7 --oat-location=/data/dalvik-cache/arm/data@[email protected]@[email protected] --instruction-set=arm --instruction-set-features=default --runtime-arg -Xms64m --runtime-arg -Xmx512m
I/dex2oat ( 6252): dex2oat took 2.419s (threads: 4)
V/BackupManagerService(  455): restoreAtInstall pkg=com.example.android.testing.espresso.BasicSample token=3 restoreSet=0
V/BackupManagerService(  455): Finishing install immediately
W/Settings(  455): Setting install_non_market_apps has moved from android.provider.Settings.Global to android.provider.Settings.Secure, returning read-only value.
I/InputReader(  455): Reconfiguring input devices.  changes=0x00000010
D/Documents( 4253): Update found 7 roots in 19ms
I/UpdateIcingCorporaServi( 1101): Updating corpora: APPS=com.example.android.testing.espresso.BasicSample, CONTACTS=MAYBE
I/ConfigFetchService( 1277): PackageReceiver: Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.example.android.testing.espresso.BasicSample flg=0x4000010 cmp=com.google.android.gms/.config.ConfigFetchService$PackageReceiver (has extras) }
I/ConfigService(  902): onCreate
I/ConfigService(  902): onBind for Intent { act=com.google.android.gms.config.UPDATE pkg=com.google.android.gms } action com.google.android.gms.config.UPDATE
I/ConfigFetchService( 1277): onStartCommand Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.example.android.testing.espresso.BasicSample cmp=com.google.android.gms/.config.ConfigFetchService (has extras) }
I/ConfigFetchService( 1277): launchTask
I/ConfigService(  902): onBind returning update interface
I/ConfigService(  902): onBind for Intent { act=com.google.android.gms.config.START pkg=com.google.android.gms } action com.google.android.gms.config.START
I/ConfigService(  902): onBind returning config service
I/ConfigFetchService( 1277): service connected
I/ConfigClient( 1277): service connected
D/PackageBroadcastService( 1277): Received broadcast action=android.intent.action.PACKAGE_ADDED and uri=com.example.android.testing.espresso.BasicSample
I/UpdateIcingCorporaServi( 1101): UpdateCorporaTask done [took 141 ms] updated apps [took 141 ms] 
D/BackupManagerService(  455): Received broadcast Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.example.android.testing.espresso.BasicSample flg=0x4000010 (has extras) }
W/BackupManagerService(  455): Removing schedule queue dupe of com.example.android.testing.espresso.BasicSample
I/art     (  455): Explicit concurrent mark sweep GC freed 81278(4MB) AllocSpace objects, 17(1258KB) LOS objects, 33% free, 22MB/33MB, paused 1.943ms total 258.559ms
D/AndroidRuntime( 6235): Shutting down VM
W/ResourceType(  455): ResTable_typeSpec entry count inconsistent: given 1, previously 1426
W/Launcher.Model( 2672): Nobody to tell about the new app.  Launcher is probably loading.
W/ResourcesManager( 1003): Asset path '/system/framework/com.google.android.maps.jar' does not exist or contains no resources.
I/Icing   ( 1277): Indexing 314CC0875B3577CA58AC16521A56497F0625B02E from com.google.android.googlequicksearchbox
I/Icing   ( 1277): Indexing done 314CC0875B3577CA58AC16521A56497F0625B02E
D/AndroidRuntime( 6278): 
D/AndroidRuntime( 6278): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
D/AndroidRuntime( 6278): CheckJNI is OFF
E/memtrack( 6278): Couldn't load memtrack module (No such file or directory)
E/android.os.Debug( 6278): failed to load memtrack module: -2
D/AndroidRuntime( 6278): Calling main entry com.android.commands.pm.Pm
D/Finsky  ( 1594): [1] PackageVerificationReceiver.onReceive: Verification requested, id = 3
D/Finsky  ( 1594): [1] WorkerTask.onPreExecute: Verification Requested for id = 3, data=file:///data/local/tmp/app-debug-test-unaligned.apk flags=114 fromVerificationActivity=false
D/Finsky  ( 1594): [1] 2.onResponse: Verification id=3 response=0
D/Finsky  ( 1594): [1] PackageVerificationReceiver.onReceive: Verification requested, id = 3
D/DefContainer( 3872): Copying /data/local/tmp/app-debug-test-unaligned.apk to base.apk
D/PackageManager(  455): Renaming /data/app/vmdl365918615.tmp to /data/app/com.example.android.testing.espresso.BasicSample.test-1
I/art     (  455): DexFile_isDexOptNeeded failed to open oat file '/data/dalvik-cache/arm/data@[email protected]@[email protected]' for file location '/data/app/com.example.android.testing.espresso.BasicSample.test-1/base.apk': Failed to open oat filename for reading: No such file or directory
I/art     (  455): DexFile_isDexOptNeeded failed to open oat file '/data/app/com.example.android.testing.espresso.BasicSample.test-1/arm/base.odex' for file location '/data/app/com.example.android.testing.espresso.BasicSample.test-1/base.apk': Failed to open oat filename for reading: No such file or directory
I/PackageManager(  455): Running dexopt on: /data/app/com.example.android.testing.espresso.BasicSample.test-1/base.apk pkg=com.example.android.testing.espresso.BasicSample.test isa=arm vmSafeMode=false
I/dex2oat ( 6295): /system/bin/dex2oat --zip-fd=6 --zip-location=/data/app/com.example.android.testing.espresso.BasicSample.test-1/base.apk --oat-fd=7 --oat-location=/data/dalvik-cache/arm/data@[email protected]@[email protected] --instruction-set=arm --instruction-set-features=default --runtime-arg -Xms64m --runtime-arg -Xmx512m
D/libgps  (  455): proxy_gps_stop()
D/libgps  (  455): proxy_gps_status_cb()
D/libgps  (  455): proxy_gps_status_cb()
D/libgps  (  455): proxy_gps_release_wakelock_cb()
I/dex2oat ( 6295): dex2oat took 3.100s (threads: 4)
V/BackupManagerService(  455): restoreAtInstall pkg=com.example.android.testing.espresso.BasicSample.test token=4 restoreSet=0
V/BackupManagerService(  455): Finishing install immediately
W/Settings(  455): Setting install_non_market_apps has moved from android.provider.Settings.Global to android.provider.Settings.Secure, returning read-only value.
I/ConfigClient( 1277): received Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.example.android.testing.espresso.BasicSample.test flg=0x4000010 (has extras) }
D/Documents( 4253): Update found 7 roots in 8ms
I/InputReader(  455): Reconfiguring input devices.  changes=0x00000010
I/UpdateIcingCorporaServi( 1101): Updating corpora: APPS=com.example.android.testing.espresso.BasicSample.test, CONTACTS=MAYBE
I/ConfigFetchService( 1277): PackageReceiver: Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.example.android.testing.espresso.BasicSample.test flg=0x4000010 cmp=com.google.android.gms/.config.ConfigFetchService$PackageReceiver (has extras) }
D/BackupManagerService(  455): Received broadcast Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.example.android.testing.espresso.BasicSample.test flg=0x4000010 (has extras) }
I/UpdateIcingCorporaServi( 1101): UpdateCorporaTask done [took 27 ms] updated apps [took 27 ms] 
W/BackupManagerService(  455): Removing schedule queue dupe of com.example.android.testing.espresso.BasicSample.test
I/ConfigFetchService( 1277): onStartCommand Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.example.android.testing.espresso.BasicSample.test cmp=com.google.android.gms/.config.ConfigFetchService (has extras) }
D/PackageBroadcastService( 1277): Received broadcast action=android.intent.action.PACKAGE_ADDED and uri=com.example.android.testing.espresso.BasicSample.test
W/Launcher.Model( 2672): Nobody to tell about the new app.  Launcher is probably loading.
I/art     (  455): Explicit concurrent mark sweep GC freed 26369(1910KB) AllocSpace objects, 16(410KB) LOS objects, 33% free, 22MB/33MB, paused 1.774ms total 219.857ms
D/AndroidRuntime( 6278): Shutting down VM
D/AndroidRuntime( 6317): 
D/AndroidRuntime( 6317): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
D/AndroidRuntime( 6317): CheckJNI is OFF
E/memtrack( 6317): Couldn't load memtrack module (No such file or directory)
E/android.os.Debug( 6317): failed to load memtrack module: -2
D/AndroidRuntime( 6317): Calling main entry com.android.commands.am.Am
I/ActivityManager(  455): Force stopping com.example.android.testing.espresso.BasicSample appid=10205 user=0: start instr
I/ActivityManager(  455): Start proc com.example.android.testing.espresso.BasicSample for added application com.example.android.testing.espresso.BasicSample: pid=6331 uid=10205 gids={50205, 9997} abi=armeabi-v7a
I/art     ( 6331): Late-enabling -Xcheck:jni
I/MonitoringInstrumentation( 6331): Instrumentation Started!
I/AndroidJUnitRunner( 6331): Setting context classloader to 'dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/com.example.android.testing.espresso.BasicSample.test-1/base.apk", zip file "/data/app/com.example.android.testing.espresso.BasicSample-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]]', Original: 'dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/com.example.android.testing.espresso.BasicSample.test-1/base.apk", zip file "/data/app/com.example.android.testing.espresso.BasicSample-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]]'
D/InfraTrack( 6331): Tracking disabled due to lack of internet permissions
I/TestRequestBuilder( 6331): Scanning classpath to find tests in apks [/data/app/com.example.android.testing.espresso.BasicSample.test-1/base.apk]
I/TestRunner( 6331): run started: 2 tests
I/TestRunner( 6331): started: testChangeText_newActivity(com.example.android.testing.espresso.BasicSample.ChangeTextBehaviorTest)
I/MonitoringInstrumentation( 6331): Activities that are still in CREATED to PAUSED: 0
I/ActivityManager(  455): START u0 {act=android.intent.action.MAIN flg=0x14000000 cmp=com.example.android.testing.espresso.BasicSample/.MainActivity} from uid 10205 on display 0
D/LifecycleMonitor( 6331): Lifecycle status change: com.example.android.testing.espresso.BasicSample.MainActivity@3b34b917 in: PRE_ON_CREATE
D/LifecycleMonitor( 6331): Lifecycle status change: com.example.android.testing.espresso.BasicSample.MainActivity@3b34b917 in: CREATED
D/LifecycleMonitor( 6331): Lifecycle status change: com.example.android.testing.espresso.BasicSample.MainActivity@3b34b917 in: STARTED
D/LifecycleMonitor( 6331): Lifecycle status change: com.example.android.testing.espresso.BasicSample.MainActivity@3b34b917 in: RESUMED
D/OpenGLRenderer( 6331): Render dirty regions requested: false
D/Atlas   ( 6331): Validating map...
D/libEGL  ( 6331): loaded /system/lib/egl/libEGL_tegra.so
D/libEGL  ( 6331): loaded /system/lib/egl/libGLESv1_CM_tegra.so
D/libEGL  ( 6331): loaded /system/lib/egl/libGLESv2_tegra.so
I/OpenGLRenderer( 6331): Initialized EGL, version 1.4
D/OpenGLRenderer( 6331): Enabling debug mode 0
I/ActivityManager(  455): Displayed com.example.android.testing.espresso.BasicSample/.MainActivity: +635ms
I/LatinIME(  743): Starting input. Cursor position = -1,-1
E/RichInputConnection(  743): Unable to connect to the editor to retrieve text.
D/RichInputConnection(  743): Will try to retrieve text later.
I/InputAttributes(  743): InputType.TYPE_NULL is specified
D/InputManagerEventInjectionStrategy( 6331): Creating injection strategy with input manager.
I/LatinIME(  743): Starting input. Cursor position = 0,0
I/ViewInteraction( 6331): Performing 'type text(Espresso)' action on view with id: com.example.android.testing.espresso.BasicSample:id/editTextUserInput
D/UiControllerImpl( 6331): Injecting string: "Espresso"
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (\C0\80) with key code (59) downtime: (1932792)
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (E) with key code (33) downtime: (1932792)
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (E) with key code (33) downtime: (1932792)
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (\C0\80) with key code (59) downtime: (1932792)
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (s) with key code (47) downtime: (1932792)
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (s) with key code (47) downtime: (1932792)
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (p) with key code (44) downtime: (1932792)
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (p) with key code (44) downtime: (1932792)
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (r) with key code (46) downtime: (1932792)
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (r) with key code (46) downtime: (1932792)
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (e) with key code (33) downtime: (1932792)
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (e) with key code (33) downtime: (1932792)
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (s) with key code (47) downtime: (1932792)
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (s) with key code (47) downtime: (1932792)
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (s) with key code (47) downtime: (1932792)
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (s) with key code (47) downtime: (1932792)
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (o) with key code (43) downtime: (1932792)
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (o) with key code (43) downtime: (1932792)
I/ViewInteraction( 6331): Performing 'close keyboard' action on view with id: com.example.android.testing.espresso.BasicSample:id/editTextUserInput
I/ViewInteraction( 6331): Performing 'single click' action on view with id: com.example.android.testing.espresso.BasicSample:id/activityChangeTextBtn
E/ViewAssertions( 6331): 'with text: is "Espresso"' check could not be performed because view 'with id: com.example.android.testing.espresso.BasicSample:id/show_text_view' was not found.
D/LifecycleMonitor( 6331): Lifecycle status change: com.example.android.testing.espresso.BasicSample.MainActivity@3b34b917 in: PAUSED
I/MicrophoneInputStream( 1101): mic_close gfk@308920bf
I/HotwordRecognitionRnr( 1101): Stopping hotword detection.
W/SurfaceFlinger(  129): couldn't log to binary event log: overflow.
W/IInputConnectionWrapper( 6331): showStatusIcon on inactive InputConnection
I/HotwordRecognitionRnr( 1101): Hotword detection finished
I/art     ( 6331): Explicit concurrent mark sweep GC freed 24929(1323KB) AllocSpace objects, 1(12KB) LOS objects, 40% free, 7MB/12MB, paused 1.687ms total 101.106ms
D/LifecycleMonitor( 6331): Lifecycle status change: com.example.android.testing.espresso.BasicSample.MainActivity@3b34b917 in: STOPPED
D/LifecycleMonitor( 6331): Lifecycle status change: com.example.android.testing.espresso.BasicSample.MainActivity@3b34b917 in: DESTROYED
W/LocationOracleImpl( 1101): Best location was null
W/LocationOracleImpl( 1101): Best location was null
I/art     ( 6331): Explicit concurrent mark sweep GC freed 396(18KB) AllocSpace objects, 0(0B) LOS objects, 39% free, 7MB/11MB, paused 2.870ms total 74.433ms
I/TestRunner( 6331): failed: testChangeText_newActivity(com.example.android.testing.espresso.BasicSample.ChangeTextBehaviorTest)
I/TestRunner( 6331): ----- begin exception -----
I/TestRunner( 6331): android.support.test.espresso.NoMatchingViewException: No views in hierarchy found matching: with id: com.example.android.testing.espresso.BasicSample:id/show_text_view
I/TestRunner( 6331): 
I/TestRunner( 6331): View Hierarchy:
I/TestRunner( 6331): +>DecorView{id=-1, visibility=VISIBLE, width=555, height=520, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=1} 
I/TestRunner( 6331): |
I/TestRunner( 6331): +->FrameLayout{id=-1, visibility=VISIBLE, width=513, height=478, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=21.0, y=21.0, child-count=2} 
I/TestRunner( 6331): |
I/TestRunner( 6331): +-->FrameLayout{id=16908290, res-name=content, visibility=VISIBLE, width=513, height=478, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=1} 
I/TestRunner( 6331): |
I/TestRunner( 6331): +--->LinearLayout{id=-1, visibility=VISIBLE, width=513, height=478, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=4} 
I/TestRunner( 6331): |
I/TestRunner( 6331): +---->TextView{id=2131165184, res-name=textToBeChanged, visibility=VISIBLE, width=119, height=39, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=197.0, y=128.0, text=Espresso, input-type=0, ime-target=false, has-links=false} 
I/TestRunner( 6331): |
I/TestRunner( 6331): +---->EditText{id=2131165185, res-name=editTextUserInput, visibility=VISIBLE, width=343, height=55, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=true, is-enabled=true, is-focused=true, is-focusable=true, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=true, editor-info=[inputType=0x20001 imeOptions=0x40000006 privateImeOptions=null actionLabel=null actionId=0 initialSelStart=8 initialSelEnd=8 initialCapsMode=0x0 hintText=type somethingโ€ฆ label=null packageName=null fieldId=0 fieldName=null extras=null ], x=85.0, y=210.0, text=Espresso, hint=type somethingโ€ฆ, input-type=131073, ime-target=true, has-links=false} 
I/TestRunner( 6331): |
I/TestRunner( 6331): +---->Button{id=2131165186, res-name=changeTextBt, visibility=VISIBLE, width=158, height=64, has-focus=false, has-focusable=true, has-window-focus=true, is-clickable=true, is-enabled=true, is-focused=false, is-focusable=true, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=177.0, y=265.0, text=Change text, input-type=0, ime-target=false, has-links=false} 
I/TestRunner( 6331): |
I/TestRunner( 6331): +---->Button{id=2131165187, res-name=activityChangeTextBtn, visibility=VISIBLE, width=343, height=64, has-focus=false, has-focusable=true, has-window-focus=true, is-clickable=true, is-enabled=true, is-focused=false, is-focusable=true, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=85.0, y=329.0, text=Open activity and change text, input-type=0, ime-target=false, has-links=false} 
I/TestRunner( 6331): |
I/TestRunner( 6331): +-->ViewStub{id=16909166, visibility=GONE, width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=true, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0} 
I/TestRunner( 6331): |
I/TestRunner( 6331):    at dalvik.system.VMStack.getThreadStackTrace(Native Method)
I/TestRunner( 6331):    at java.lang.Thread.getStackTrace(Thread.java:580)
I/TestRunner( 6331):    at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyE
I/TestRunner( 6331): ----- end exception -----
I/TestRunner( 6331): finished: testChangeText_newActivity(com.example.android.testing.espresso.BasicSample.ChangeTextBehaviorTest)
I/MicrophoneInputStream( 1101): mic_starting gfk@110891bb
I/MonitoringInstrumentation( 6331): Activities that are still in CREATED to PAUSED: 0
I/TestRunner( 6331): started: testChangeText_sameActivity(com.example.android.testing.espresso.BasicSample.ChangeTextBehaviorTest)
I/MonitoringInstrumentation( 6331): Activities that are still in CREATED to PAUSED: 0
I/AudioFlinger(  135): AudioFlinger's thread 0x40fd0008 ready to run
I/HotwordRecognitionRnr( 1101): Starting hotword detection.
I/MicrophoneInputStream( 1101): mic_started gfk@110891bb
I/ActivityManager(  455): START u0 {act=android.intent.action.MAIN flg=0x10000000 cmp=com.example.android.testing.espresso.BasicSample/.MainActivity} from uid 10205 on display 0
W/GCoreFlp( 1323): No location to return for getLastLocation()
D/LifecycleMonitor( 6331): Lifecycle status change: com.example.android.testing.espresso.BasicSample.MainActivity@143fb3f4 in: PRE_ON_CREATE
D/LifecycleMonitor( 6331): Lifecycle status change: com.example.android.testing.espresso.BasicSample.MainActivity@143fb3f4 in: CREATED
D/LifecycleMonitor( 6331): Lifecycle status change: com.example.android.testing.espresso.BasicSample.MainActivity@143fb3f4 in: STARTED
D/LifecycleMonitor( 6331): Lifecycle status change: com.example.android.testing.espresso.BasicSample.MainActivity@143fb3f4 in: RESUMED
V/ConfigFetchTask( 1277): ConfigFetchTask getDeviceDataVersionInfo(): ABFEt1WJ34I-y1RzmXeJwYm3-zibuATjSGAHNX884SH5BYO85tS6pFdHXjFPo8W_b4RdZY7G3FDKuViiPIv5LrvgrSysAbhxt_iMC-tmZrVrhRpsdQy-G2sIga9eK3lC8kfCqzI4WqOjhOMYeOIAGR37otjFeh29iv-p4lL3gzRpcK4VBi9yEH1Ip7HYPYRY06GMSPtWuNcC94ndLklgoOr4QH0JpEBLpOz97FjcpUww0krOCUm4Ru06sVO20CGycFDo24-mVUdXEx4L0IveCdfsUDOB73inl3OzMhWN316ruz8SGd_tQpI
I/HotwordWorker( 1101): onReady
I/GoogleHttpClient( 1277): Falling back to old SSLCertificateSocketFactory
I/ActivityManager(  455): Displayed com.example.android.testing.espresso.BasicSample/.MainActivity: +117ms
I/LatinIME(  743): Starting input. Cursor position = 0,0
I/ViewInteraction( 6331): Performing 'type text(Espresso)' action on view with id: com.example.android.testing.espresso.BasicSample:id/editTextUserInput
D/UiControllerImpl( 6331): Injecting string: "Espresso"
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (\C0\80) with key code (59) downtime: (1934206)
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (E) with key code (33) downtime: (1934206)
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (E) with key code (33) downtime: (1934206)
I/ConfigFetchService( 1277): launchTask
V/ConfigFetchTask( 1277): ConfigFetchTask getDeviceDataVersionInfo(): ABFEt1WJ34I-y1RzmXeJwYm3-zibuATjSGAHNX884SH5BYO85tS6pFdHXjFPo8W_b4RdZY7G3FDKuViiPIv5LrvgrSysAbhxt_iMC-tmZrVrhRpsdQy-G2sIga9eK3lC8kfCqzI4WqOjhOMYeOIAGR37otjFeh29iv-p4lL3gzRpcK4VBi9yEH1Ip7HYPYRY06GMSPtWuNcC94ndLklgoOr4QH0JpEBLpOz97FjcpUww0krOCUm4Ru06sVO20CGycFDo24-mVUdXEx4L0IveCdfsUDOB73inl3OzMhWN316ruz8SGd_tQpI
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (\C0\80) with key code (59) downtime: (1934206)
I/GoogleHttpClient( 1277): Falling back to old SSLCertificateSocketFactory
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (s) with key code (47) downtime: (1934206)
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (s) with key code (47) downtime: (1934206)
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (p) with key code (44) downtime: (1934206)
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (p) with key code (44) downtime: (1934206)
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (r) with key code (46) downtime: (1934206)
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (r) with key code (46) downtime: (1934206)
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (e) with key code (33) downtime: (1934206)
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (e) with key code (33) downtime: (1934206)
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (s) with key code (47) downtime: (1934206)
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (s) with key code (47) downtime: (1934206)
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (s) with key code (47) downtime: (1934206)
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (s) with key code (47) downtime: (1934206)
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (o) with key code (43) downtime: (1934206)
V/ESP_TRACE( 6331): EventInjector:Injecting event for character (o) with key code (43) downtime: (1934206)
I/ViewInteraction( 6331): Performing 'close keyboard' action on view with id: com.example.android.testing.espresso.BasicSample:id/editTextUserInput
I/ViewInteraction( 6331): Performing 'single click' action on view with id: com.example.android.testing.espresso.BasicSample:id/changeTextBt
W/InputDispatcher(  455): Permission denied: injecting event from pid 6331 uid 10205 to window Window{3b197ccc u0 InputMethod} owned by uid 10054
W/InputManager(  455): Input event injection from pid 6331 permission denied.
D/LifecycleMonitor( 6331): Lifecycle status change: com.example.android.testing.espresso.BasicSample.MainActivity@143fb3f4 in: PAUSED
I/ConfigFetchService( 1277): fetch service done; releasing wakelock
I/ConfigFetchService( 1277): stopping self
I/ConfigService(  902): onDestroy
I/art     ( 6331): Explicit concurrent mark sweep GC freed 5078(364KB) AllocSpace objects, 6(90KB) LOS objects, 40% free, 7MB/12MB, paused 3.054ms total 70.134ms
W/SurfaceFlinger(  129): couldn't log to binary event log: overflow.
W/IInputConnectionWrapper( 6331): showStatusIcon on inactive InputConnection
I/art     ( 6331): Explicit concurrent mark sweep GC freed 217(9KB) AllocSpace objects, 0(0B) LOS objects, 39% free, 7MB/12MB, paused 2.507ms total 66.390ms
I/TestRunner( 6331): failed: testChangeText_sameActivity(com.example.android.testing.espresso.BasicSample.ChangeTextBehaviorTest)
I/TestRunner( 6331): ----- begin exception -----
I/TestRunner( 6331): android.support.test.espresso.PerformException: Error performing 'single click' on view 'with id: com.example.android.testing.espresso.BasicSample:id/changeTextBt'.
I/TestRunner( 6331):    at android.support.test.espresso.PerformException$Builder.build(PerformException.java:83)
I/TestRunner( 6331):    at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:70)
I/TestRunner( 6331):    at android.support.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:53)
I/TestRunner( 6331):    at android.support.test.espresso.ViewInteraction.runSynchronouslyOnUiThread(ViewInteraction.java:185)
I/TestRunner( 6331):    at android.support.test.espresso.ViewInteraction.doPerform(ViewInteraction.java:115)
I/TestRunner( 6331):    at android.support.test.espresso.ViewInteraction.perform(ViewInteraction.java:87)
I/TestRunner( 6331):    at com.example.android.testing.espresso.BasicSample.ChangeTextBehaviorTest.testChangeText_sameActivity(ChangeTextBehaviorTest.java:61)
I/TestRunner( 6331):    at java.lang.reflect.Method.invoke(Native Method)
I/TestRunner( 6331):    at java.lang.reflect.Method.invoke(Method.java:372)
I/TestRunner( 6331):    at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
I/TestRunner( 6331):    at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
I/TestRunner( 6331):    at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:192)
I/TestRunner( 6331):    at junit.framework.TestCase.runBare(TestCase.java:134)
I/TestRunner( 6331):    at junit.framework.TestResult$1.protect(TestResult.java:115)
I/TestRunner( 6331):    at junit.framework.TestResult.runProtected(TestResult.java:133)
I/TestRunner( 6331):    at android.support.test.internal.runner.junit3.DelegatingTestResult.runProtected(DelegatingTestResult.java:90)
I/TestRunner( 6331):    at junit.framework.TestResult.run(TestResult.java:118)
I/TestRunner( 6331):    at android.support.test.internal.runner.junit3.AndroidTestResult.run(AndroidTestResult.java:49)
I/TestRunner( 6331):    at junit.framework.TestCase.run(TestCase.java:124)
I/TestRunner( 6331):    at android.support.test.internal.runner.junit3.NonLeakyTestSuite$NonLeakyTest.run(NonLeakyTestSuite.java:63)
I/TestRunner( 6331):    at junit.framework.TestSuite.runTest(TestSuite.java:243)
I/TestRunner( 6331):    at junit.framework.TestSuite.run(TestSuite.java:238)
I/TestRunner( 6331):    at android.support.test.internal.runner.junit3.DelegatingTestSuite.run(DelegatingTestSuite.java:103)
I/TestRunner( 6331):    at android.support.test.internal.runner.junit3.AndroidTestSuite.run(AndroidTestSuite.java:63)
I/TestRunner( 6331):    at android.support.test.internal.runner.junit3.JUnit38ClassRunner.run(JUnit38ClassRunner.java:90)
I/TestRunner( 6331):    at org.junit.runners.Suite.runChild(Suite.java:128)
I/TestRunner( 6331):    at org.junit.runners.Suite.runChild(Suite.java:24)
I/TestRunner( 6331):    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
I/TestRunner( 6331):    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
I/TestRunner( 6331):    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
I/TestRunner( 6331):    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
I/TestRunner( 6331):    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
I/TestRunner( 6331):    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
I/TestRunner( 6331):    at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
I/TestRunner( 6331):    at org.junit.runner.JUnitCore.run(JUnitCore.java:136)
I/TestRunner( 6331):    at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:270)
I/TestRunner( 6331):    at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1837)
I/TestRunner( 6331): Caused by: android.support.test.espresso.PerformException: Error performing 'Send down montion event' on view 'unknown'.
I/TestRunner( 6331):    at android.support.test.espresso.PerformException$Builder.build(PerformException.java:83)
I/TestRunner( 6331):    at android.support.test.espresso.action.MotionEvents.sendDown(MotionEvents.java:104)
I/TestRunner( 6331):    at android.support.test.espresso.action.Tap.sendSingleTap(Tap.java:133)
I/TestRunner( 6331):    at android.support.test.espresso.action.Tap.access$100(Tap.java:35)
I/TestRunner( 6331):    at android.support.test.espresso.action.Tap$1.sendTap(Tap.java:40)
I/TestRunner( 6331):    at android.support.test.espresso.action.GeneralClickAction.perform(GeneralClickAction.java:98)
I/TestRunner( 6331):    at android.support.test.espresso.ViewInteraction$1.run(ViewInteraction.java:144)
I/TestRunner( 6331):    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
I/TestRunner( 6331):    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
I/TestRunner( 6331):    at android.os.Handler.handleCallback(Handler.java:739)
I/TestRunner( 6331):    at android.os.Handler.dispatchMessage(Handler.java:95)
I/TestRunner( 6331):    at android.os.Looper.loop(Looper.java:135)
I/TestRunner( 6331):    at android.app.ActivityThre
I/TestRunner( 6331): ----- end exception -----
D/LifecycleMonitor( 6331): Lifecycle status change: com.example.android.testing.espresso.BasicSample.MainActivity@143fb3f4 in: STOPPED
D/LifecycleMonitor( 6331): Lifecycle status change: com.example.android.testing.espresso.BasicSample.MainActivity@143fb3f4 in: DESTROYED
I/TestRunner( 6331): finished: testChangeText_sameActivity(com.example.android.testing.espresso.BasicSample.ChangeTextBehaviorTest)
W/LocationOracleImpl( 1101): Best location was null
I/MonitoringInstrumentation( 6331): Activities that are still in CREATED to PAUSED: 0
I/TestRunner( 6331): run finished: 2 tests, 2 failed, 0 ignored
I/MonitoringInstrumentation( 6331): Activities that are still in CREATED to PAUSED: 0
I/MonitoringInstrumentation( 6331): waitForActivitiesToComplete() took: 0ms
D/AndroidRuntime( 6317): Shutting down VM
I/ActivityManager(  455): Force stopping com.example.android.testing.espresso.BasicSample appid=10205 user=0: finished inst
I/ActivityManager(  455): Killing 6331:com.example.android.testing.espresso.BasicSample/u0a205 (adj 0): stop com.example.android.testing.espresso.BasicSample
W/ActivityManager(  455): Spurious death for ProcessRecord{132139fe 6331:com.example.android.testing.espresso.BasicSample/u0a205}, curProc for 6331: null
D/AndroidRuntime( 6391): 
D/AndroidRuntime( 6391): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
D/AndroidRuntime( 6391): CheckJNI is OFF
E/memtrack( 6391): Couldn't load memtrack module (No such file or directory)
E/android.os.Debug( 6391): failed to load memtrack module: -2
D/AndroidRuntime( 6391): Calling main entry com.android.commands.pm.Pm
I/ActivityManager(  455): Force stopping com.example.android.testing.espresso.BasicSample.test appid=10206 user=-1: uninstall pkg
I/ActivityManager(  455): Force stopping com.example.android.testing.espresso.BasicSample.test appid=10206 user=0: pkg removed
W/GeofencerStateMachine( 1323): Ignoring removeGeofence because network location is disabled.
I/InputReader(  455): Reconfiguring input devices.  changes=0x00000010
D/Documents( 4253): Update found 7 roots in 8ms
D/VoicemailCleanupService( 1076): Cleaning up data for package: com.example.android.testing.espresso.BasicSample.test
I/UpdateIcingCorporaServi( 1101): Updating corpora: APPS=com.example.android.testing.espresso.BasicSample.test, CONTACTS=MAYBE
I/LatinIME:LogUtils(  743): Dictionary info: dictionary = main:en_us ; version = 52 ; date = 1412572954
I/LatinIME:LogUtils(  743): Dictionary info: dictionary = main:en_us ; version = 52 ; date = 1412572954
W/Launcher( 1003): setApplicationContext called twice! old=com.google.android.velvet.VelvetApplication@3b34b917 new=com.google.android.velvet.VelvetApplication@3b34b917
W/ContextImpl( 3915): Calling a method in the system process without a qualified user: android.app.ContextImpl.startService:1686 android.content.ContextWrapper.startService:515 android.content.ContextWrapper.startService:515 com.android.keychain.KeyChainBroadcastReceiver.onReceive:12 android.app.ActivityThread.handleReceiver:2579 
I/UpdateIcingCorporaServi( 1101): UpdateCorporaTask done [took 50 ms] updated apps [took 50 ms] 
I/ConfigFetchService( 1277): PackageReceiver: Intent { act=android.intent.action.PACKAGE_REMOVED dat=package:com.example.android.testing.espresso.BasicSample.test flg=0x4000010 cmp=com.google.android.gms/.config.ConfigFetchService$PackageReceiver (has extras) }
I/ConfigService(  902): onCreate
I/ConfigService(  902): onBind for Intent { act=com.google.android.gms.config.UPDATE pkg=com.google.android.gms } action com.google.android.gms.config.UPDATE
I/ConfigFetchService( 1277): onStartCommand Intent { act=android.intent.action.PACKAGE_REMOVED dat=package:com.example.android.testing.espresso.BasicSample.test cmp=com.google.android.gms/.config.ConfigFetchService (has extras) }
I/ConfigService(  902): onBind returning update interface
I/ConfigService(  902): onBind for Intent { act=com.google.android.gms.config.START pkg=com.google.android.gms } action com.google.android.gms.config.START
I/ConfigService(  902): onBind returning config service
I/ConfigService(  902): onDestroy
I/LocationSettingsChecker( 3937): Removing dialog suppression flag for package com.example.android.testing.espresso.BasicSample.test
D/PackageBroadcastService( 1277): Received broadcast action=android.intent.action.PACKAGE_REMOVED and uri=com.example.android.testing.espresso.BasicSample.test
D/AccountUtils( 1277): Clearing selected account for com.example.android.testing.espresso.BasicSample.test
I/Icing   ( 1277): doRemovePackageData com.example.android.testing.espresso.BasicSample.test
D/BackupManagerService(  455): Received broadcast Intent { act=android.intent.action.PACKAGE_REMOVED dat=package:com.example.android.testing.espresso.BasicSample.test flg=0x4000010 (has extras) }
D/JobSchedulerService(  455): Receieved: android.intent.action.PACKAGE_REMOVED
I/art     (  455): Explicit concurrent mark sweep GC freed 32692(1909KB) AllocSpace objects, 8(2MB) LOS objects, 33% free, 23MB/35MB, paused 2.161ms total 286.431ms
D/AndroidRuntime( 6391): Shutting down VM
W/ResourceType(  455): ResTable_typeSpec entry count inconsistent: given 1, previously 1426
W/Launcher.Model( 2672): Nobody to tell about the new app.  Launcher is probably loading.
D/AndroidRuntime( 6427): 
D/AndroidRuntime( 6427): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
D/AndroidRuntime( 6427): CheckJNI is OFF
E/memtrack( 6427): Couldn't load memtrack module (No such file or directory)
E/android.os.Debug( 6427): failed to load memtrack module: -2
D/AndroidRuntime( 6427): Calling main entry com.android.commands.pm.Pm
I/ActivityManager(  455): Force stopping com.example.android.testing.espresso.BasicSample appid=10205 user=-1: uninstall pkg
I/ActivityManager(  455): Force stopping com.example.android.testing.espresso.BasicSample appid=10205 user=0: pkg removed
I/InputReader(  455): Reconfiguring input devices.  changes=0x00000010
W/GeofencerStateMachine( 1323): Ignoring removeGeofence because network location is disabled.
I/art     ( 2672): Explicit concurrent mark sweep GC freed 327(16KB) AllocSpace objects, 1(36KB) LOS objects, 24% free, 5MB/7MB, paused 523us total 40.393ms
D/VoicemailCleanupService( 1076): Cleaning up data for package: com.example.android.testing.espresso.BasicSample
I/LatinIME:LogUtils(  743): Dictionary info: dictionary = main:en_us ; version = 52 ; date = 1412572954
D/Documents( 4253): Update found 7 roots in 44ms
I/art     ( 1101): Explicit concurrent mark sweep GC freed 21495(1438KB) AllocSpace objects, 7(795KB) LOS objects, 39% free, 11MB/19MB, paused 2.336ms total 67.331ms
I/LatinIME:LogUtils(  743): Dictionary info: dictionary = main:en_us ; version = 52 ; date = 1412572954
D/BackupManagerService(  455): Received broadcast Intent { act=android.intent.action.PACKAGE_REMOVED dat=package:com.example.android.testing.espresso.BasicSample flg=0x4000010 (has extras) }
D/JobSchedulerService(  455): Receieved: android.intent.action.PACKAGE_REMOVED
I/art     ( 1003): Explicit concurrent mark sweep GC freed 75708(3MB) AllocSpace objects, 5(180KB) LOS objects, 39% free, 15MB/25MB, paused 1.702ms total 114.393ms
D/TaskPersister(  455): removeObsoleteFile: deleting file=377_task.xml
D/TaskPersister(  455): removeObsoleteFile: deleting file=377_task_thumbnail.png
I/UpdateIcingCorporaServi( 1101): Updating corpora: APPS=com.example.android.testing.espresso.BasicSample, CONTACTS=MAYBE
W/Launcher( 1003): setApplicationContext called twice! old=com.google.android.velvet.VelvetApplication@3b34b917 new=com.google.android.velvet.VelvetApplication@3b34b917
W/ContextImpl( 3915): Calling a method in the system process without a qualified user: android.app.ContextImpl.startService:1686 android.content.ContextWrapper.startService:515 android.content.ContextWrapper.startService:515 com.android.keychain.KeyChainBroadcastReceiver.onReceive:12 android.app.ActivityThread.handleReceiver:2579 
I/ConfigFetchService( 1277): PackageReceiver: Intent { act=android.intent.action.PACKAGE_REMOVED dat=package:com.example.android.testing.espresso.BasicSample flg=0x4000010 cmp=com.google.android.gms/.config.ConfigFetchService$PackageReceiver (has extras) }
I/ConfigService(  902): onCreate
I/ConfigService(  902): onBind for Intent { act=com.google.android.gms.config.UPDATE pkg=com.google.android.gms } action com.google.android.gms.config.UPDATE
I/ConfigFetchService( 1277): onStartCommand Intent { act=android.intent.action.PACKAGE_REMOVED dat=package:com.example.android.testing.espresso.BasicSample cmp=com.google.android.gms/.config.ConfigFetchService (has extras) }
I/ConfigService(  902): onBind returning update interface
I/ConfigService(  902): onBind for Intent { act=com.google.android.gms.config.START pkg=com.google.android.gms } action com.google.android.gms.config.START
I/ConfigService(  902): onBind returning config service
W/Launcher.Model( 2672): Nobody to tell about the new app.  Launcher is probably loading.
I/ConfigService(  902): onDestroy
I/LocationSettingsChecker( 3937): Removing dialog suppression flag for package com.example.android.testing.espresso.BasicSample
D/PackageBroadcastService( 1277): Received broadcast action=android.intent.action.PACKAGE_REMOVED and uri=com.example.android.testing.espresso.BasicSample
D/AccountUtils( 1277): Clearing selected account for com.example.android.testing.espresso.BasicSample
W/ResourcesManager( 1003): Asset path '/system/framework/com.google.android.maps.jar' does not exist or contains no resources.
I/UpdateIcingCorporaServi( 1101): UpdateCorporaTask done [took 181 ms] updated apps [took 181 ms] 
I/Icing   ( 1277): doRemovePackageData com.example.android.testing.espresso.BasicSample
I/art     (  455): Explicit concurrent mark sweep GC freed 21999(1520KB) AllocSpace objects, 5(960KB) LOS objects, 33% free, 22MB/33MB, paused 3.016ms total 314.013ms
D/AndroidRuntime( 6427): Shutting down VM

The soft keyboard is still overlapping the buttons when are clicked.
http://stackoverflow.com/questions/3553779/android-dismiss-keyboard/18858246#18858246

Related code:

  private void tryToCloseKeyboard(View view, UiController uiController) throws TimeoutException {
    InputMethodManager imm = (InputMethodManager) getRootActivity(uiController)
        .getSystemService(Context.INPUT_METHOD_SERVICE);
    final AtomicInteger atomicResultCode = new AtomicInteger();
    final CountDownLatch latch = new CountDownLatch(1);

    ResultReceiver result = new ResultReceiver(null) {
      @Override
      protected void onReceiveResult(int resultCode, Bundle resultData) {
        atomicResultCode.set(resultCode);
        latch.countDown();
      }
    };

    if (!imm.hideSoftInputFromWindow(view.getWindowToken(), 0, result)) {
      Log.w(TAG, "Attempting to close soft keyboard, while it is not shown.");
      return;
    }

    try {
      if (!latch.await(2, TimeUnit.SECONDS)) {
        throw new TimeoutException("Wait on operation result timed out.");
      }
    } catch (InterruptedException e) {
      throw new PerformException.Builder()
        .withActionDescription(this.getDescription())
        .withViewDescription(HumanReadables.describe(view))
        .withCause(new RuntimeException("Waiting for soft keyboard close result was interrupted."))
        .build();
    }

You could use the result to check it or gain time

Request to hide the soft input window from the context of the window that is currently accepting input. This should be called as a result of the user doing some actually than fairly explicitly requests to have the input window hidden.
Parameters:
windowToken The token of the window that is making the request, as returned by View.getWindowToken().
flags Provides additional operating flags. Currently may be 0 or have the HIDE_IMPLICIT_ONLY bit set.
resultReceiver If non-null, this will be called by the IME when it has processed your request to tell you what it has done. The result code you receive may be either RESULT_UNCHANGED_SHOWN, RESULT_UNCHANGED_HIDDEN, RESULT_SHOWN, or RESULT_HIDDEN.
803 
804     public boolean More ...hideSoftInputFromWindow(IBinder windowToken, int flags,
805             ResultReceiver resultReceiver) {
806         checkFocus();
807         synchronized (mH) {
808             if (mServedView == null || mServedView.getWindowToken() != windowToken) {
809                 return false;
810             }
811 
812             try {
813                 return mService.hideSoftInput(mClient, flags, resultReceiver);
814             } catch (RemoteException e) {
815             }
816             return false;
817         }
818     }

Running tests on a KitKat device from command line

Hi,

Can these sample expresso tests be run on KitKat?
These are the errors i receive when testing on my LG phone running Kitkat.

MacBookPro:android-testing shauvik$ ./gradlew connectedCheck
:espresso:BasicSample:app:preBuild
:espresso:BasicSample:app:compileDebugNdk UP-TO-DATE
:espresso:BasicSample:app:preDebugBuild
:espresso:BasicSample:app:checkDebugManifest
:espresso:BasicSample:app:prepareDebugDependencies
:espresso:BasicSample:app:compileDebugAidl UP-TO-DATE
:espresso:BasicSample:app:compileDebugRenderscript UP-TO-DATE
:espresso:BasicSample:app:generateDebugBuildConfig UP-TO-DATE
:espresso:BasicSample:app:generateDebugAssets UP-TO-DATE
:espresso:BasicSample:app:mergeDebugAssets UP-TO-DATE
:espresso:BasicSample:app:generateDebugResValues UP-TO-DATE
:espresso:BasicSample:app:generateDebugResources UP-TO-DATE
:espresso:BasicSample:app:mergeDebugResources UP-TO-DATE
:espresso:BasicSample:app:processDebugManifest UP-TO-DATE
:espresso:BasicSample:app:processDebugResources UP-TO-DATE
:espresso:BasicSample:app:generateDebugSources UP-TO-DATE
:espresso:BasicSample:app:compileDebugJava UP-TO-DATE
:espresso:BasicSample:app:preDexDebug UP-TO-DATE
:espresso:BasicSample:app:dexDebug UP-TO-DATE
:espresso:BasicSample:app:processDebugJavaRes UP-TO-DATE
:espresso:BasicSample:app:validateDebugSigning
:espresso:BasicSample:app:packageDebug UP-TO-DATE
:espresso:BasicSample:app:zipalignDebug UP-TO-DATE
:espresso:BasicSample:app:assembleDebug UP-TO-DATE
:espresso:BasicSample:app:compileDebugTestNdk UP-TO-DATE
:espresso:BasicSample:app:preDebugTestBuild
:espresso:BasicSample:app:prepareComAndroidSupportTestEspressoEspressoCore20Library UP-TO-DATE
:espresso:BasicSample:app:prepareComAndroidSupportTestEspressoEspressoIdlingResource20Library UP-TO-DATE
:espresso:BasicSample:app:prepareComAndroidSupportTestTestingSupportLib01Library UP-TO-DATE
:espresso:BasicSample:app:prepareDebugTestDependencies
:espresso:BasicSample:app:compileDebugTestAidl UP-TO-DATE
:espresso:BasicSample:app:processDebugTestManifest UP-TO-DATE
:espresso:BasicSample:app:compileDebugTestRenderscript UP-TO-DATE
:espresso:BasicSample:app:generateDebugTestBuildConfig UP-TO-DATE
:espresso:BasicSample:app:generateDebugTestAssets UP-TO-DATE
:espresso:BasicSample:app:mergeDebugTestAssets UP-TO-DATE
:espresso:BasicSample:app:generateDebugTestResValues UP-TO-DATE
:espresso:BasicSample:app:generateDebugTestResources UP-TO-DATE
:espresso:BasicSample:app:mergeDebugTestResources UP-TO-DATE
:espresso:BasicSample:app:processDebugTestResources UP-TO-DATE
:espresso:BasicSample:app:generateDebugTestSources UP-TO-DATE
:espresso:BasicSample:app:compileDebugTestJava UP-TO-DATE
:espresso:BasicSample:app:preDexDebugTest UP-TO-DATE
:espresso:BasicSample:app:dexDebugTest UP-TO-DATE
:espresso:BasicSample:app:processDebugTestJavaRes UP-TO-DATE
:espresso:BasicSample:app:packageDebugTest UP-TO-DATE
:espresso:BasicSample:app:assembleDebugTest UP-TO-DATE
:espresso:BasicSample:app:connectedAndroidTest
Tests on LG-D855 - 4.4.2 failed: Unable to find instrumentation info for: ComponentInfo{com.example.android.testing.espresso.BasicSample.test/android.support.test.runner.AndroidJUnitRunner}

com.android.builder.testing.ConnectedDevice > hasTests[LG-D855 - 4.4.2] FAILED
No tests found.
:espresso:BasicSample:app:connectedAndroidTest FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':espresso:BasicSample:app:connectedAndroidTest'.
> There were failing tests. See the report at: file:///Users/shauvik/Projects/android-testing/espresso/BasicSample/app/build/outputs/reports/androidTests/connected/index.html

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 35.487 secs
MacBookPro:android-testing shauvik$ 

Warning:Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app and test app differ.

When Tried to include new version this error is shown, google groups said its fixed but I am still getting this error.

Warning:Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app and test app differ.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
    applicationId "com.shivam.espressotest2"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    minSdkVersion 19
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

packagingOptions {
    exclude 'LICENSE.txt'
}
}

 dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.1.1'
    compile 'com.android.support:support-annotations:22.1.0'

androidTestCompile 'com.android.support.test:runner:0.2'
androidTestCompile 'com.android.support.test:rules:0.2'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.1'

}

Test integration and Android Studio

I was just wondering if you guys are going to add Robolectric, Mockito, Espresso/Robotium, etc out of the box for Android Studio? For example, adding a testing template when first creating a project. I created a repo that does this, but it would be awesome if something like this was added to Android Studio.

Failing uiautomator.BasicSample tests on emulator

testChangeText_newActivity

java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.test.uiautomator.UiObject2.setText(java.lang.String)' on a null object reference
at com.example.android.testing.uiautomator.BasicSample.ChangeTextBehaviorTest.testChangeText_newActivity(ChangeTextBehaviorTest.java:103)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:54)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:228)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1853)

testChangeText_sameActivity

java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.test.uiautomator.UiObject2.setText(java.lang.String)' on a null object reference
at com.example.android.testing.uiautomator.BasicSample.ChangeTextBehaviorTest.testChangeText_sameActivity(ChangeTextBehaviorTest.java:88)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:54)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:228)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1853)

Repro with:

# from android-testing/ui/uiautomator/BasicSample
./gradlew connectedAndroidTest

OS: Mac OS X Yosemite, 10.10.4, 8Gb RAM, 1.7GHz Intel Core i7
AVD:
screen shot 2015-08-17 at 7 57 40 pm

/cc @JoseAlcerreca @keyboardsurfer

Could not launch intent Intent

If i include in build.gradle

androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2') {
        exclude module: 'recyclerview-v7'
    }

espresso gives me this error

java.lang.RuntimeException: Could not launch intent Intent { act=android.intent.action.MAIN flg=0x14000000 cmp=com.example.android.testing.espresso.BasicSample/.MainActivity } within 45 seconds. Perhaps the main thread has not gone idle within a reasonable amount of time? There could be an animation or something constantly repainting the screen. Or the activity is doing network calls on creation? See the threaddump logs. For your reference the last time the event queue was idle before your activity launch request was 1442838884986 and now the last time the queue went idle was: 1442838884986. If these numbers are the same your activity might be hogging the event queue.
at android.support.test.runner.MonitoringInstrumentation.startActivitySync(MonitoringInstrumentation.java:353)
at android.support.test.rule.ActivityTestRule.launchActivity(ActivityTestRule.java:219)
at android.support.test.rule.ActivityTestRule$ActivityStatement.evaluate(ActivityTestRule.java:255)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:54)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:240)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1837)

Why is this happening?

Build Failures for android-testing

I just did the git clone for the android-testing project about a half-hour ago and imported the project using Android Studio as the instructions suggest. I got a warning message complaining about VCS but no root, so I selected "Add Root". That allowed the import to complete and display files, but with some build errors, to wit:

  1. BasicSample-app: MainActivity won't build because R not found. Of course, I have seen this often enough before in both Eclipse and Android Studio, the solution in either case seems to be about the same. So I am more concerned about:

  2. espresso-BasicSample-app builds and runs, but the test does not build , complaining that it cannot find AndroidJUnit4.class. Even more surprising, in the import android.support.test.runner.AndroidJUnit4, it complains it cannot even find runner, though I do have the directory /opt/adt-bundle-mac-x86_64-20140702/sdk/extras/android/m2repository/com/android/support/test/runner (yes, I installed the bundle under Mac OSX, this was the default at the time) and I followed the instructions (long ago, actually) for downloading the Android Support Repository and Android Support Library. That said, I do have to point out that the instructions for the latter do not actually say to add the mentioned changes to the dependencies in the Gradle files, so I did not follow that part, leaving it up to the imported project to set those (hopefully correctly).

BTW: if adding those dependencies is the way to fix this, then WHICH "Gradle file" are they referring to at https://developer.android.com/tools/testing-support-library/index.html#setup when they say, " add these dependencies in your build.gradle file??

Finally, just in case it is relevant, the contents of the above runner directory contain jars for javadocs and source for runner-0.2 and runner-0.3, nothing for AndroidJUnit4.

Run individual test from Android Studio

Is there a way to run an individual test from Android Studio? With the default config in this repo for the BasicSample, I see this error:

/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/java -ea -Didea.launcher.port=7535 "-Didea.launcher.bin.path=/Applications/Android Studio.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath "/Applications/Android Studio.app/Contents/lib/idea_rt.jar:/Applications/Android Studio.app/Contents/plugins/junit/lib/junit-rt.jar:/Users/user/woven/android-sdk-macosx/platforms/android-21/android.jar:/Users/user/woven/android-sdk-macosx/platforms/android-21/data/res:/Users/user/woven/espresso_samples/espresso/BasicSample/app/build/intermediates/classes/debug:/Users/user/woven/espresso_samples/espresso/BasicSample/app/build/intermediates/exploded-aar/com.android.support.test/testing-support-lib/0.1/classes.jar:/Users/user/woven/espresso_samples/espresso/BasicSample/app/build/intermediates/exploded-aar/com.android.support.test/testing-support-lib/0.1/res:/Users/user/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.3/42a25dc3219429f0e5d060061f71acb49bf010a0/hamcrest-core-1.3.jar:/Users/user/.gradle/caches/modules-2/files-2.1/com.squareup/javawriter/2.1.1/67ff45d9ae02e583d0f9b3432a5ebbe05c30c966/javawriter-2.1.1.jar:/Users/user/.gradle/caches/modules-2/files-2.1/javax.annotation/javax.annotation-api/1.2/479c1e06db31c432330183f5cae684163f186146/javax.annotation-api-1.2.jar:/Users/user/.gradle/caches/modules-2/files-2.1/junit/junit/4.12/2973d150c0dc1fefe998f834810d68f278ea58ec/junit-4.12.jar:/Users/user/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/18.0/cce0823396aa693798f8882e64213b1772032b09/guava-18.0.jar:/Users/user/woven/espresso_samples/espresso/BasicSample/app/build/intermediates/exploded-aar/com.android.support.test.espresso/espresso-idling-resource/2.0/classes.jar:/Users/user/woven/espresso_samples/espresso/BasicSample/app/build/intermediates/exploded-aar/com.android.support.test.espresso/espresso-idling-resource/2.0/res:/Users/user/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-library/1.1/b988c01468e3398d46678a2eb48aeb5bde271e9f/hamcrest-library-1.1.jar:/Users/user/woven/espresso_samples/espresso/BasicSample/app/libs/droiddriver.jar:/Users/user/woven/espresso_samples/espresso/BasicSample/app/build/intermediates/exploded-aar/com.android.support.test.espresso/espresso-core/2.0/classes.jar:/Users/user/woven/espresso_samples/espresso/BasicSample/app/build/intermediates/exploded-aar/com.android.support.test.espresso/espresso-core/2.0/res:/Users/user/woven/android-sdk-macosx/extras/android/m2repository/com/android/support/support-annotations/21.0.3/support-annotations-21.0.3.jar:/Users/user/.gradle/caches/modules-2/files-2.1/com.google.code.findbugs/jsr305/2.0.1/516c03b21d50a644d538de0f0369c620989cd8f0/jsr305-2.0.1.jar:/Users/user/.gradle/caches/modules-2/files-2.1/javax.inject/javax.inject/1/6975da39a7040257bd51d21a231b76c915872d38/javax.inject-1.jar:/Users/user/.gradle/caches/modules-2/files-2.1/junit/junit-dep/4.10/64417b3bafdecd366afa514bd5beeae6c1f85ece/junit-dep-4.10.jar:/Users/user/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-integration/1.1/8d47177aa4da0f259fc823a39736bad2f09993d5/hamcrest-integration-1.1.jar" com.intellij.rt.execution.application.AppMain com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 com.example.android.testing.espresso.BasicSample.ChangeTextBehaviorTest
!!! JUnit version 3.8 or later expected:

java.lang.RuntimeException: Stub!
    at junit.runner.BaseTestRunner.<init>(BaseTestRunner.java:5)
    at junit.textui.TestRunner.<init>(TestRunner.java:54)
    at junit.textui.TestRunner.<init>(TestRunner.java:48)
    at junit.textui.TestRunner.<init>(TestRunner.java:41)
    at com.intellij.rt.execution.junit.JUnitStarter.junitVersionChecks(JUnitStarter.java:190)
    at com.intellij.rt.execution.junit.JUnitStarter.canWorkWithJUnitVersion(JUnitStarter.java:173)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:56)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)

I found this plugin, I'm not sure if there's a better way.

Pressing back button on a dialog fragment

in a test case when i have my dialog fragment open Espresso.pressBack() doesn't seem to do anything , i thought it was because it's a DialogFragment so maybe a different window so tried :

onView(any(View.class)).inRoot(withDecorView(not(
                is(mActivityRule.getActivity().getWindow().getDecorView()))))
                        .perform(ViewActions.pressBack());

(although i'm not sure about onView(any(View.class))) but with that i get

android.support.test.espresso.NoMatchingRootException: Matcher 'with decor view not is <com.android.internal.policy.impl.PhoneWindow$DecorView.....

I'm i missing something or is this not supported currently ?

Could an example for "How to Clear App Cache/Data" be added to the uiautomator example

Im migrating to the new uiautomator version, but my existing method for clearing cache and data is no longer working. I think its because its the Java equivalent of an adb command, which I guess, will not work with the new uiautomator since the tests are running in an apk instead of through an adb shell. But that is just my guess. If you need any more info please let me know. Here is the code i used to use:

        try {
            Process process = Runtime.getRuntime().exec("system/bin/pm clear com.my.application");
            BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
            int read;
            char[] buffer = new char[4096];
            StringBuffer output = new StringBuffer();
            while ((read = reader.read(buffer)) > 0) {
                output.append(buffer, 0, read);
            }
            reader.close();
            process.waitFor();

            return true;

        } catch (IOException e) {
            throw new RuntimeException(e);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }

BasicUnitAndroidTest not working

when you execute the BasicUnitAndroidTest project, the tests are not working,
the first reason is, that the files or under AndroidTest where they are not found by the plugin

if you rename the folder to test, files are now found but no more compiling because of missing dependencies

Ui Automator -> UiObject2.setText() fails on APK <= 19 if the current TextBox is empty

On Android APK <= 19, UiAutomator up to 2.1.0 fails with the when

UiObject2 txtField = getEditTextByAnyMeans();
txtField.setText("blah");

the reason is quite simple ( UiObject2.java:589 ):

public void setText(String text) {
    AccessibilityNodeInfo node = getAccessibilityNodeInfo();
    /* a lot of stuff */
        CharSequence currentText = node.getText();
        if (!currentText.equals(text)) {

node.getText() is returning null and that is causing the app to crash.

bellow is the stacktrace:

java.lang.NullPointerException
at android.support.test.uiautomator.UiObject2.setText(UiObject2.java:589)
at com.connvision.farmforce.tests.ApplicationTest.setFieldValue(ApplicationTest.java:150)
at com.connvision.farmforce.tests.ApplicationTest.testAddFarmer(ApplicationTest.java:129)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:24)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at org.junit.runner.JUnitCore.run(JUnitCore.java:136)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:270)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1741)

Custom runner class AndroidJUnit4 should have a public constructor with signature AndroidJUnit4(Class testClass)

Hi, I Have created the exact same test class as "CalculatorTest.java".. But when i am trying to run from Android studio, i am facing the following exception..

java.lang.Exception: Custom runner class AndroidJUnit4 should have a public constructor with signature AndroidJUnit4(Class testClass)
at org.junit.runners.model.InitializationError.(InitializationError.java:38)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:111)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.runners.model.RunnerBuilder.runners(RunnerBuilder.java:101)
at org.junit.runners.model.RunnerBuilder.runners(RunnerBuilder.java:87)
at org.junit.runners.Suite.(Suite.java:102)
at org.junit.runners.Suite.(Suite.java:70)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:107)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:41)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)

Please Help...

Looking for working example of Sharding?

I am trying to use sharding with the new AndroidJUnitRunner, using the sample in testrunner/AndroidJunitRunnerSample in this repo.

$./gradlew installDebug installDebugAndroidTest
# normal instrumentation
$ adb shell am instrument -w  com.example.android.testing.androidjunitrunnersample.test/android.support.test.runner.AndroidJUnitRunner
# sharding
$ adb shell am instrument -w -e numShards 5 -e shardIndex 1  com.example.android.testing.androidjunitrunnersample.test/android.support.test.runner.AndroidJUnitRunner

However, the number of test run in both are 69 for me... Is there something I missed?

P.S. If I use $ adb shell am instrument -w -e numShards 5 -e shardIndex 10 it still runs all 69 tests without complaining. If I use $ adb shell am instrument -w -e numShards 5 -e shardIndex A it will actually throw NumberFormatException correctly, so I am sure the parameters are correctly being processed...

BasicSample : "Please upgrade JUnit version to at least 4.6."

I'm getting this error when trying to run BasicSample:

:app:testDebug FAILED
FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:testDebug'.

    Test filtering is not supported for given version of JUnit. Please upgrade JUnit version to at least 4.6.

I am using Android Studio 1.2 Beta 3.

onWebView Element is not currently interactable and may not be manipulated

when I use espresso onWebView to click html button it will fail.

Some tests WebView components of layout xml :

PASS : android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/webView"

PASS : android:layout_width="wrap_content"
android:layout_height="10dp"
android:id="@+id/webView"

PASS : android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/webView"

FAIL : android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/webView"

FAIL : android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/webView"

FAIL : android:layout_width="100dp"
android:layout_height="wrap_content"
android:id="@+id/webView"

I found if the layout_height of WebView is " wrap_content " will run fail and got error message.

error message:
java.lang.RuntimeException: java.lang.RuntimeException: Error in evaluationEvaluation: status: 12 value: {message=Element is not currently interactable and may not be manipulated} hasMessage: true message: Element is not currently interactable and may not be manipulated
at android.support.test.espresso.web.sugar.Web$WebInteraction$ExceptionPropagator.(Web.java:323)
at android.support.test.espresso.web.sugar.Web$WebInteraction.doEval(Web.java:292)
at android.support.test.espresso.web.sugar.Web$WebInteraction.perform(Web.java:259)
at com.example.cake.cake_esp_test.WebActivityTest.enter_email_and_password_submit(WebActivityTest.java:54)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at android.support.test.internal.statement.UiThreadStatement.evaluate(UiThreadStatement.java:55)
at android.support.test.rule.ActivityTestRule$ActivityStatement.evaluate(ActivityTestRule.java:257)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:54)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:240)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1853)
Caused by: java.lang.RuntimeException: Error in evaluationEvaluation: status: 12 value: {message=Element is not currently interactable and may not be manipulated} hasMessage: true message: Element is not currently interactable and may not be manipulated
at android.support.test.espresso.web.model.SimpleAtom.handleBadEvaluation(SimpleAtom.java:142)
at android.support.test.espresso.web.model.SimpleAtom.transform(SimpleAtom.java:76)
at android.support.test.espresso.web.model.SimpleAtom.transform(SimpleAtom.java:30)
at android.support.test.espresso.web.action.AtomAction$2.apply(AtomAction.java:136)
at android.support.test.espresso.web.action.AtomAction$2.apply(AtomAction.java:133)
at android.support.test.espresso.web.deps.guava.util.concurrent.Futures$2.apply(Futures.java:760)
at android.support.test.espresso.web.deps.guava.util.concurrent.Futures$ChainingListenableFuture.run(Futures.java:906)
at android.support.test.espresso.web.deps.guava.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:457)
at android.support.test.espresso.web.deps.guava.util.concurrent.ExecutionList.executeListener(ExecutionList.java:156)
at android.support.test.espresso.web.deps.guava.util.concurrent.ExecutionList.execute(ExecutionList.java:145)
at android.support.test.espresso.web.deps.guava.util.concurrent.AbstractFuture.set(AbstractFuture.java:185)
at android.support.test.espresso.web.deps.guava.util.concurrent.SettableFuture.set(SettableFuture.java:53)
at android.support.test.espresso.web.action.AtomAction$1.run(AtomAction.java:117)
at android.support.test.espresso.web.deps.guava.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:457)
at android.support.test.espresso.web.deps.guava.util.concurrent.ExecutionList.executeListener(ExecutionList.java:156)
at android.support.test.espresso.web.deps.guava.util.concurrent.ExecutionList.execute(ExecutionList.java:145)
at android.support.test.espresso.web.deps.guava.util.concurrent.AbstractFuture.set(AbstractFuture.java:185)
at android.support.test.espresso.web.deps.guava.util.concurrent.Futures$ChainingListenableFuture$1.run(Futures.java:918)
at android.support.test.espresso.web.deps.guava.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:457)
at android.support.test.espresso.web.deps.guava.util.concurrent.Futures$ImmediateFuture.addListener(Futures.java:106)
at android.support.test.espresso.web.deps.guava.util.concurrent.Futures$ChainingListenableFuture.run(Futures.java:914)
at android.support.test.espresso.web.deps.guava.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:457)
at android.support.test.espresso.web.deps.guava.util.concurrent.ExecutionList.executeListener(ExecutionList.java:156)
at android.support.test.espresso.web.deps.guava.util.concurrent.ExecutionList.execute(ExecutionList.java:145)
at android.support.test.espresso.web.deps.guava.util.concurrent.AbstractFuture.set(AbstractFuture.java:185)
at android.support.test.espresso.web.deps.guava.util.concurrent.Futures$ChainingListenableFuture$1.run(Futures.java:918)
at android.support.test.espresso.web.deps.guava.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:457)
at android.support.test.espresso.web.deps.guava.util.concurrent.ExecutionList.executeListener(ExecutionList.java:156)
at android.support.test.espresso.web.deps.guava.util.concurrent.ExecutionList.execute(ExecutionList.java:145)
at android.support.test.espresso.web.deps.guava.util.concurrent.AbstractFuture.set(AbstractFuture.java:185)
at android.support.test.espresso.web.action.JavascriptEvaluation$ValueCallbackFuture.onReceiveValue(JavascriptEvaluation.java:429)
at com.android.org.chromium.android_webview.AwContents$5.handleJavaScriptResult(AwContents.java:1738)
at com.android.org.chromium.content.browser.webcontents.WebContentsImpl.onEvaluateJavaScriptResult(WebContentsImpl.java:227)
at com.android.org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
at com.android.org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:53)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5257)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

Test fails on Android 2.3.6 device

on target device: SHW-M110S 2.3.6
ran test_all.sh with cloned android-testing project
result was as below

ui/espresso/BasicSample :app:connectedDebugAndroidTest
ui/espresso/BasicSample Tests on SHW-M110S - 2.3.6 failed: Instrumentation run failed due to 'Process crashed.'
ui/espresso/BasicSample
ui/espresso/BasicSample com.android.builder.testing.ConnectedDevice > No tests found.[SHW-M110S - 2.3.6] FAILED
ui/espresso/BasicSample No tests found. This usually means that your test classes are not in the form that your test runner expects (e.g. don't inherit from TestCase or lack @test annotations).
ui/espresso/BasicSample :app:connectedDebugAndroidTest FAILED

any clue on this?

Espresso Intents for select multiple images Intent.EXTRA_ALLOW_MULTIPLE not working

This is first time I am using espresso intents, I followed BasicSamle provided in the android-testing project but no solved.

In my app I have a activity where user selects multiple images and then returned images are shown in the gridview, Now by using the espresso intents I want to mock this without going to actual image picker and return some specified images everytime.

No error but still opens the image chooser window when I run the test. I feel I am doing it wrong but I am not getting how it works.

I am testing using apk.

This is how photo picker is called

App code

This is how I am calling select images Intent and result is handled in onActivityResult.

if (ApiUtils.checkApiLevel(18)) {
        intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
    }
    intent.setAction(Intent.ACTION_GET_CONTENT);
    startActivityForResult(Intent.createChooser(intent,      getActivity().getString(R.string.fragment_image_selection_select_picture)), 1);

Testing Code

@RunWith(AndroidJUnit4.class)
@LargeTest
public class ImagesTests {

private static final String LAUNCHER_ACTIVITY_FULL_CLASSNAME = "com.company.recorder.RecorderActivity";
private static Class<? extends Activity> activityClass;
private ServiceValidatorIdlingResource serviceValidatorIdlingResource;

static {
    try {
        activityClass = (Class<? extends Activity>) Class.forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME);
    } catch (ClassNotFoundException e) {
        throw new RuntimeException(e);
    }
}

/**
 * Change espresso default view idling time
 * so that test can wait for long time
 */
@Before
public void registerWaitService() {
    EspressoSolo.setIdlingResourceTimeout(30);

    Instrumentation.ActivityResult result = createImageCaptureActivityResultStub();

    // Stub the Intent.
    intending(hasAction(Intent.ACTION_GET_CONTENT)).respondWith(result);

   //For API 18 and above
    intending(hasAction(Intent.EXTRA_ALLOW_MULTIPLE)).respondWith(result);

    //intending(not(isInternal())).respondWith(result);
}

private Instrumentation.ActivityResult createImageCaptureActivityResultStub() {
    // Put the drawable in a bundle.
    Bundle bundle = new Bundle();
    Uri imageUri = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" +
            InstrumentationRegistry.getTargetContext().getPackageName()+ '/' +
            InstrumentationRegistry.getTargetContext().getResources().getResourceTypeName(R.drawable.abc_ic_menu_copy_mtrl_am_alpha) + '/' +
            InstrumentationRegistry.getTargetContext().getResources().getResourceEntryName(R.drawable.abc_ic_menu_copy_mtrl_am_alpha) );

    Parcelable parcelable = (Parcelable)imageUri;

    ArrayList<Parcelable> parcels = new ArrayList<>();
    parcels.add(parcelable);

    bundle.putParcelableArrayList(Intent.EXTRA_STREAM, parcels);

    // Create the Intent that will include the bundle.
    Intent resultData = new Intent();
    resultData.putExtras(bundle);

    // Create the ActivityResult with the Intent.
    return new Instrumentation.ActivityResult(Activity.RESULT_OK, resultData);
}

@Rule
public IntentsTestRule<?> mIntentsRule = new IntentsTestRule<>(
        activityClass);


/**
 * In this test images are taken during the recording
 * add the images taken during the recording through add photos card
 * displayed after recording is stopped.
 *
 * @throws Exception
 */
@Test
public void testAddImagesFromPhotosCard() throws Exception {

    onView(withId(Recorder.getId("recorderpage_record"))).perform(click());

    Log.d("called", "other package");
    IdlingResource idlingResource0 = new RecordingWaitIdlingResource(5000);
    Espresso.registerIdlingResources(idlingResource0);

    Log.d("called", "other package");
    onView(withId(Recorder.getId("card_topText"))).perform(click());
    Espresso.unregisterIdlingResources(idlingResource0);
    onView(withId(Recorder.getId("recorderpage_stop"))).perform(click());
    //Log.d("called", "other package");
    IdlingResource idlingResource2 = new RecordingWaitIdlingResource(2000);
    Espresso.registerIdlingResources(idlingResource2);
    onView(withId(Recorder.getId("recorderpage_statustext")))
            .perform(click());
    Espresso.unregisterIdlingResources(idlingResource2);

    onView(withId(Recorder.getId("pager"))).perform(swipeLeft());

    onData(allOf()).onChildView(withId(Recorder.getId("recordsOverflow"))).
            atPosition(0).perform(click());

    IdlingResource idlingResource3 = new RecordingWaitIdlingResource(2000);
    Espresso.registerIdlingResources(idlingResource3);
    onData(allOf()).onChildView(withId(Recorder.getId("recordsOverflow"))).
            atPosition(0).perform(click());
    Espresso.unregisterIdlingResources(idlingResource3);
    onView(withText("Add an image")).perform(click());

    Instrumentation.ActivityResult result = createImageCaptureActivityResultStub();
    intending(toPackage("com.android.documentsui")).respondWith(result);

     /* I actually dont know which preinstalled app is opened by intent, I saw this com.android.documentsui, also tried with photos and gallery package names */

    intending(toPackage("com.android.documentsui.DocumentsActivity")).respondWith(result);

    intending(hasAction(Intent.ACTION_GET_CONTENT)).respondWith(result);

    //Now click on add images
    onView(withId(Recorder.getId("menu_fragment_imagewizard_selection_add"))).perform(click());

    //Just waits for 2seconds
    IdlingResource idlingResource4 = new RecordingWaitIdlingResource(2000);
    Espresso.registerIdlingResources(idlingResource4);
    onView(withText("Add images")).perform(click());
    Espresso.unregisterIdlingResources(idlingResource4);

}
}

**PS:- **
Espresson not waiting for all views to become visible, that's why I implemented my own idling resource to wait for few seconds[Which is exactly opposite to espresso], I have no idea why its happening.

WebBasicSample fails at least on 4.0.4, 5.1.1

Galaxy Nexus 4.0.4

com.example.android.testing.espresso.web.BasicSample.WebViewActivityTest > typeTextInInput_clickButton_SubmitsForm[Galaxy Nexus - 4.0.4] FAILED 
    java.lang.RuntimeException: java.lang.RuntimeException: Atom evaluation returned null!
    at android.support.test.espresso.web.sugar.Web$WebInteraction$ExceptionPropagator.<init>(Web.java:323)
:app:connectedDebugAndroidTest FAILED

OnePlusOne 5.1.1

com.example.android.testing.espresso.web.BasicSample.WebViewActivityTest > typeTextInInput_clickButton_SubmitsForm[A0001 - 5.1.1] FAILED 
    java.lang.RuntimeException: java.lang.RuntimeException: Atom evaluation returned null!
    at android.support.test.espresso.web.sugar.Web$WebInteraction$ExceptionPropagator.<init>(Web.java:323)
:app:connectedDebugAndroidTest FAILED

dependency not found: androidTestCompile 'com.android.support.test:runner:0.4'

Run this test project individually, \github\android-testing\unit\BasicUnitAndroidTest\app\build.gradle getting failure:
A problem occurred configuring project ':app'.

Could not resolve all dependencies for configuration ':app:_debugAnd
roidTestCompile'.
Could not find com.android.support.test:runner:0.4.
Searched in the following locations:
https://jcenter.bintray.com/com/android/support/test/runner/0
.4/runner-0.4.pom
https://jcenter.bintray.com/com/android/support/test/runner/0
.4/runner-0.4.jar
file:/C:/Users/Forrest/AppData/Local/Android/sdk/extras/andro
id/m2repository/com/android/support/test/runner/0.4/runner-0.4.pom
file:/C:/Users/Forrest/AppData/Local/Android/sdk/extras/andro
id/m2repository/com/android/support/test/runner/0.4/runner-0.4.jar
file:/C:/Users/Forrest/AppData/Local/Android/sdk/extras/googl
e/m2repository/com/android/support/test/runner/0.4/runner-0.4.pom
file:/C:/Users/Forrest/AppData/Local/Android/sdk/extras/googl
e/m2repository/com/android/support/test/runner/0.4/runner-0.4.jar
Required by:
BasicUnitAndroidTest:app:unspecified

After I downgraded runner to 0.3, test runs successfully. Are you sure runner of v0.4 is available?
Thanks in advance.

uiautomator-v18:2.1.2 -> UiObject2.setText() fails on APK <= 19 if the current TextBox is empty

On Android APK <= 19, UiAutomator up to 2.1.2 fails with the when
UiObject2 txtField = getEditTextByAnyMeans();
txtField.setText("blah");

the reason is quite simple ( UiObject2.java:601 ):

        CharSequence currentText = node.getText();
        if (!text.equals(currentText)) {
            ...
            if (!node.performAction(AccessibilityNodeInfo.ACTION_SET_SELECTION, args) &&
                    currentText.length() > 0) {
                // TODO: Decide if we should throw here
                Log.w(TAG, "AccessibilityNodeInfo#performAction(ACTION_SET_SELECTION) failed");
            }

node.getText() is returning null and currentText is null , and "currentText.length()" is causing the app to crash.

bellow is the stack trace:
java.lang.NullPointerException
at android.support.test.uiautomator.UiObject2.setText(UiObject2.java:601)
at com.example.LoginTestCase.testLogin(LoginTestCase.java:33)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:115)
at android.support.test.internal.runner.junit3.AndroidTestResult.runProtected(AndroidTestResult.java:77)
at junit.framework.TestResult.run(TestResult.java:118)
at android.support.test.internal.runner.junit3.AndroidTestResult.run(AndroidTestResult.java:55)
at junit.framework.TestCase.run(TestCase.java:124)
at android.support.test.internal.runner.junit3.NonLeakyTestSuite$NonLeakyTest.run(NonLeakyTestSuite.java:63)
at junit.framework.TestSuite.runTest(TestSuite.java:243)
at junit.framework.TestSuite.run(TestSuite.java:238)
at android.support.test.internal.runner.junit3.DelegatingTestSuite.run(DelegatingTestSuite.java:103)
at android.support.test.internal.runner.junit3.AndroidTestSuite.run(AndroidTestSuite.java:69)
at android.support.test.internal.runner.junit3.JUnit38ClassRunner.run(JUnit38ClassRunner.java:90)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:54)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:240)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1701)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.