- Android SDK with updated path variable
- ADT plugin in eclipse
Steps for setting up proper environment for automation
- Install java
- Install eclipse
- Install android sdk
with proper installation typing “adb” in command prompt from any path should give you something like this …
- Install adt plugin in eclipse. Above points can referred here and here
- Set android SDK location in eclipse. In eclipse go to Window -> Preferences -> Android. With proper ADT plugin installation it should appear something like this …. Provide exact installation location of the android SDK here. If successful set you will see this
- Create AVD. In Eclipse go to Window -> Android sdk and avd manager. This will open up the “Android SDK and AVD manager” (you can also open it from windows programs and android SDK). Click on new and provide name, target(android version), sd card size, resolution(built in). After filling in all the required fields hit “Create AVD” Select the AVD created just now and hit “start” and then “launch”. This should launch the emulator with the above selected configuration.
Now everything is setup for running Robotium tests.
Running the sample test
- Download the sample code from here. Unzip the file to some location.
- Import the code into eclipse. In eclipse go to File -> Import -> Existing Projects into Workspace. On successful import of the projects you should see all the project files and folders visible in the package explorer of eclipse.
- Install the app in the emulator. Download the FileManager app from here. (this app is signed with the debug key, details about signing apps with your own keys can be found here). From the saved path open a command prompt and type – adb install <app-name>.apk
- Open the app “OI File Manager”(the application we installed) and click on “Accept” and “Continue” (I havent handeled this in the tests). Now we are all set to run the test.
- Select the test and run as “Android Junit tests”.
- In few secs you could see running tests. First time it fails(its intentional) and creates a screenshot, which is a very useful information for debugging. You can check out the code for how the screenshot is captured, its not a robotium feature, its achieved using native android apis. Open the app in the emulator you could see the screenshot named as ‘testname…..’ . After viewing get back to the view below in the app, you can hit back in the emulator.
- Run the tests again, it should pass.
You can enhance the tests further and use it for automating your own/other apps.