Trang chủ
QA Learning Hub
Chương 14 · Mobile Testing
Chương 14 Trung Cấp

Mobile Testing

Đặc thù kiểm thử ứng dụng di động — iOS, Android, và những test case chỉ có trên mobile.

📱 Phân Loại Mobile App
NativeHybridReact Native / FlutterMobile Web
TechSwift (iOS) / Kotlin (Android)Cordova/Ionic wrap WebViewJS/Dart compile to nativeBrowser, any language
PerformanceBestPoor-MediumGoodDepends on browser
Test ToolsXCTest, Espresso, AppiumAppium + WebView inspectionDetox (RN), Flutter DriverPlaywright/Selenium + DevTools
Test ChallengesPlatform-specific bugsWebView + native layerBridge latency, gesture eventsBrowser compatibility
DistributionApp Store / Play StoreApp stores or PWAApp storesURL — instant update
🔍 Mobile-specific Test Cases
  • InterruptionsĐang dùng app: (1) Incoming call → decline → app state preserved. (2) SMS notification → dismiss → back to app. (3) App goes to background (home button) → resume. Data không bị mất.
  • Background/ForegroundApp in background 30 phút → foreground: auth session valid? Data refresh tự động? Loading state shown? (iOS có thể kill app khi memory pressure)
  • Network ConditionsSwitch từ WiFi → 4G giữa chừng. Switch to Airplane Mode. 3G slow (200ms latency). Offline hoàn toàn → graceful error message, không crash.
  • OrientationPortrait → Landscape mid-form: data preserved? Layout đúng? Video/image scale. Force portrait (nếu app chỉ support 1 orientation) → handle gracefully.
  • KeyboardSoft keyboard che input field cuối form? Form scroll lên không? Keyboard dismiss khi tap outside? Return/Done key behavior đúng không?
  • Battery & MemoryApp chạy nền có drain battery bất thường không? Sau 1 giờ sử dụng, memory có leak không? (Monitor với Instruments/Android Profiler)
  • PermissionsCamera: deny → app show helpful message, không crash. Location: "Always" vs "While Using" vs "Deny" — behavior đúng cả 3 case. Notification: deny → app vẫn hoạt động core features.
  • App UpdateUpdate từ v1.0 → v2.0: user data (preferences, login state) preserved. DB migration chạy đúng. Không force logout trừ khi absolutely necessary.
  • Deep LinksClick link trong email/SMS → mở đúng screen trong app. Nếu app chưa install → redirect đúng App Store/Play Store.
  • Push NotificationsTap notification: app closed → open đúng screen. App in background → bring to foreground, navigate đúng screen. App in foreground → in-app notification hoặc handle gracefully.
📋 Device Test Strategy
PriorityiOSAndroidRationale
P1iPhone 15 Pro (iOS 17), iPhone 13 (iOS 16)Pixel 7 (Android 14), Samsung S23 (Android 13)Latest OS, high market share
P2iPhone 12 (iOS 15), iPad (iPadOS 17)Samsung A54 (mid-range), Android 12Older OS users, tablet
P3iPhone SE (small screen), iOS 15Entry-level device, Android 11Edge cases, older users

Real Device vs Emulator:

  • Emulator/Simulator tốt cho: Quick functional check, fast iteration, free, CI integration, keyboard/touch emulation
  • Real device bắt buộc cho: Performance testing, camera/NFC/biometrics, battery drain, actual network behavior, certify release candidate
  • BrowserStack/AWS Device Farm: Cloud real devices — tốn tiền nhưng cover nhiều device types. Dùng cho release sign-off.
🍎 iOS-specific Testing
  • Safe Area: Content không bị che bởi Dynamic Island (iPhone 14 Pro+), notch, home indicator ở dưới
  • Face ID / Touch ID: Biometric authentication flow. Enroll → authenticate → bypass (passcode fallback)
  • TestFlight: Distribution platform cho iOS beta. Test update notification, version management
  • iOS keyboard shortcuts: Undo (shake), cut/copy/paste magnifier, keyboard accessory bar
  • iCloud Sync: Data sync giữa iPhone và iPad nếu app support
  • App Store Guidelines: In-app purchases phải qua Apple (30% commission), certain content restrictions
  • Privacy labels: App Store privacy "nutrition labels" phải accurate với actual data collection
🤖 Android-specific Testing
  • Back button: Android hardware/gesture back — navigate trong app stack, hoặc background app. Không bao giờ crash.
  • APK Sideloading: Install APK directly (debug builds) → test không cần Play Store. adb install app.apk
  • ADB Commands cho QA:
    • adb devices — list connected devices
    • adb logcat — view device logs realtime
    • adb shell input text "hello" — input text
    • adb screencap /sdcard/screenshot.png — take screenshot
  • Fragmentation: Android runs trên 1000s of device models với customized UI (Samsung One UI, Xiaomi MIUI). Test trên Samsung nếu target market là Asia.
  • Storage Permissions: Android 13+ granular storage permissions thay vì single READ_EXTERNAL_STORAGE
  • Battery Optimization: Android có thể kill background processes để tiết kiệm pin — test app behavior khi bị killed
🧰 Mobile Testing Tools
  • BrowserStack App LiveReal device cloud, 3000+ devices. Upload APK/IPA và test directly. Session recording, device logs. Nhất cho cross-device testing.
  • Xcode SimulatoriOS simulator (macOS only). Nhanh, free. Limitation: không test camera, NFC, actual network. Tốt cho development và initial QA.
  • Android Studio EmulatorAVD Manager — create virtual devices với bất kỳ Android version. Chậm hơn real device, Google Play services có thể thiếu.
  • Charles Proxy / ProxymanIntercept HTTP/HTTPS traffic từ device. Debug API calls, mock responses, test offline behavior bằng cách block endpoints.
  • Appium InspectorInspect UI elements của native app để viết automation locators. Chạy trên top của Appium server.
  • Firebase Test LabGoogle's cloud device testing — real Android devices, automated test (Espresso/Robo), free tier có sẵn.
✏️ Bài Tập
📝 Bài Tập: Mobile Test Plan

Bạn sắp test ứng dụng food delivery mobile (iOS + Android). Tính năng mới: Real-time order tracking với live map.

  1. Define device test matrix (P1/P2/P3) với justification
  2. Viết 15 mobile-specific test cases (không phải functional tests về tracking feature mà là platform/mobile-specific cases)
  3. Identify 5 risks đặc thù cho real-time tracking feature trên mobile
  4. List 3 test cases chỉ có thể test trên real device (không thể trên emulator)