android / android-test Goto Github PK
View Code? Open in Web Editor NEWAn extensive framework for testing Android apps
Home Page: https://android.github.io/android-test
License: Apache License 2.0
An extensive framework for testing Android apps
Home Page: https://android.github.io/android-test
License: Apache License 2.0
In step 5 Android Testing Codelab, mActionsListener initialized in onActivityCreated, but in project step-1-5 I see that mActionsListener initialized in onCreate.
Using Bazel 0.11 on Ubuntu 14.04, building //tools/android/emulated_devices/generic_phone:android_24_x86_qemu2
gets stuck at creating android images...
and terminates after 5 minutes.
To get to this point, it also requires a manual patch to emulated_device.py to force -no-window
if testing with emulator v27.
Full log:
jingwen@testing-ubuntu1404:~/android-testing$ bazel build @android_test_support//tools/android/emulated_devices/generic_ph
one:android_24_x86_qemu2
.....................
INFO: Analysed target @android_test_support//tools/android/emulated_devices/generic_phone:android_24_x86_qemu2 (24 package
s loaded).
INFO: Found 1 target...
ERROR: /home/jingwen/.cache/bazel/_bazel_jingwen/ac19bcc67b1d047b3dd7d09ea2e20b5c/external/android_test_support/tools/andr
oid/emulated_devices/generic_phone/BUILD:43:1: creating android images... failed (Exit 1)
debugfs: rm /lib/hw/hwcomposer.goldfish.so
debugfs: rm /lib/hw/hwcomposer.ranchu.so
debugfs: rm /lib/hw/hwcomposer.goldfish.so
debugfs: rm /lib/hw/hwcomposer.ranchu.so
debugfs: rm /lib/hw/hwcomposer.goldfish.so
debugfs: rm /lib/hw/hwcomposer.ranchu.so
debugfs: rm /lib/hw/hwcomposer.goldfish.so
debugfs: rm /lib/hw/hwcomposer.ranchu.so
If you want to add certificates to the emulator, Please install MCrypt library using sudo apt-get install python-mcrypt .
debugfs 1.42.9 (4-Feb-2014)
rm: File not found by ext2_lookup while trying to resolve filename
rm: File not found by ext2_lookup while trying to resolve filename
8012 blocks
12149 blocks
debugfs 1.42.9 (4-Feb-2014)
rm: File not found by ext2_lookup while trying to resolve filename
rm: File not found by ext2_lookup while trying to resolve filename
8012 blocks
12149 blocks
debugfs 1.42.9 (4-Feb-2014)
rm: File not found by ext2_lookup while trying to resolve filename
rm: File not found by ext2_lookup while trying to resolve filename
8012 blocks
12149 blocks
debugfs 1.42.9 (4-Feb-2014)
rm: File not found by ext2_lookup while trying to resolve filename
rm: File not found by ext2_lookup while trying to resolve filename
8012 blocks
12149 blocks
Traceback (most recent call last):
File "/home/jingwen/.cache/bazel/_bazel_jingwen/ac19bcc67b1d047b3dd7d09ea2e20b5c/bazel-sandbox/7904738133470682564/execr
oot/__main__/bazel-out/host/bin/external/android_test_support/tools/android/emulator/unified_launcher_head.runfiles/__main
__/../android_test_support/tools/android/emulator/unified_launcher.py", line 1002, in <module>
app.run()
File "/home/jingwen/.cache/bazel/_bazel_jingwen/ac19bcc67b1d047b3dd7d09ea2e20b5c/bazel-sandbox/7904738133470682564/execr
oot/__main__/bazel-out/host/bin/external/android_test_support/tools/android/emulator/unified_launcher_head.runfiles/google
_apputils/google/apputils/app.py", line 238, in run
return _actual_start()
File "/home/jingwen/.cache/bazel/_bazel_jingwen/ac19bcc67b1d047b3dd7d09ea2e20b5c/bazel-sandbox/7904738133470682564/execr
oot/__main__/bazel-out/host/bin/external/android_test_support/tools/android/emulator/unified_launcher_head.runfiles/google
_apputils/google/apputils/app.py", line 267, in _actual_start
really_start()
File "/home/jingwen/.cache/bazel/_bazel_jingwen/ac19bcc67b1d047b3dd7d09ea2e20b5c/bazel-sandbox/7904738133470682564/execr
oot/__main__/bazel-out/host/bin/external/android_test_support/tools/android/emulator/unified_launcher_head.runfiles/google
_apputils/google/apputils/app.py", line 220, in really_start
sys.exit(main(argv))
File "/home/jingwen/.cache/bazel/_bazel_jingwen/ac19bcc67b1d047b3dd7d09ea2e20b5c/bazel-sandbox/7904738133470682564/execr
oot/__main__/bazel-out/host/bin/external/android_test_support/tools/android/emulator/unified_launcher_head.runfiles/__main
__/../android_test_support/tools/android/emulator/unified_launcher.py", line 982, in main
raise e
tools.android.emulator.emulated_device.TransientEmulatorFailure: Could not cleanly shutdown emulator
Target @android_test_support//tools/android/emulated_devices/generic_phone:android_24_x86_qemu2 failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 264.978s, Critical Path: 242.97s```
Currently targetting pie-cts-dev, aosp-master and internal master
There is text selection issue on the website.
Url https://google.github.io/android-testing-support-library/docs/espresso/basics/index.html
Issue
clicking on content select all text on the site. only way to unselect seems like doubleclick.
Using firefox 44.0 on linux mint cinnamon
Is there source code and a public build process for opensource/entry_point_deploy.jar
? If so, can it be documented somewhere in this repository?
Espresso 2.2.1, Genymotion 2.6.0
We are using the perfom(click()) method to navigate through the application by selecting certain elements on screen. Randomly the click() method will long press on an object rather than just click and in that case it will cause tests to fail. This happens more frequently when pressing items in the action bar as they have help text. So rather than clicking on a share icon in the actionbar it will long press it and show the help text, causing the test to fail.
We have also tried click(click()) as a work around, but that just causes most of the other tests to fail. If it does long press and it is successful, it will try and click again and the test will fail as the element is no longer there.
We are running are tests via Android Studio and it also happens when running through Gradle and adb.
What steps will reproduce the problem?
Outcome:
Tests will randomly fail do to long clicks when it is not expecting them.
Expected:
Remove the random long press and make the click() method consistent for tests.
Also posted this on the google page:
https://code.google.com/p/android/issues/detail?id=199544&thanks=199544&ts=1453722149
Refactor the build rules used for androidx.test to enable:
Command:
bazel build @android_test_support//tools/android/emulated_devices/pixel:google_25_x86_qemu2
Stacktrace:
I1011 18:16:44.618 emulated_device.py:650]trying to make sdcard on the fly.
I1011 18:16:44.927 emulated_device.py:271]Emulator type: 2
creating android images...; 3s linux-sandbox
18:16:45.039 emulated_device.py:1658]Executing: ['/usr/local/google/home/jingwen/.cache/bazel/_bazel_jingwen/c3fd10e8f98dec3345138bf677d22ccd/bazel-sandbox/5716239700482091081/execroot/__main__/external/androidsdk/emulator/emulator', '-ports', '23546,22441', '-skin', '540x960', '-cache', 'cache.img', '-data', 'userdata-qemu.img', '-memory', '4096', '-sdcard', 'sdcard.img', '-partition-size', '2047', '-no-snapshot-save', '-verbose', '-unix-pipe', 'sockets/qemu.mgmt', '-unix-pipe', 'sockets/device-forward-server', '-unix-pipe', 'sockets/tar-pull-server', '-unix-pipe', 'sockets/exec-server', '-unix-pipe', 'sockets/tar-push-server', '-writable-system', '-show-kernel', '-engine', 'qemu2', '-kernel', '/tmp/tmpTluMI7android-emulator-launch/images/init/kernel-ranchu', '-no-window', '-gpu', 'on', '-no-audio', '-no-boot-anim', '-selinux', 'permissive', '-fixed-scale', '-netdelay', 'none', '-netspeed', 'full', '-avd', 'mobile_ninjas.adb.22441', '-qemu', '-enable-kvm', '-L', '/tmp/tmpTluMI7android-emulator-launch/bios']
I1011 18:16:45.042 emulated_device.py:1673]Launching emulator in: /tmp/tmpTluMI7android-emulator-launch/images/session
I1011 18:16:45.043 emulated_device.py:1679]Write emulator log to /tmp/emulator_logVKuIjB.txt
I1011 18:16:45.043 emulated_device.py:2125]system: False pm: False adb: False sdcard: False boot_complete: False launcher: False pipes: False current step attempts: 0 total attempts: 0
I1011 18:16:45.043 emulated_device.py:3473]Checking if adb is listening.
I1011 18:16:45.294 emulated_device.py:2125]system: False pm: False adb: False sdcard: False boot_complete: False launcher: False pipes: False current step attempts: 1 total attempts: 1
I1011 18:16:45.295 emulated_device.py:3427]Emulator log below ==================================================
I1011 18:16:45.295 emulated_device.py:3428]Emulator log end ==================================================
I1011 18:16:45.295 emulated_device.py:3427]watchdog.out below ==================================================
If you want to add certificates to the emulator, Please install MCrypt library using sudo apt-get install python-mcrypt .
I1011 18:16:45.295 emulated_device.py:3428]watchdog.out end ==================================================
I1011 18:16:45.295 emulated_device.py:3427]watchdog.err below ==================================================
Traceback (most recent call last):
File "/usr/local/google/home/jingwen/.cache/bazel/_bazel_jingwen/c3fd10e8f98dec3345138bf677d22ccd/bazel-sandbox/5716239700482091081/execroot/__main__/bazel-out/host/bin/external/android_test_support/tools/android/emulator/unified_launcher_head.runfiles/__main__/../android_test_support/tools/android/emulator/unified_launcher.py", line 958, in <module>
app.run()
File "/usr/local/google/home/jingwen/.cache/bazel/_bazel_jingwen/c3fd10e8f98dec3345138bf677d22ccd/bazel-sandbox/5716239700482091081/execroot/__main__/bazel-out/host/bin/external/android_test_support/tools/android/emulator/unified_launcher_head.runfiles/google_apputils/google/apputils/app.py", line 238, in run
return _actual_start()
File "/usr/local/google/home/jingwen/.cache/bazel/_bazel_jingwen/c3fd10e8f98dec3345138bf677d22ccd/bazel-sandbox/5716239700482091081/execroot/__main__/bazel-out/host/bin/external/android_test_support/tools/android/emulator/unified_launcher_head.runfiles/google_apputils/google/apputils/app.py", line 267, in _actual_start
really_start()
File "/usr/local/google/home/jingwen/.cache/bazel/_bazel_jingwen/c3fd10e8f98dec3345138bf677d22ccd/bazel-sandbox/5716239700482091081/execroot/__main__/bazel-out/host/bin/external/android_test_support/tools/android/emulator/unified_launcher_head.runfiles/google_apputils/google/apputils/app.py", line 220, in really_start
sys.exit(main(argv))
File "/usr/local/google/home/jingwen/.cache/bazel/_bazel_jingwen/c3fd10e8f98dec3345138bf677d22ccd/bazel-sandbox/5716239700482091081/execroot/__main__/bazel-out/host/bin/external/android_test_support/tools/android/emulator/unified_launcher_head.runfiles/__main__/../android_test_support/tools/android/emulator/unified_launcher.py", line 941, in main
EntryPoint(reporter)
File "/usr/local/google/home/jingwen/.cache/bazel/_bazel_jingwen/c3fd10e8f98dec3345138bf677d22ccd/bazel-sandbox/5716239700482091081/execroot/__main__/bazel-out/host/bin/external/android_test_support/tools/android/emulator/unified_launcher_head.runfiles/__main__/../android_test_support/tools/android/emulator/unified_launcher.py", line 778, in EntryPoint
boot_time_apks)
File "/usr/local/google/home/jingwen/.cache/bazel/_bazel_jingwen/c3fd10e8f98dec3345138bf677d22ccd/bazel-sandbox/5716239700482091081/execroot/__main__/bazel-out/host/bin/external/android_test_support/tools/android/emulator/unified_launcher_head.runfiles/__main__/../android_test_support/tools/android/emulator/unified_launcher.py", line 311, in _FirstBootAtBuildTimeOnly
build_time_only_no_op_rendering=True)
File "/usr/local/google/home/jingwen/.cache/bazel/_bazel_jingwen/c3fd10e8f98dec3345138bf677d22ccd/bazel-sandbox/5716239700482091081/execroot/__main__/bazel-out/host/bin/external/android_test_support/tools/android/emulator/unified_launcher_head.runfiles/android_test_support/tools/android/emulator/emulated_device.py", line 1167, in StartDevice
with_audio, with_boot_anim)
File "/usr/local/google/home/jingwen/.cache/bazel/_bazel_jingwen/c3fd10e8f98dec3345138bf677d22ccd/bazel-sandbox/5716239700482091081/execroot/__main__/bazel-out/host/bin/external/android_test_support/tools/android/emulator/unified_launcher_head.runfiles/android_test_support/tools/android/emulator/emulated_device.py", line 1686, in _StartEmulator
pipe_dir)
File "/usr/local/google/home/jingwen/.cache/bazel/_bazel_jingwen/c3fd10e8f98dec3345138bf677d22ccd/bazel-sandbox/5716239700482091081/execroot/__main__/bazel-out/host/bin/external/android_test_support/tools/android/emulator/unified_launcher_head.runfiles/android_test_support/tools/android/emulator/emulated_device.py", line 1754, in _ForkWatchdog
pipe_dir)
File "/usr/local/google/home/jingwen/.cache/bazel/_bazel_jingwen/c3fd10e8f98dec3345138bf677d22ccd/bazel-sandbox/5716239700482091081/execroot/__main__/bazel-out/host/bin/external/android_test_support/tools/android/emulator/unified_launcher_head.runfiles/android_test_support/tools/android/emulator/emulated_device.py", line 1778, in _WatchdogLoop
pipe_service_processes = self._StartPipeServices(pipe_dir)
File "/usr/local/google/home/jingwen/.cache/bazel/_bazel_jingwen/c3fd10e8f98dec3345138bf677d22ccd/bazel-sandbox/5716239700482091081/execroot/__main__/bazel-out/host/bin/external/android_test_support/tools/android/emulator/unified_launcher_head.runfiles/android_test_support/tools/android/emulator/emulated_device.py", line 1931, in _StartPipeServices
close_fds=True))
File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 8] Exec format error
I1011 18:16:45.295 emulated_device.py:3428]watchdog.err end ==================================================
Traceback (most recent call last):
File "/usr/local/google/home/jingwen/.cache/bazel/_bazel_jingwen/c3fd10e8f98dec3345138bf677d22ccd/bazel-sandbox/5716239700482091081/execroot/__main__/bazel-out/host/bin/external/android_test_support/tools/android/emulator/unified_launcher_head.runfiles/__main__/../android_test_support/tools/android/emulator/unified_launcher.py", line 958, in <module>
app.run()
File "/usr/local/google/home/jingwen/.cache/bazel/_bazel_jingwen/c3fd10e8f98dec3345138bf677d22ccd/bazel-sandbox/5716239700482091081/execroot/__main__/bazel-out/host/bin/external/android_test_support/tools/android/emulator/unified_launcher_head.runfiles/google_apputils/google/apputils/app.py", line 238, in run
return _actual_start()
File "/usr/local/google/home/jingwen/.cache/bazel/_bazel_jingwen/c3fd10e8f98dec3345138bf677d22ccd/bazel-sandbox/5716239700482091081/execroot/__main__/bazel-out/host/bin/external/android_test_support/tools/android/emulator/unified_launcher_head.runfiles/google_apputils/google/apputils/app.py", line 267, in _actual_start
really_start()
File "/usr/local/google/home/jingwen/.cache/bazel/_bazel_jingwen/c3fd10e8f98dec3345138bf677d22ccd/bazel-sandbox/5716239700482091081/execroot/__main__/bazel-out/host/bin/external/android_test_support/tools/android/emulator/unified_launcher_head.runfiles/google_apputils/google/apputils/app.py", line 220, in really_start
sys.exit(main(argv))
File "/usr/local/google/home/jingwen/.cache/bazel/_bazel_jingwen/c3fd10e8f98dec3345138bf677d22ccd/bazel-sandbox/5716239700482091081/execroot/__main__/bazel-out/host/bin/external/android_test_support/tools/android/emulator/unified_launcher_head.runfiles/__main__/../android_test_support/tools/android/emulator/unified_launcher.py", line 941, in main
EntryPoint(reporter)
creating android images...; 3s linux-sandbox
File "/usr/local/google/home/jingwen/.cache/bazel/_bazel_jingwen/c3fd10e8f98dec3345138bf677d22ccd/bazel-sandbox/5716239700482091081/execroot/__main__/bazel-out/host/bin/external/android_test_support/tools/android/emulator/unified_launcher_head.runfiles/__main__/../android_test_support/tools/android/emulator/unified_launcher.py", line 778, in EntryPoint
boot_time_apks)
File "/usr/local/google/home/jingwen/.cache/bazel/_bazel_jingwen/c3fd10e8f98dec3345138bf677d22ccd/bazel-sandbox/5716239700482091081/execroot/__main__/bazel-out/host/bin/external/android_test_support/tools/android/emulator/unified_launcher_head.runfiles/__main__/../android_test_support/tools/android/emulator/unified_launcher.py", line 311, in _FirstBootAtBuildTimeOnly
build_time_only_no_op_rendering=True)
File "/usr/local/google/home/jingwen/.cache/bazel/_bazel_jingwen/c3fd10e8f98dec3345138bf677d22ccd/bazel-sandbox/5716239700482091081/execroot/__main__/bazel-out/host/bin/external/android_test_support/tools/android/emulator/unified_launcher_head.runfiles/android_test_support/tools/android/emulator/emulated_device.py", line 1167, in StartDevice
with_audio, with_boot_anim)
File "/usr/local/google/home/jingwen/.cache/bazel/_bazel_jingwen/c3fd10e8f98dec3345138bf677d22ccd/bazel-sandbox/5716239700482091081/execroot/__main__/bazel-out/host/bin/external/android_test_support/tools/android/emulator/unified_launcher_head.runfiles/android_test_support/tools/android/emulator/emulated_device.py", line 1690, in _StartEmulator
self._PollEmulatorStatus(timer)
File "/usr/local/google/home/jingwen/.cache/bazel/_bazel_jingwen/c3fd10e8f98dec3345138bf677d22ccd/bazel-sandbox/5716239700482091081/execroot/__main__/bazel-out/host/bin/external/android_test_support/tools/android/emulator/unified_launcher_head.runfiles/android_test_support/tools/android/emulator/emulated_device.py", line 2126, in _PollEmulatorStatus
self._EnsureEmuRunning()
File "/usr/local/google/home/jingwen/.cache/bazel/_bazel_jingwen/c3fd10e8f98dec3345138bf677d22ccd/bazel-sandbox/5716239700482091081/execroot/__main__/bazel-out/host/bin/external/android_test_support/tools/android/emulator/unified_launcher_head.runfiles/android_test_support/tools/android/emulator/emulated_device.py", line 3447, in _EnsureEmuRunning
raise Exception('Emulator has died')
Exception: Emulator has died
creating android images...; 3s linux-sandbox
Target @android_test_support//tools/android/emulated_devices/pixel:google_25_x86_qemu2 failed to build
no action running
Use --verbose_failures to see the command lines of failed build steps.
no action running
Elapsed time: 53.406s, Critical Path: 26.41s
no action running
FAILED: Build did NOT complete successfully
When trying to match a row using withRowString and the list view has a header view, cursor matcher fails:
java.lang.IllegalArgumentException: Column index is invalid at android.support.test.espresso.matcher.CursorMatchers$CursorMatcher.matchesSafely(CursorMatchers.java:116) at android.support.test.espresso.matcher.CursorMatchers$CursorMatcher.matchesSafely(CursorMatchers.java:61) at android.support.test.espresso.matcher.BoundedMatcher.matches(BoundedMatcher.java:73) at org.hamcrest.core.AllOf.matches(AllOf.java:27) at org.hamcrest.DiagnosingMatcher.matches(DiagnosingMatcher.java:12) at android.support.test.espresso.action.AdapterDataLoaderAction.perform(AdapterDataLoaderAction.java:83) at android.support.test.espresso.ViewInteraction$1.run(ViewInteraction.java:144) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at android.os.Handler.handleCallback(Handler.java:746) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5443) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) Caused by: android.database.CursorIndexOutOfBoundsException: Index 5 requested, with a size of 5 at android.database.AbstractCursor.checkPosition(AbstractCursor.java:460) at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:136) at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:50) at android.support.test.espresso.matcher.CursorMatchers$7.apply(CursorMatchers.java:245) at android.support.test.espresso.matcher.CursorMatchers$CursorMatcher.matchesSafely(CursorMatchers.java:113) ... 15 more
This is probably because adding a header view to a list view causes the list view to increase element count in the underlying adapter.
From HeaderViewListAdapter
public int getCount() {
if (mAdapter != null) {
return getFootersCount() + getHeadersCount() + mAdapter.getCount();
} else {
return getFootersCount() + getHeadersCount();
}
}
local junit test
I am using FragmentScenario to test my fragment, and I want grant the permission first.
I have tried to use robolectric's ShadowApplications and GrantPermissionRule, and both of them are not working.
1st case: Robolectric grant success, but in fragment side, it returns DENIED (not scenario.onFragment {}), confused :(
2st case: GrantPermissionRule broken at NullPointerException(checkNotNull(UiAutomation))
java.lang.NullPointerException
at androidx.test.internal.util.Checks.checkNotNull(Checks.java:34)
at androidx.test.runner.permission.UiAutomationShellCommand.(UiAutomationShellCommand.java:65)
at androidx.test.runner.permission.PermissionRequester.addPermissions(PermissionRequester.java:91)
at androidx.test.rule.GrantPermissionRule.grantPermissions(GrantPermissionRule.java:95)
at androidx.test.rule.GrantPermissionRule.grant(GrantPermissionRule.java:89)
at com.aeye.ui.fragments.bindDevice.BindDeviceFragmentTest.(BindDeviceFragmentTest.kt:24)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:217)
at org.robolectric.RobolectricTestRunner$HelperTestRunner.createTest(RobolectricTestRunner.java:584)
at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:266)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:263)
at org.robolectric.internal.SandboxTestRunner$HelperTestRunner.methodBlock(SandboxTestRunner.java:319)
at org.robolectric.internal.SandboxTestRunner$2.evaluate(SandboxTestRunner.java:256)
at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:130)
at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:42)
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.robolectric.internal.SandboxTestRunner$1.evaluate(SandboxTestRunner.java:84)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at androidx.test.ext.junit.runners.AndroidJUnit4.run(AndroidJUnit4.java:104)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
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:498)
at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131)
Test is execurted regardless @RequiresDevice
annotation is set.
Specific instrumentation runner is set to android.support.test.runner.AndroidJUnitRunner
, line testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
is added to build.gradle
as well.
Test class:
@RequiresDevice
public class OnBoardingTest {
@Rule
public ActivityTestRule<OnbordingActivity> activityRule
= new ActivityTestRule<>(OnbordingActivity.class);
@Before
public void setUp() {
Intents.init();
}
@After
public void tearDown() {
Intents.release();
}
@Test
@RequiresDevice
public void testGetStarted() {
onView(withId(R.id.onboarding_button)).perform(click());
intended(hasComponent(CreateAccountActivity.class.getName()));
}
}
Have scoured the google.github.com site and can't find a link for the javadoc. There's references in the Release notes but no link on the ATSL site.
This might not be a bug - (but I didn't see it documented anywhere) Is finish()
/onDestroy()
guaranteed to be called on every Activity started by ActivityTestRule, specifically in order? I'm seeing cases where onDestroy()
is called, but the activity that's returning isn't being finished via isFinishing()
.
Some logs that show my findings: (@Before
and @After
are junit before/after methods)
D/OrderOfOp: @Before
D/OrderOfOp: @After
D/OrderOfOp: onPause()
D/OrderOfOp: @Before
D/OrderOfOp: onDestroy()
D/OrderOfOp: onDestroy() --> isFinishing()
D/OrderOfOp: @After
D/OrderOfOp: onPause()
D/OrderOfOp: @Before
D/OrderOfOp: @After
D/OrderOfOp: onPause()
D/OrderOfOp: @Before
D/OrderOfOp: onDestroy()
D/OrderOfOp: onDestroy() --> isFinishing()
D/OrderOfOp: onPause()
D/OrderOfOp: onDestroy()
D/OrderOfOp: onDestroy() --> isFinishing()
(for reference, this is the onDestroy() method):
@Override
protected void onDestroy() {
super.onDestroy();
Log.d("OrderOfOp", "onDestroy()");
if (isFinishing()) {
Log.d("OrderOfOp", "onDestroy() --> isFinishing()");
}
}
Hi,
We have a flaky tests suite for a specific activity due to the following error:
"Overslept and turned a tap into a long press"
I have to mention that this activity has multiple fragments and by clicking on the bottom tab bar we navigate between the fragments.
sometimes clicking on one of the bar items becomes along click and the test fails.
any plans to fix it soon?
any suggestions besides rollback action?
Thanks,
Tali
If we run more Test with same ServiceTestRule object, the bindAndWait function it will test the status of public static CountDownLatch mConnectedLatch = new CountDownLatch(1);
that is initialized only on first run of ServiceTestRule.
So the first run, the bindAndWait waits correctly the connection establishment, the next runs, will not, because the latch is 0.
Makes the property not static seems it solve the bug.
Sometimes it is convenient for Espresso Recorder to help create tests, especially when working with NestedScrollViews / Coordinator Layout / RecyclerViews, or if it is a new person onboarding onto the automation suite.
Right now, Espresso Recorder can indefinitely hang for unknown reasons when launching my application. Regardless, it would be useful to attach the espresso recorder while I already have the application launched and device/emulator using the debugger. That way I can choose which screen to have it record if I want a snippet of functionality on that activity/fragment.
After upgrade ASTL to 1.0 i see
android.support.test.espresso.remote.NoRemoteEspressoInstanceException: No remote instances available
pretty often, but only in Firebase Test Lab runs, never saw it locally.
Tests runs on CI via gcloud, with orchestrator disabled (default for now)
In the index document, under JUnit 4 Rules, the Android JUnit Runner link is broken. Going to correct it by a PR.
Broken: https://google.github.io/android-testing-support-library/atsl/androidjunitrunner-guide/index.html
Should be: https://google.github.io/android-testing-support-library/docs/androidjunitrunner-guide/index.html
It will be cool to have included which things should be retained by proguard to run tests of your proguarded apps.
Store the output of the Google Cloud Build CI axt_m2respository target in Google Cloud Storage, so it be could be used as release artifact
In some case, a background operation finish activity after completion, which view action & check is not fit.
Maybe IdlingResource should waiting for all assert will work fine.
when run through android studio the test compile and run. but for the build server I have to run grade task: connectedAndroidTest and after compiling I get:
Tests on SAMSUNG-SGH-I317 - 4.4.2 failed: Instrumentation run failed due to 'java.lang.IllegalAccessError'
com.android.builder.testing.ConnectedDevice > No tests found.[SAMSUNG-SGH-I317 - 4.4.2] �[31mFAILED �[0
I have tried to exclude
exclude group: 'javax.inject'
but there must be other conflicts.
Are there any plans to add support for the uix format in Espresso? It'd be nice to have a visual inspection tool. The current human readable ASCII diagram doesn't work well on large apps.
Please add instructions on how one would start contributing to ATSL
Write a on device test(Espresso), use ActivityScenarioRule, and move to resumed state, then test the swipeUp() view action, activity stuck.....
But when I change the rule to ActivityTestRule, swipeUp() works fine.
What's going on?
As requested in bazelbuild/bazel#4679, it will be great to have macOS support for unified launcher, and therefore android_device
building on the Mac.
We'd like to see a counterpart to minSdkVersion value of @SdkSuppress annotation to only run a test on API levels lower than some target.
It would be very useful to have public method to change hardcoded interval for Idling Resources isIdle() checks (5 sec).
Often there is a need to use Idling Resource for a short ~ 1-2 sec waits. So no need to wait additional few seconds (per each test).
Some of the legacy APIs (like androidx.test.filters.SmallTest) do not cleanly map to their maven artifact name (which in this case is androidx.test:runner)
Doclava has support for emitting Maven coordinates into the class documentation, via the -artifact args.
Add this support to androidx.test reference doc generation.
Minor documentation bug (and if there's a better way to file these types of issue, please let me know).
Last line of the first paragraphs reads "If you are not familiar with hamcrest matchers, we suggest you start with a quick look at this presentation.".
Expected: a link or embedded object for "this presentation".
Actual: no link or embedded object is provided for "this presentation", leading to confusion and sadness.
From ActivityTestRule to ActivityScenario
From InstrumentationRegistry to ApplicationProvider
RuntimeEnvironment.application
to ApplicationProvider
etc
As referenced in my original AndroidX Discuss Post and my Stack Overflow post and this new stack overflow post about FragmentScenario, there seems to be a limitation of the ActivityScenario API when using ActivityScenario.launch()
method because it only waits for two possible Lifecycle.State
s RESUMED
and DESTROYED
.
Claim:
There is a limitation within the launch(Intent startActivityIntent)
method of the ActivityScenario API. It waits for the Activity to be Lifecycle.STATE.RESUMED
or DESTROYED
and if it isn't within 4.5 seconds then it throws this error.
Context:
My application uses an IndexActivity
to load a config which instructs the application on certain API calls to make. However, immediately after it loads a DialogActivity
and the IndexActivity
goes into STOPPED
. On accepting terms within the DialogActivity
the IndexActivity
goes back into RESUMED
and then ActivityScenario works properly. With my tests, there was a race condition on whether Espresso could click through the terms within 4.5 seconds to get the IndexActivity
to be RESUMED
or whether this error would throw before that. It would take major refactoring to enable another Activity to be launched with ActivityScenario so that was not an option.
The Fix
Within public static <A extends Activity> ActivityScenario<A> launch(Intent startActivityIntent)
of Activity Scenario, check the logic scenario.waitForActivityToBecomeAnyOf(State.RESUMED, State.DESTROYED);
If you can create your own custom Activity Scenario and adjust this line of code to be something like scenario.waitForActivityToBecomeAnyOf(State.STOPPED, State.DESTROYED);
then it will theoretically work for you. You can then use ActivityScenario again to move the Activity into whatever Lifecycle State you want.
OR just use the old https://developer.android.com/reference/androidx/test/rule/ActivityTestRule
TL;DR
This is happening because the Lifecycle.State of your Activity is not either of the two specific lifecycle states ActivityScenario.Launch()
waits for, RESUMED
or DESTROYED
. Your activity is probably in the background of a dialog or another edge-case situation that was not thought about when creating the API.
Full StackTrace for Test here:
10:54:42 V/InstrumentationResultParser: java.lang.AssertionError: Activity never becomes requested state "[RESUMED]" (last lifecycle transition = "STOPPED")
10:54:42 V/InstrumentationResultParser: at androidx.test.core.app.ActivityScenario.waitForActivityToBecomeAnyOf(ActivityScenario.java:228)
10:54:42 V/InstrumentationResultParser: at androidx.test.core.app.ActivityScenario.moveToState(ActivityScenario.java:368)
10:54:42 V/InstrumentationResultParser: at com.myapplication.android.test.HomeTest.launchActivity(HomeTest.java:30)
10:54:42 V/InstrumentationResultParser: at java.lang.reflect.Method.invoke(Native Method)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
10:54:42 V/InstrumentationResultParser: at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
10:54:42 V/InstrumentationResultParser: at androidx.test.internal.runner.junit4.statement.RunBefores.evaluate(RunBefores.java:76)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
10:54:42 V/InstrumentationResultParser: at androidx.test.ext.junit.runners.AndroidJUnit4.run(AndroidJUnit4.java:104)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.Suite.runChild(Suite.java:128)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.Suite.runChild(Suite.java:27)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
10:54:42 V/InstrumentationResultParser: at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
10:54:42 V/InstrumentationResultParser: at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
10:54:42 V/InstrumentationResultParser: at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:56)
10:54:42 V/InstrumentationResultParser: at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:388)
10:54:42 V/InstrumentationResultParser: at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2075)
RESUMED
state, due to pop-up modal or dialogIt seems this is not a bug but is rather a restriction of the API
But, the expected behavior would be to either allow STOPPED
to be waited for within the launch() method, or to allow the user to specify which states they want to wait for.
ActivityScenario wants your activity to be either RESUMED
or DESTROYED
, and if it isn't after 45000 milliseconds then it throws the error above.
android {
defaultConfig {
// Specifies instrumentation which connects the test package and the application package
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
// The package name of the test app
testApplicationId 'com.myapplication.android.test'
// The following argument makes the Android Test Orchestrator run its
// "pm clear" command after each test invocation. This command ensures
// that the app's state is completely cleared between tests.
testInstrumentationRunnerArguments clearPackageData: 'true'
}
testOptions {
animationsDisabled = true
execution 'ANDROIDX_TEST_ORCHESTRATOR'
}
useLibrary 'android.test.runner'
useLibrary 'android.test.base'
useLibrary 'android.test.mock'
}
dependencies {
// Core library
androidTestImplementation 'androidx.test:core:1.0.0'
// AndroidJUnitRunner and JUnit Rules
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test:rules:1.1.0'
androidTestUtil 'androidx.test:orchestrator:1.1.0'
// Assertions
androidTestImplementation 'androidx.test.ext:junit:1.0.0'
androidTestImplementation 'androidx.test.ext:truth:1.0.0'
androidTestImplementation 'com.google.truth:truth:0.42'
// Espresso dependencies
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-accessibility:3.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-web:3.1.0'
androidTestImplementation 'androidx.test.espresso.idling:idling-concurrent:3.1.0'
// The following Espresso dependency can be either "implementation"
// or "androidTestImplementation", depending on whether you want the
// dependency to appear on your APK's compile classpath or the test APK
// classpath.
androidTestImplementation 'androidx.test.espresso:espresso-idling-resource:3.1.0'
}
None right now.
Hi all.
Where can I get the source code for Android Testing Support Library?
I tried the instructions here: https://android.github.io/android-test/contribute/, but the code I got seemed too old.
Is it not open-sourced any more?
Link to AXT documentation page is dead
Currently, it's not user friendly to discover android_device
targets in //tools/android/emulated_devices
. The easiest way to do this now is via a bazel query
for all implicit outputs.
It will be great to have a device(avd, api_kind, api_level)
macro that translates into the corresponding //tools/android/emulated_devices/$(avd):$(api_kind)_$(api_level)_x86_qemu2
target name.
My tests are done and now I just want to lunch manually the app, I get Waiting for debugger . I force close it then the app shutdown completely.
I've used for all my test Record Espresso Tests feature under Run menu [Android Studio 2.2]
To fix this issue, I have to go in Developer menu then select "my App" then again "Nothing" under Selector debug app.
After that Waiting to debugger is no longer displayed. This is fine until I use again Record Espresso Tests feature.
Do you guys have any suggestions how to fix this issue in a different way?
Thanks!
See googlearchive/android-audio-high-performance#10 for full details
I hit an issue while I tried to use intended() to verify the intent that is been sent by my app.
In Espresso test, after I perform click in my app to launch other external activity with an intent (assuming I am trying to launch HTML Viewer to view a text file from my app), then Espresso works good while I use intended() method to verify the intent that I passed while launching the external activity. However, the problem is that after I called intended(), the app focus will not get back to my app and I will not be able to continue my next test method if they are in the same class. Is there any way I can work around it?
Bug file here, but this seems like the more appropriate place for it:
https://code.google.com/p/android/issues/detail?id=187249
There is a typo on the Layout Assertion "noEllipsizedText()" under the View Assertions header of the Espresso Cheat Sheet version 2.1
Currently this appears on the cheat sheet as "noEllipseizedText(Matcher)"
The trouble for me was I learned about this Layout Assertion from the cheat sheet. So when it wasn't working with my code, performing a Google search for its name returned nothing useful as it was all websites that have reposted this same information with the same error. The correct citation on the cheat sheet should read "noEllipsizedText()" removing the word "matcher" from between the parentheses and removing the 'e' between 's' and 'i' in the method name.
In pictures: this is how it appears on the cheat sheet
And this is how it's actually implemented
Lastly, here's my correction of the cheat sheet using primitive image copy/paste. I don't have the tools to do this correctly, but feel bad for not trying. I didn't change the version number either.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.