Issue
I have created a simple ui test for an android application following this tutorial:
http://developer.android.com/tools/testing/testing_ui.html
Now I have build my project and uploaded the TestProject.jar file into a virtual device using:
adb push <path_to_output_jar>/TestProject.jar /data/local/tmp/
but when I run the command to run my test
adb shell uiautomator runtest TestProject.jar -c com.uia.example.my.Test
I get this error
Error: /data/local/tmp/TestProject.jar does not exist
Why? The jar is uploaded to virtual device. Am I missing something here?
Also, using a real device I cannot even upload it:
uiautomator: permission denied
Solution
Can you confirm whether the adb push actually transfers the file correctly? There are a couple of ways to check this:
- Check the output of the
adb pushcommand e.g.adb push bin/UIAutomatorExample.jar /data/local/tmp/In my case the output is1011 KB/s (5854 bytes in 0.005s)(the evidence is the number of bytes transferred. Here we know something was sucessfully transferred somewhere). - Use
adb shellto check the file is available in the expected location:adb shell ls -l /data/local/tmp/*.jarHere is the output for my example-rw-rw-rw- shell shell 5854 2013-04-11 01:36 UIAutomatorExample.jarNote: the file size in bytes matched the figure from the first command output, 5854 bytes.
Once we know the jar file has been successfully deployed to the correct location the run command should work, provided the target device is running version 16 or later of Android APIs. (although in practice 17 is the first version of Android where UIAutomator seems to work reliably.)
adb shell uiautomator runtest LaunchSettings.jar -c com.uia.example.my.LaunchSettings
Of course you need to replace LaunchSettings.jar with TestProject.jar :)
Answered By - JulianHarty
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.