Testing multiple Android phones connected to one PC - android

I am about to develop a test program for mobile phones.
To reduce cost, I want multiple Android phones to one PC, then install test program to the phones and then run the test program at once.
Can it be done? I am using Android SDK and NDK. Phones are not rooted.

Sure.
You can write a simple shell wrapper to run your tests on all connected devices simultaneously - remember their serial-numbers and use this snippet:
$ adb -s serial1 install <your_test_package>.apk
$ adb -s serial2 install <your_test_package>.apk
$ adb -s serial1 shell am instrument -w <your_test_package_name>/<runner_class>
$ adb -s serial2 shell am instrument -w <your_test_package_name>/<runner_class>
For details, consult with
http://developer.android.com/tools/help/adb.html#directingcommands
http://developer.android.com/tools/testing/testing_otheride.html#RunTestsCommand
Also, you can run your tests on any combination of physical devices, AVDs and virtualized Android-x86 installations (using KVM or VirtualBox).

Related

Android UI testing: "adb shell uiautomator" throws error, "uiautomator" in "adb shell" works

I would like to compile and run Android UI black-box tests using only command-line tools on Windows. I wrote an UiAutomatorTestCase, built it, and uploaded it into /data/local/tmp/. I verified that the jar file was copied into the latter directory.
If I type
adb shell
and then type
uiautomator runtest MyTest.jar –c com.example.MyTest
at the adb shell prompt, the test runs successfully. So far so good.
The problem is if I combine these two steps and type
adb shell uiautomator runtest MyTest.jar –c com.example.MyTest
then I get the following error:
Error: /data/local/tmp/ľc does not exist
According to the documentation, this should work. The error is the same on Windows 7 Pro 32-bit HUN and on Windows 8.1 Pro 64-bit ENG. The device is a Samsung Galaxy S3 Mini (GT-I8190), running Android 4.1.2 (API level 16).
What am I doing wrong?
I strongly suppose,
adb shell
$ <command> is same as adb shell <command>. I've never encountered any discrepancy in this regards.
Please try adb kill-server and adb start-server
Please also try adb -s <device_id> shell <command> you can find <device_id> from adb devices
Can you also please let us know what is the output of adb version?

adb and multiple device simultaneously

I am automating some test on android devices.
I am using Jenkins in order to run the tests (via jobs)
each job runs with a 95% success rate when only 1 device is connected to the machine
but when I plug 2 android devices or more, it seems adb has some trouble and I get a 5% success rate.
is it ok to run multiple instances of adb command?
here is the command I run for each job:
adb -s DEVICESERIAL shell am force-stop com.myapp.test
adb -s DEVICESERIAL shell am force-stop com.myapp
adb -s DEVICESERIAL uninstall com.myapp adb -s DEVICESERIAL uninstall com.myapp.test
adb -s DEVICESERIAL install -r com.myapp adb -s DEVICESERIAL install -r com.myapp.test
adb -s DEVICESERIAL shell am instrument -w TESTNAME/android.test.InstrumentationTestRunner
adb -s DEVICESERIAL logcat -d -v time
all command run with success but when the test starts and when I have multiple devices connected i get errors like for example:
- Unable to find instrumentation target package
- INSTRUMENTATION_STATUS_CODE: 0
- Failure [INSTALL_FAILED_INVALID_URI]
at first I thought the test apk was not installed correctly, but when trying manually after the failure, it worked fine (so the test file is installed)
again. Using 1 device only, everything is stable.
Is there something special to do in order to install and run the test on different devices simultaneously?
note that I have tried different usb ports, different cables etc...
thanks

Java Robotium Android - Run same test simultaneosly on two different devices

I want to run an Android Robotium test on two devices simultaneosly. I couldn't find any solution by now...
To be more precise, I have an application-test.apk wich contains multiple instrumentation classes. I want to run the same test apk, but different test classes on both devices. I know that I can run the tests only in serial mode, with adb.
You can use the -s flag to point an adb command to a specific device. This means that you can just open up two terminals and using the -s flag run both different commands and they will both run in parallel. It is obviously then easy to change this into a script to make it a more scaleable solution.
Example time...
You have two devices connected to your machine and two different test classes you want to run (one on each) on running:
adb devices
you see
List of devices attached
SERIALOFDEVICE1 device1
SERIALOFDEVICE2 device2
then using the serials shown you can then run a command:
adb -s SERIALOFDEVICE1 shell am instrument -w -e class com.android.foo.FooTest1 com.android.foo/android.test.InstrumentationTestRunner
adb -s SERIALOFDEVICE2 shell am instrument -w -e class com.android.foo.FooTest2 com.android.foo/android.test.InstrumentationTestRunner
where
com.android.foo.FooTest1
com.android.foo.FooTest2
Are the classes you want to run on each device.

Android application execution

I am executing an Android chat application on my Windows 7 PC (not using Eclipse). I created one emulator in AVD manager and installed that application using ADB.
I want to know how to run that application in two Android virtual devices simultaneously. Can anybody help?
type:
adb devices
you'll see for ex:
emulator-5555
emulator-5554
To install your app on each one:
adb -s emulator-5555 install yourapp.apk
adb -s emulator-5554 install yourapp.apk

How to run Android instrumentation tests from the command line (in Kubuntu)?

We are able to run instrumentation tests of Android from the command line on Windows by launching:
adb shell
am instrument -w <package.test>/android.test.InstrumentationTestRunner
This gives us good results.
Using the same architecture, we are unable to run the same in Kubuntu.
We have the same setup in Kubuntu.
Can someone let us know, if there are packages with same name.. Then what package will the adb shell point?
How will the emulator connect with adb shell from cmd line?
DO we need to do any changes to do so in Kubuntu ?
You need to explain what errors you are seeing.
If you have the same setup under Kubuntu, i.e. the Android SDK is installed, with tools like adb accessible in your path, then everything should work fine.
In response to your individual points (and these answers are the same on Windows, Mac or Linux):
It is not possible to have more than one Android package installed on a device or emulator with the same package name.
You can connect to the emulator — the same as for any device — by calling adb shell, e.g.:
adb -d shell if you have a single USB-attached device
adb -e shell if you have a single emulator running
adb -s emulator-5554 shell to specify a particular emulator (or device serial number)
You don't need to change anything between operating systems. The difference would be with setting up a device, as you need to modify udev rules on Linux, and install the USB driver on Windows

Categories

Resources