Upload
mindfire-solutions
View
1.180
Download
8
Tags:
Embed Size (px)
DESCRIPTION
This presentation would help give a jump start guide on Robotium for getting started with Android automation should join this Seminar.
Citation preview
Android Automation Using Robotium
Presenter : Abhishek Swain, Mindfire Solutions
About Me: Abhishek Swain, Software QA EngineerMindfire Solutions
Skills : Robotium , Appium , Selenium WebDriver , Maven , Junit , SQL ....
Certifications : ISTQB Foundation Level, V-Skills Selenium Certified
Connect Me :Facebook : http://www.facebook.com/jikun55LinkedIn : http://in.linkedin.com/pub/abhishek-swain/58/8a/829/
Contact Me :Email : [email protected] /[email protected]: mfsi_abhishekswain
Agenda
Introduction Features of Robotium Limitations Configurations and Creating a project Discussion on project work flow Short Demo
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
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
Limitations :
No other Client Library supported except Java No Support for Flash
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
Requirements :
Android SDK Download Link: http://developer.android.com/sdk/index.html
Java JDK Eclipse Maven Maven Plugin for Eclipse Installation Link :http://download.eclipse.org/technology/m2e/releases
Installations:
Requirements :
JAVA_HOME Path of 'bin' directory in System path
ANDROID_HOMEPath of 'Tools' & 'Platform-Tools' in System Path
MAVEN_HOMEPath of 'bin' directory in System path
Configurations/Environment Variables:
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
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
Installing app to Emulators/Device & Some basic commands
Check for connected/available devicesadb devices
Install app to Device/Emulatoradb install [AUT_name].apk
Uninstall appadb uninstall [application package name]
copy file from PC to Device/Emulatoradb push [file_path]/[File_name_with_extension]
copy file from Device/Emulator to PCadb pull [file_path_on_device]/[File_name_with_extension] [folder_path_PC]
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>
Configuring Android Test Project
Define Target Package in AndroidManifest.xml
How to get Activity class names of AUT ?
From Hierarchy ViewerFrom Dev Tools - Package ExplorerFrom Logcat
Developing Test Script :
Inherit ActivityInstrumentationTestCase2 in the TestClass
public Class TestClass_Name extends ActivityInstrumentationTestCase2
Continued..
Developing Test Script :
Create instance of Solo class Define launcher activity class name Define setUp() and tearDown() methods Define test methods
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 ConventionMust start with keyword 'test' e.g testLogin()
What happens while Executing :Two apk files gets installed : AUT apk and Test Project apk
How Android Junit3 Different from Junit4
setUp() and tearDown() take the roles of @Before and @After of Junit4
Test Function Naming ConventionMust start with keyword 'test' e.g testLogin()
With Junit4 methods annoted with @Test recognized as test methods
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
How to Target Elements on Activity
By Indexe.g solo.enterText(0,"some text");
By Ide.g solo.getView("Id_Of_Element");solo.enterText((EdiText)solo.getView("Id_Of_Element")," some text");
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
Robotium Classes and API Definitions
Classes:
ByConditionRobotiumUtilsSoloSolo.ConfigSolo.Config.ScreenshotFileTypeTimeoutWebElement
API Documentation Link:http://robotium.googlecode.com/svn/doc/index.html
Modes Of Running Tests
From Eclipse : As Android Junit TestAnnotations, 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.InstrumentationTestRunner
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
Demo :
Questions ??
www.mindfiresolutions.com
https://www.facebook.com/MindfireSolutions
http://www.linkedin.com/company/mindfire-solutions
http://twitter.com/mindfires