Automated Testing of Application on Android using ROBOTIUM – Part 2
Submitted by kkambham on April 26, 2011
Read article at Alliance Global Services
Since my previous blog on automated testing of applications on Android ( Part 1 ), I have been working on various challenges encountered during automation and further refining the approach to create a robust data-driven mobile automation framework with good reporting capabilities.
In this blog, I will be writing about how to setup and configure environment for automated testing of applications on Android starting with setup, creation of the android test project and modifying the manifest.xml file.
The base setup is well documented by following the following links:
• Downloading and installing Base ROBOTIUM Framework v2.2
• Setting up the environment for Android development with eclipse
I have used Eclipse as my IDE as it is well integrated and documented for Android development. Once we have downloaded the ROBOTIUM framework and setup the eclipse, we need to know the Package/Starter Activity name/Android SDK version details of the application to be tested using Robotium. I have found two approaches to find these details.
Approach 1
At the command prompt enter the command:
C:\> adb logcat
And search for below text:
"Starting activity: Intent {act=android.intent.action.MAIN cat=android.intent.category.LAUNCHER? flg=0x10200000 cmp=com.example.android.notepad/.NotesList
"
Target Package: com.example.android.notepad
Starter Activity: NotesList
This gives us the required Package/Starter Activity name details for proceeding with developing automation scripts.
Approach 2
Use re-sign.jar to assign signature for APK File. Open re-assign.jar file and drop the Application APK file. It will remove the existing signature and repacks it as a jar file. Finally it will display the package name and starter activity.
Modify Application Signature
After using re-sign.jar, use java ([jdk1.x]/bin), jarsigner utility to assign new signature (debugkey signature) to the apk created by re-sign utility. Deploy the newly created apk into target device to start with creating automation scripts.
Syntax to use jarsigner utility :
jarsigner -keystore debug.keystore -storepass android -keypass androiddebugkey
Once the prerequisite are known we can proceed with creating an Android JUnit test project in Eclipse.
Create Android Test Project File
To create the test project, open the Eclipse IDE and create AndroidTestProject (File->new->Project->Android->AndroidTestProject). In order to create the test project we need to fill the following details:
• TestProjectName : [exampleapplicationtesting]
• Test Target : Select “ThisProject“
• Build Target : Select this value based on Android SDK version in which the Automation-Under-Test (AUT) was developed.
If the AUT was developed using SDK version 7 then select Android2.1-Update1.
If the AUT was developed using SDK version 8 then select Android2.2.
• Properties :
o Application name: [applicationtesting]
o Packagename: [com.test.android.applicationtesting]
o MinSDKversion: Default value will be automatically displayed based on Build Target selection.
Click on “finish” to create the new project with the name [exampleapplicationtesting].
Modifying AndroidManifest.xml
We need to modify manifest file to setup target Application to support various versions of Android SDK.
Default Value in manifest.xml :
[instrumentation android:targetPackage="[com.Example.ApplicationTesting]"]
New value to be entered in in manifest.xml :
[instrumentation android:targetPackage="[Target App package name]"]
We can also specify one additional attribute “android:label”, which will allow us to easily identify the test project in Dev Tools->Instrumentation (as shown in the image below) and execute the automated test from device itself.
If application SDK version is not available then specify the minSDK and maxSDK version to scale test project on multiple SDK versions of the application. The syntax to specify the sdk versions in manifest.xml is:
[uses-sdk android:minsdkversion="3" android:targetsdkversion="7" android:maxsdkversion="9"/]
After doing these modifications save the manifest file. This will complete the basic setup and configuration and get us ready to start creating test scripts using Robotium in Eclipse.
About the author: Kishor Reddy, Associate Test Architect |
Associate Test Automation Architect at Alliance Global Services varied experience of 8+ years in STLC – rich experience in Functional Test Automation. Very well experienced in designing Test Automation frameworks, developing test automation solutions for Web, Flex, Flash and Desktop applications and Client-Server applications using QTP and Open-source tools like Selenium, Flex Monkey and Robotium. View my complete profile |
Theme by Danetsoft and Danang Probo Sayekti