Post on 14-Aug-2015
Getting Started With Android Mobile App Testing
by Martin Poschenrieder CEO and Founder testmunk
June 22nd, 2015
Twitter: @mposchenrieder
Presentation for students at Portnov QA school
Twitter: @mposchenrieder
Which tools should I have? Where do I get started?
Twitter: @mposchenrieder
About me
• Born in Germany, moved to Silicon Valley 3 years ago.
• First QA related task, 10 years ago for German handset manufacturer
• First launched several mobile apps when realizing pain of app testing and started testmunk.
Twitter: @mposchenrieder
Demo testmunk
Twitter: @mposchenrieder
Goals for this session
1. Getting started on Android QA
2. Better understanding the “developer language” and terminologies
3. Being more productive: Faster bug investigation and replication
Twitter: @mposchenrieder
Twitter: @mposchenrieder
Agenda• What are common bugs on mobile
• What do we need to QA an android app
• Android sdk
• Adb - how do we interact with a device
• Android device logs
• What kind of tools does the developer use to code an android app?
• Sample app
Twitter: @mposchenrieder
What are typical issues / bugs found in mobile apps?
Question:
Twitter: @mposchenrieder
What kind of bugs will you find in your QA job?
Backend issues/ !Problems retrieving contentReference: http://blog.testmunk.com/flipboard-transitioning-from-manual-to-automated-ui-testing/
Twitter: @mposchenrieder
What kind of bugs will you find in your QA job?
Twitter: @mposchenrieder
Timeout issues!E.g. after XX seconds nothing happens
Reference: http://blog.testmunk.com/flipboard-transitioning-from-manual-to-automated-ui-testing/
Twitter: @mposchenrieder
UI issues!buttons/text/elements missing or wrong
Reference: http://blog.testmunk.com/flipboard-transitioning-from-manual-to-automated-ui-testing/
What kind of bugs will you find in your QA job?
Twitter: @mposchenrieder
What kind of bugs will you find in your QA job?
Crashes!Reference: http://blog.testmunk.com/flipboard-transitioning-from-manual-to-automated-ui-testing/
Twitter: @mposchenrieder
What kind of bugs will you find in your QA job?
UX issues!Reference: http://blog.testmunk.com/flipboard-transitioning-from-manual-to-automated-ui-testing/
Twitter: @mposchenrieder
What do we need to QA an android app?
.apk file
apk = Android package kit a mini USB cable An Android phone
a computer (Mac/Win/Linux) Source code (nice to have)
public class MainActivity extends Activity { @Override
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); }
Android sdk installed
Twitter: @mposchenrieder
Android SDKWhat is the Android SDK?
“A software development kit that enables developers to create applications for the Android platform. The Android SDK includes sample projects with source code, development tools, an emulator, and required libraries to build Android applications. Applications are written using the Java programming language and run on Dalvik, a custom virtual machine designed for embedded use which runs on top of a Linuxkernel.” (webopedia)
Twitter: @mposchenrieder
How can I interact with a device?
adb “Android debug bridge”
Twitter: @mposchenrieder
What is adb?ADB provides the bridge between your machine and your computer. it provides a terminal-based interface for interacting with your phone’s file system. Since Android platform is based on Linux, command-line is often required to perform certain advanced operations on your device using root access. http://forum.xda-developers.com/showthread.php?t=2011772
Twitter: @mposchenrieder
How can I install adb• adb is part of android sdk that comes by default with android studio
• Can be downloaded here: http://developer.android.com/sdk/index.html
• Can also be downloaded manually: https://developer.android.com/sdk/installing/index.html
Twitter: @mposchenrieder
adb “Android debug bridge”
Twitter: @mposchenrieder
How to enable android device on debug modeAndroid 4.x devices:!!Go to Settings > Developer Options > USB Debugging. !NOTE: For devices running Android 4.2.2 or later, you may need to unlock Developer Options before it is available within the Menu: !Go to Android home screen. Pull down the notification bar. Tap "Settings" Tap "About Device" Tap on the "Build Number" button about 7 times. Developer Mode should now be unlocked and available in Settings > More > Developer Options
http://www.companionlink.com/support/kb/Enable_Android_USB_Debugging_Mode
Twitter: @mposchenrieder
Which adb commands should I know?Adb devices!! Shows the devices that are connected. The devices that you want to get logs or run your automated testrun !!Adb kill-server // Adb start-server!! Commonly used when ‘adb devices’ doesn’t recognize the device.!!Adb install <file_path_to_apk>!Adb uninstall <file_path_to_apk>!
adb is part of ddms (Dalvik Debug Monitor Server) simply execute ddms in terminal
Twitter: @mposchenrieder
Which adb commands should I know? (2)
!
Record Video!adb shell screenrecord /sdcard/demo.mp4!!
Take screenshot !adb shell screencap -p /sdcard/screen.png!!Many more commands available -> google ‘adb commands’
Twitter: @mposchenrieder
Device logs are helpful (especially for the developer) to investigate bugs
FATAL EXCEPTION: main E/AndroidRuntime( 635): java.lang.RuntimeException: Only a background thread is allowed to do that - called from ItemCache:clearItems E/AndroidRuntime( 635): currentThread = main E / A n d r o i d R u n t i m e ( 6 3 5 ) : M a i n L o o p e r T h r e a d = m a i n E / A n d r o i d R u n t i m e ( 6 3 5 ) : a t flipboard.util.SharedAndroidUtil.requireBackgroundThread(SharedAndroidUtil.java:152) E/AndroidRuntime( 635): at flipboard.io.SectionDataCache.softRequireBackgroundThread(SectionDataCache.java:150) E/AndroidRuntime( 635): at flipboard.io.SectionDataCache.clearItems(SectionDataCache.java:80) E/AndroidRuntime( 635): at flipboard.service.User.removeSectionInternal(User.java:2104) E/AndroidRuntime( 635): at flipboard.service.User.removeSection(User.java:1975) E/AndroidRuntime( 635): at flipboard.service.User.unfollowSection(User.java:1943)
Twitter: @mposchenrieder
How can I access the android device logs?
Logcat (The device log)!adb logcat –d!!Export to a file on your desktop!Windows: adb logcat –d > %UserProfile%\Desktop\device_log.txt!Mac: adb logcat -d > ~/Desktop/device_log.txt!!Windows & Mac: adb logcat -c!To clear
Twitter: @mposchenrieder
The manifest file (good to know about it)
• “No launchable activity found”
<application android:label="@string/app_name" android:icon="@drawable/icon"> <activity android:name="ExampleActivity" android:label="@string/app_name">
<intent-filter> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> </intent-filter>
</activity> </application>
The manifest file presents essential information about your app to the Android system… (read more)
Twitter: @mposchenrieder
uiautomatorviewer• “Which buttons are you talking about?” Type uiautomatorview in terminal
takes screenshot
Twitter: @mposchenrieder
What IDEs do android developers use? • IDE = Integrated development Environments) - where the “cool” stuff
gets build :)
• Most common are:
• IntelliJ
• Eclipse
• Android Studio
Twitter: @mposchenrieder
Android Studio (most popular from Google)
Twitter: @mposchenrieder
Some Test automation Frameworks!
• Calabash / Appium • cross platform compatible
• Robotium • uiautomator • Espresso • Selendroid
Twitter: @mposchenrieder
Good to know• Mobile test automation is becoming more and more popular • Device fragmentation as one major reason • Using resources effectively
• QA Engineers need to have a powerful ‘toolbox’ to use the best approaches for the job to be done (like performance testing, ux testing, test automation…)
• QA is the one who usually understand the most about a product and connects ‘business people’ with devs.
!
Twitter: @mposchenrieder
FAQ / common questions• Can I run an apk on both emulator and device —> YES, different on iOS though.
• What can be automated?
• Good average is 30-50% sometimes more, sometimes less depending on the app.
• How do I deal with UI changes and changing my test cases
• Good structure is very helpful. E.g. Page Object Framework (Link here)
What are your questions?
Twitter: @mposchenrieder
Where do I get started• Sample android app and sourcecode: https://github.com/
testmunk/TMSampleAndroid
• Check out our blog on blog.testmunk.com, where we cover topics such as:
• Getting started with mobile test automation
• Moving from manual to automated testing
• Page Object Framework
Twitter: @mposchenrieder
Diving into Android Studio and adb• Sample Android project: https://github.com/testmunk/TMSampleAndroid
Twitter: @mposchenrieder
Contact
Martin Poschenrieder
Twitter: mposchenrieder
email: martin@testmunk.com