Copyright (C) SAS Institute
General Public License: http://www.opensource.org/licenses/gpl-license.php
| 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. |
| TestRunner | The on-device SAFS Test Runner APK for SAFS Android Remote Control testing. |
| 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. For SAFS, the SAFS Android Engine is considered the Controller. |
| The Test | The SAFS keyword-driven tests or JSAFS tests developed for execution by SAFS. More native SAFS/Robotium Remote Control tests are also possible. |
SAFS Android Remote Control support and execution has the same system requirements as those required for developing standard native Android tests. That means a Java SDK, the Android SDK, and Ant are still required. Ideally, these should be installed prior to installing SAFS.
* The System environment variable JAVA_HOME should be set to the path to the Java SDK.
* The System environment variable PATH should contain the path to the Java SDK 'bin' subfolder.
* The System environment variable ANDROID_HOME should be set to the path to the Android SDK.
* The System environment variable PATH should contain the paths to both the Android SDK's 'tools' and 'platform-tools' subfolders.
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.
* The System environment variable ANT_HOME should be set to the path to the Ant SDK.
* The System environment variable PATH should contain the path to the Ant SDK's 'bin' subfolder.
(As an advanced feature, the framework can rebuild the SAFSTestRunner at runtime to match the targetPackage of whatever AUT is specified for testing.)
Rebuild Sample SpinnerActivity-debug.apk:
Required only once to build with your tester/developer debug profile.
Once you have successfully completed the Setup Instructions above, you should be ready to test/verify that SAFS Android support is working.
The SAFS Droid sample comes with a ready-to-run test for the SpinnerSample provided by SAFS. As mentioned in Definitions and the Setup Instructions above, you must have a valid emulator AVD or a real Device working properly with your Android SDK.
Consult the SAFS Keyword Reference for specific Android (DRD) support currently available in SAFS.
Specifically:
Enjoy!
You can also use the SoloRemoteControl project installed with the Droid samples as a reference for your own Java test development project for SAFS/Robotium Remote Control. This is completely different than writing SAFS Test Tables with Driver Commands and Component Functions. This is for Java developers, or testers with Java develoment experience.
The SoloRemoteControl/src directory contains all the sourcecode contained in the safs-remotecontrol.jar.
safs-remotecontrol.jar (re-sign.jar is also present, but is not normally part of a development project.)
The quickest way to do the above in Eclipse:
Create a New->Java Project from the existing source at:
samples\Droid\SoloRemoteControl
You can find the existing sample MyTest code in the SoloRemoteControl/src folder at:
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{
// see the existing MyTest.java for a completed example
}
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(){
String action = "MyTest";
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);
log.pass(action, "CurrentActivity UID: "+ activityID);
log.pass(action, "CurrentActivity Class: "+ activityClass);
log.pass(action, "CurrentActivity Name: "+ activityName);
}catch(Throwable e){
e.printStackTrace();
}
}
Refer to: JavaDoc for com.jayway.android.robotium.remotecontrol.solo JavaDoc for com.jayway.android.robotium.remotecontrol Also review: Using Serializable in SAFS/Robotium RemoteControl
safs-remotecontrol.jar
(The above can be found in the SoloRemoteControl/libs folder.)
The following command (all on one line) for MyTest (see the runSoloTest file below):
%SAFSDIR%\jre\bin\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. 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 as everything mentioned above transpires.
Upon completion, the default "RemoteControl.log" is stored in the "current working directory".
The default runSoloTest script should have that in the SoloRemoteControl\bin.
The log will contain something like:
PASS : MyTest: CurrentActivity UID: 669d9657-6d3b-4706-994b-6cb6a7cc3235 PASS : MyTest: CurrentActivity Class: com.android.example.spinner.SpinnerActivity PASS : MyTest: CurrentActivity Name: SpinnerActivity
Carl Nagle, SAS Institute Project Manager, SAFSDEV Subscribe to appropriate Support Forums to review support archives and ask questons.