Definitions, Critical Reminders, Install Instructions, Test Development, What's New
Overlay | Overwrite an existing install with upgraded assets (Libraries, Scripts, Source, etc). |
SAFS | Software Automation Framework Support |
Device | The actual Android device to be used for testing. An Emulator is also considered a device. |
On-Device | Code or applications on the device targetted for testing. |
AUT | App Under Test--the on-device target APK to be tested. |
Messenger | The on-device SAFS TCP Messenger APK for Android testing. |
RobotiumTestRunner | The on-device RobotiumTestRunner APK for Robotium Remote Control Android testing. |
SAFSTestRunner | The on-device SAFSTestRunner APK for SAFS Robotium Remote Control Android testing with SAFS extensions. |
Controller | The computer used to remotely control the test on the device. For simplicity, the test development machine and the Controller are assumed to be the same. |
The Test | The AUT-specific Java test code developed for execution on the remote Controller. |
It is assumed all RobotiumRC installation requirements have been met. If that is not the case, then you should perform a full Release install and not an Overlay. You can apply an Overlay after installing a Release.
NOTE:
To test on a real device, you must verify/prepare any required connections and/or drivers for your device. Refer to the Android Developers documentation for details.
Windows: Overlay-Win.bat %ANDROID_HOME% or <path-to-android-sdk> Unix: Overlay-Unx.sh $ANDROID_HOME or <path-to-android-sdk> Mac: Overlay-Mac.sh $ANDROID_HOME or <path-to-android-sdk>
On Mac, and possibly some incantations of Unix, the user may be required to use sudo as follows:
sudo ./Overlay-Mac.sh $ANDROID_HOME
or
sudo ./Overlay-Unx.sh $ANDROID_HOME
If the script does not run at all:
This step can be skipped if the Messenger was built automatically during the Overlay.
This build is required only once with your specific developer debug profile/certificate following an Overlay.
(Use <path-to\SAFSTestRunner\libs> if you intend to use the SAFSTestRunner instead.
This line simply insures the safstcpmessenger.jar is up-to-date for the target TestRunner.)
On Windows:
If you receive a BUILD FAILED message along with "Could not create task or type of type: componentdef.":
Then try the 'ant debug' command again in that same CMD window.
This step can be skipped if the TestRunner was built automatically during the Overlay.
This build is required only once per AUT with your specific developer debug profile/certificate after an Overlay.
(As an advanced feature, the framework can rebuild the RobotiumTestRunner at runtime to match the targetPackage of whatever AUT is specified for testing.)
On Windows:
If you receive a BUILD FAILED message along with "Could not create task or type of type: componentdef.":
Then try the 'ant debug' command again in that same CMD window.
This step can be skipped if the TestRunner was automatically built during the Overlay.
This build is required once per AUT with your specific developer debug profile/certificate after an Overlay.
(As an advanced feature, the framework can rebuild the SAFSTestRunner at runtime to match the targetPackage of whatever AUT is specified for testing.)
On Windows:
If you receive a BUILD FAILED message along with "Could not create task or type of type: componentdef.":
Then try the 'ant debug' command again in that same CMD window.
This step can be skipped if the SampleSpinner app was automatically re-signed during the Overlay.
This step may be required for each subsequent AUT build if it was not already signed with your specific developer debug profile/certificate.
java -jar <path\to\re-sign.jar> <path\to\SpinnerActivity.apk> <out\to\SpinnerActivity-debug.apk>
As a reminder, re-signing the AUT can be done automatically at runtime by properly specifying the resignjar command-line parameter available to SoloTest subclasses. Learn more about that in the section below.
You can use the SoloRemoteControl project installed with Robotium RemoteControl as a reference for your own Java development project.
The SoloRemoteControl/src directory contains all the sourcecode contained in the safs-remotecontrol.jar.
safs-remotecontrol.jar (robotium-remotecontrol.jar is no longer used.) robotium-serializable.jar ->(only needed if using new/custom serialized classes) safsautoandroid.jar safssockets.jar re-sign.jar (is also present, but is not normally part of a development project) The following can be found at <path-to-android-sdk>/tools/lib ddmlib.jar
The SAFS SoloTest version allows the user to take advantage of the SAFSTestRunner instead of the RobotiumTestRunner. The SAFS TestRunner provides access to SAFS Driver Commands and SAFS EngineCommands and other exposed SAFS functionality without requiring the full install and capability of the complete SAFS Automation Framework.
The source for both of these SoloTest classes can be found in the appropriate SoloRemoteControl/src subfolders.
You can find a copy of the example MyTest code below in the SoloRemoteControl/src folder at:
This example uses the smaller Robotium SoloTest class and the RobotiumTestRunner instead of the enhanced SAFS SoloTest class using the SAFSTestRunner option, but the concepts are the same for both.
Your MyTest class will need to minimally import a few classes:
import java.util.Properties; import com.jayway.android.robotium.remotecontrol.solo.Message; import com.jayway.android.robotium.remotecontrol.solo.SoloTest; import com.jayway.android.robotium.remotecontrol.solo.Solo; public class MyTest extends SoloTest{ }
public MyTest(){ super(); } public MyTest(String[] args){ super(args); } public MyTest(String messengerApk, String testRunnerApk, String instrumentArg){ super(messengerApk, testRunnerApk, instrumentArg); }
public static void main(String[] args){ SoloTest soloTest = new MyTest(args); soloTest.process(); }
protected void test(){ try{ String activityID = solo.getCurrentActivity(); Properties props = solo._last_remote_result; String activityName = props.getProperty(Message.PARAM_NAME); String activityClass = props.getProperty(Message.PARAM_CLASS); System.out.println("CurrentActivity UID: "+ activityID); System.out.println("CurrentActivity Class: "+ activityClass); System.out.println("CurrentActivity Name: "+ activityName); }catch(Exception e){ e.printStackTrace(); } }
Refer to RobotiumTestRunner support
JavaDoc in com.jayway.android.robotium.remotecontrol.solo JavaDoc in com.jayway.android.robotium.remotecontrolAdditional SAFSTestRunner JavaDoc support
JavaDoc in org.safs.android.remotecontrol Also review: Using Serializable in Robotium RemoteControl
safs-remotecontrol.jar (robotium-remotecontrol.jar is no longer used.) robotium-serializable.jar (only needed if using new/custom serialized classes) safsautoandroid.jar safssockets.jar ddmlib.jar (<path-to-android-sdk>/tools/lib)
For example, the following command (all on one line) for the RobotiumTestRunner:
java com.jayway.android.robotium.remotecontrol.MyTest aut=<path-to-your/aut-debug.apk> messenger=<path-to/SAFSTCPMessenger-debug.apk> runner=<path-to/RobotiumTestRunner-debug.apk> instrument=com.jayway.android.robotium.remotecontrol.client/com.jayway.android.robotium.remotecontrol.client.RobotiumTestRunner avd=SprintEvo (only if sending to an emulator)
The equivalent command (all on one line) for the SAFSTestRunner:
java com.jayway.android.robotium.remotecontrol.MyTest aut=<path-to-your/aut-debug.apk> messenger=<path-to/SAFSTCPMessenger-debug.apk> runner=<path-to/SAFSTestRunner-debug.apk> instrument=org.safs.android.engine/org.safs.android.engine.DSAFSTestRunner avd=SprintEvo (only if sending to an emulator)
Of course, you can hardcode your arguments and paths in MyTest.java, or create a script file that performs the invocation for you. We show the arguments here so the user can get an idea of what is involved, and arguments that might be able to be changed with the same test class. For example, the installed MyTest example is able to run the same test with either the RobotiumTestRunner, or the SAFSTestRunner specified in the runner and instrument arguments. The same test can be run against different AVDs or devices, too.
Hopefully, upon execution you should see a torrent of activity appear in the console and, eventually, the SAFS Messenger service go active on the device/emulator. This would be followed by the launching of the AUT, a brief pause for the execution of the getCurrentActivity call, and then a shutdown of the AUT and SAFS Messenger service.
If all went well, you should see your System.out text not too far from the end of the console output. The output will contain something like:
CurrentActivity UID: 669d9657-6d3b-4706-994b-6cb6a7cc3235 CurrentActivity Class: com.android.example.spinner.SpinnerActivity CurrentActivity Name: SpinnerActivity
Robotium Remote Control has been initially coded as a subproject of the SAFSDEV Project.
SAFSDEV has integrated this into the larger and more full-featured SAFS test automation framework. One development environment. One JSAFS API--regardless of the application technology being tested or the tool integrations used to test it. Thus providing extensive support for all of the technologies below within a single reusable testing framework.
SAFS Engines (Tool Integrations):