For installation, please reference to Installing the SDK | Android Developers. The easiest way is to download Eclipse first, then install the Android Development Tools (ADT) as Plugin in Eclipse.
How to use the attached project zip file:
Unzip it first then copy them to you workspace;
Open Eclipse, and select “File -> New -> Other…”;
Select “Android -> Android Project”, and “Next”;
Select “Create project from existing source”, and input folder path of “AndroidCalculator” project into “Location”, and change “Project Name” to “AndroidCalculator”;
“Next” and select “Build Target” as “Android 2.3.3”, then “Finish”.
|
|
How to run the application we test against:
Create a AVD of Android 2.3.3 in Android Virtual Device Manager (AVD Manager) under “Window -> AVD Manager” in Eclipse;
Select project “AndroidCalculator”, and “Run As” “Android Application”.
How to run tests against the application:
Create a AVD of Android 2.3.3 in Android Virtual Device Manager (AVD Manager) under “Window -> AVD Manager” in Eclipse;
Open “AndroidCalculatorTest -> src -> com.calculator.test”;
Select any of the java file and “Run As” “Android JUnit Test”.
|
|
Features included in “AndroidCalculatorTest”:
“InstrumentationTests.java” is implemented by Instrumentation in Android SDK itself;
“RobotiumTests_APK.java” demonstrate how to test an Android APK file when only get the APK file itself, its “Package_ID” and “Main_Activity”;
“RobotiumTests_DataDriven.java” shows how to read a group of test data from a csv file, run series of tests, then export the results to another file;
“RobotiumTests_Whitebox.java” shows how to use Robotium in UT level, more from code coverage perspective;
“RobotiumTests.java” give you a brief knowledge of writing a basic Robotium test and take screenshot in the test. (please check the screenshot under “/mnt/sdcard” in DDMS).
Library Configuration Tip:
To run the Robotium tests, we need to select all in “Properties -> Java Build Path -> Order and Export”;
Move the robotium up to top and move Android and Android Dependencies just below robotium (but still above any project).
Issues encountered when writing Robotium tests:
Unable to take ScreenShot (saving the file to emulator): Unable to take screenshot on android using robotium and private method
“Null pointer exception” or “Array out of boundary” when reading a csv file: please check the format of csv whether it’s compatible with jxl.
Some materials for Android - Robotium framework:
robotium - It’s like Selenium, but for Android™ - Google Project Hosting
Controling Quality: Design Data Driven Framework around Robotium
Robotium_Black_Box_Testing_For_Android in Chinese