3. Agenda
Introduction
Features of Robotium
Limitations
Configurations and Creating a project
Discussion on project work flow
Short Demo
4. Short Introduction
Open Source Project hosted under Google code
(Source Code : GitHub)
Founder and Developer : Redas Rana (Jayway)
Now Project maintained by Robotium Tech
Basically its a JAVA jar Library containing robust
functions
User develops automation scripts using JAVA
Android SDK Library(android.test) provided for
testing is used with Robotium
5. What We can do with Robotium:
Features List:
Can write Automation scripts for Native as well as
Hybrid android applications
Supports Activities, Native Views, Web Views,
Toasts and Almost all UI Elements
Can test against Emulators as well as real devices
One script for all versions of Android
Independent of Device screen resolution and Size
Not co-ordinate based, so Robust
Multiple Activities handled automatically
6. Limitations :
No other Client Library supported except Java
No Support for Flash
7. Do we need Source Code ??
Automation Scripts can be written without source
code – Complete support for Blackbox Testing
We need the installer build of android platform
i.e apk file
Can also be written if we have Source code – Hence
supports Whitebox Testing
9. Requirements :
JAVA_HOME
Path of 'bin' directory in System path
ANDROID_HOME
Path of 'Tools' & 'Platform-Tools' in System Path
MAVEN_HOME
Path of 'bin' directory in System path
Configurations/Environment Variables:
10. Creating Emulators & Configuring Real
Device
Emulator:
1. Can be created from 'Android Virtual Device Manager' that is a part Android
SDK
2. Can also be created from command line after necessary path settings
Real Devices:
1. Enable USB Debugging from settings in device
2. Connect using micro/mini USB Cable with PC
3. Install necessary drivers for USB debugging according to device manufacturer
11. Re-Signing APK
Signature of both AUT and Test project must match,
so Re-Signing necessary
Unsign .apk
Re-sign it with debug.keystore
Command : jarsigner -verbose -sigalg MD5withRSA
-digestalg SHA1 -keystore debug.keystore
[AUT_name].apk androiddebugkey
Default Password: android
Resign Jar Tool can also be used
12. Installing app to Emulators/Device &
Some basic commands
Check for connected/available devices
adb devices
Install app to Device/Emulator
adb install [AUT_name].apk
Uninstall app
adb uninstall [application package name]
copy file from PC to Device/Emulator
adb push [file_path]/[File_name_with_extension]
copy file from Device/Emulator to PC
adb pull [file_path_on_device]/[File_name_with_extension] [folder_path_PC]
13. Creating Android Test Project
Create a new Android Test Project from Eclipse
File --> New --> Android Test Project
Convert it to a Maven Project
Add the following Dependency of Robotium to pom.xml
<dependency>
<groupId>com.jayway.android.robotium</groupId>
<artifactId>robotium-solo</artifactId>
<version>5.0.1</version>
</dependency>
14. Configuring Android Test Project
Define Target Package in AndroidManifest.xml
How to get Activity class names of AUT ?
From Hierarchy Viewer
From Dev Tools - Package Explorer
From Logcat
15. Developing Test Script :
Inherit ActivityInstrumentationTestCase2 in the
TestClass
public Class TestClass_Name extends
ActivityInstrumentationTestCase2
Continued..
16. Developing Test Script :
Create instance of Solo class
Define launcher activity class name
Define setUp() and tearDown() methods
Define test methods
17. Understanding Workflow of Android Test
Project
Based on Junit - Android Junit Test is the customized version of Junit3
Methods :
setUp() and tearDown()
Test Function Naming Convention
Must start with keyword 'test' e.g testLogin()
What happens while Executing :
Two apk files gets installed : AUT apk and Test Project apk
18. How Android Junit3 Different from
Junit4
setUp() and tearDown() take the roles of @Before and @After of
Junit4
Test Function Naming Convention
Must start with keyword 'test' e.g testLogin()
With Junit4 methods annoted with @Test recognized as test
methods
19. Annotations Available with Android Junit
Test Project
Most Frequently Used Annotations:
@Smoke
@SmallTest
@MediumTest
@LargeTest
@FlakyTest(tolerance=n)
To execute a particular Group of test methods annotations are useful
Can be specified while running test from Eclipse and command line
20. How to Target Elements on Activity
By Index
e.g solo.enterText(0,"some text");
By Id
e.g solo.getView("Id_Of_Element");
solo.enterText((EdiText)solo.getView("Id_Of_Element")," some text");
21. How To Get Ids ??
If we have Source code of AUT, Ids can be
identified from code
If we don't have Source Code, Hierarchy Viewer can
be used which Comes with Android SDK
22. Robotium Classes and API Definitions
Classes:
By
Condition
RobotiumUtils
Solo
Solo.Config
Solo.Config.ScreenshotFileType
Timeout
WebElement
API Documentation Link:
http://robotium.googlecode.com/svn/doc/index.html
23. Modes Of Running Tests
From Eclipse : As Android Junit Test
Annotations, Target Devices can be mentioned in Run Configurations
From CommandLine:
adb shell am instrument -w -e size [small/Medium/Large]
Testprojectpackagename/android.test.InstrumentationTestRunner
Particular Classes or Particular Functions can also be specified from command
Line
adb shell am instrument -w -e class
[class_name_with_package] Testprojectpackagename/android.test.Instrumen
tationTestRunner
24. Support For Build Tools and CI
Integration Servers
Can be used with Build Tools like Maven , Ant etc
Android-Maven-Plugin is used to Build with Maven
Can be integrated with Continuous Integration (CI)
server like Jenkins/Hudson