Robotium : Run Test Scripts Directly From Mobile Device , Way To Run Shell scripts On Mobile Device

robotium

 

People using Robotium to automate android application testing must be running scripts on an Emulator or On a device using Eclipse or ADT.
But some scenarios demand to be able to run scripts on the device independently where purpose may be Convenience or some issues regarding the use of the AUT.

Steps:

1. Install the AUT (Application under test) using adb command.
Connect the Mobile using data cable and install necessary drivers.
Check if device is connected or not by using command “adb devices”,This will display all the devices connected.

Now to install AUT use adb install command.
e.g  adb install application_name.apk
Ensure application installation is a success.

 2. Generate the test project apk file.

Compile the Robotium/ Android Test Project using Eclipse , so that it can generate the APK file of the Test project. Install the apk of the test project to the device in the same way AUT is installed.

3.  Install Script Manager App :

To get shell access and to be able to run shell scripts on the Android Device , We need to install Any of the Script Manager or Shell Emulator Apps available on Google Play.

I went for Script Manager(SManager) as it comes with some useful widgets. Click Here to navigate to  the Google Play page of the application I have mentioned.

4. Create Shell scripts for android having .sh extensions the usual way we do for Linux.

Inside that file Just put the shell scripts

e.g am instrument -w -e reportDir sdcard com.hellodemo.test.test.test/com.zutubi.android.junitreport.JUnitReportTestRunner 

Now store that .sh file in Mobile Device (SDCARD/INTERNAL MEMORY).

5. Run the tests from mobile itself.

Now open the application SManager in the android device and navigate to the directory you have stored the .sh or script files. Click on that .sh file and from the options available there click on Run.

Now the test scripts must be running .

Separate .sh files can be used to run scripts those are restricted to run some specific annotated test cases.

6. Creating Shortcuts using Smanager widgets to run scripts on one touch.

Smanager comes with widgets that can be found from widgets area of android and we can add widgets to home screen by specifying which .sh file to execute, which is a convenience.

Please Note: Test script can also be run from Developer Tools from the Instrumentation option , But we it will run the whole Test Script where we desired to run some of them only by specifying annotations.