Testing OpenRemote Android 2.0 Console
This tutorial assumes you're already familiar with how to build the OpenRemote 2.0 Android Console project. If you haven't built OpenRemote Android from source yet, please see Building OpenRemote Android 2.0 Console first.
Short Overview of Android Testing
Android unit tests are a stand-alone Android applications (compiled to an APK binary) that run alongside in the same process space with the actual, testable, main Android application – in our case the OpenRemote 2.0 Android Console application.
Therefore, when tests are run, two APK binaries are installed either on the emulator or actual device and the unit test application interacts with the main application in various ways, depending what kind of test case is being built.
For all the gory details, please refer to the Official Android Developer Page on Testing.
Update Test Project
Included in the OpenRemote 2.0 Android Console component checkout is a top level "tests" directory which contains test classes.
Since the Android unit tests are a stand-alone Android binaries, the same steps apply to managing the unit test application project. The android command line tool can be used to keep the unit test application and build files in sync with the main project (same API levels, etc.).
Assuming you've installed Android SDK and checked out the OpenRemote project under the same top-level directory, you can update the project files as follows (if you've installed components to different directories, adjust file paths as necessary):
Run Tests in Emulator
Test can be run from command line using the Ant build tool.
First you must start the Android emulator. Refer to the Building OpenRemote Android 2.0 Console for how to start virtual Android devices.
Once the Android emulator is running, execute the 'run-tests' Ant target in the 'tests' project:

Not all tests will necessarily complete when run in the Android emulator. Certain system services such as WiFi connections may not be available in the emulator.
For full complete tests you should run the test suite in a physical Android device. All tests should pass in that case (unless there are known failures).
Run Tests in Android Device
The steps to run OpenRemote 2.0 Android unit tests on a physical device are almost identical to running the tests on an emulator.
Before executing the 'run-tests' Ant target, plug in the device to the USB port. If you have existing Android emulator instances running, shut them down first.
To use an Android device, make sure it has been enabled for development. See the required steps in Building OpenRemote Android 2.0 Console for how to enable a device for development. In case you are using Linux or Windows, also make sure you've installed the required USB drivers to access the device. Mac users do not need to perform any additional steps but can use the USB connection to device out of the box.
Note that when the tests are run against an Android device, all tests should pass, unless known and documented failures exist.
Troubleshooting
The following lists some common errors that may occur when trying to run the Android console unit tests.
SetupTask cannot be found
When trying to run the unit tests, if you see the following error:
Resolution
Make sure you've changed the directory to Android_Console_2_0_0_Alpha1/tests before trying to run the tests.
See Also