Elective Mobile Application Development

Mobile Application DevelopmentUnit 414 min read

Testing & Publishing Apps: Types, Tools & App Stores

Unit 4 of Mobile Application Development covers systematic testing methodologies (unit, integration, system, user acceptance), automated testing tools (Espresso, XCTest, Firebase Test Lab), app publishing guidelines (Google Play Store, Apple App Store), and post-release analytics (Crashlytics, Firebase Analytics). It a

TAKEAWAYS:

  • Testing pyramid: Unit tests (fast, low-level) → Integration tests (component interactions) → System tests (end-to-end) → User acceptance tests (real-world validation).
  • Automated testing tools like Espresso (Android) and XCTest (iOS) reduce manual effort and improve coverage, but require setup time.
  • App Store policies differ by platform (e.g., Apple’s 30% revenue cut vs. Google’s flexible pricing), and compliance is critical for approval.
  • Post-release monitoring (crash reports, user feedback) helps iterate on apps like eSewa or Khalti after launch.
  • Localization (translations, cultural adaptations) is essential for apps targeting diverse markets like Nepal’s (e.g., Daraz or Pathao).
  • Ethical testing (privacy, accessibility) avoids legal risks and improves inclusivity, as seen in NTC’s or Ncell’s compliance with telecom regulations.

1. Types of Mobile App Testing

Mobile apps require multi-layered testing to ensure functionality, performance, and security. The testing pyramid (below) shows the balance between test types:

pie
    title Mobile App Testing Pyramid
    "Unit Tests" : 60
    "Integration Tests" : 25
    "System Tests" : 10
    "User Acceptance Tests" : 5

1.1 Unit Testing

Definition: Testing individual components (e.g., a single function or class) in isolation. Tools:

  • Android: JUnit, Espresso
  • iOS: XCTest, SwiftUI Previews
  • Cross-platform: Flutter’s test package, React Native’s Jest

Example: Testing a Khalti payment validation function

// Flutter/Dart example: Unit test for payment validation
import 'package:test/test.dart';
import 'package:khalti_payment/khalti_payment.dart';

void main() {
  test('Validates successful payment', () {
    final payment = Payment(
      amount: 1000,
      transactionId: 'TX12345',
      status: 'SUCCESS',
    );
    expect(validatePayment(payment), isTrue); // Passes if logic is correct
  });
}

Trace Table:

Step Input (payment) validatePayment() Logic Output (expect) Status
1 amount=1000, status="SUCCESS" Checks status == "SUCCESS" true Pass
2 amount=0, status="FAILED" Fails amount > 0 check false Fail

Why it matters:

  • Catches bugs early (e.g., Pathao’s ride-cost calculator before integration).
  • Real-world use: Google uses Espresso to test YouTube’s Android app’s video playback logic.

1.2 Integration Testing

Definition: Tests interactions between modules (e.g., API calls + UI). Example: eSewa’s payment flow (UI → backend API → bank). Tools:

  • Android: Mockito (for mock APIs), Robolectric
  • iOS: OCMock, XCTest with URLSession
  • Cross-platform: Postman (API testing) + Appium (UI automation)

Mermaid Workflow:

flowchart TD
    A["User taps 'Pay' in eSewa"] --> B["UI sends request to Payment API"]
    B --> C["API calls NMB Bank for verification"]
    C -->|"Success"| D["Bank returns token"]
    C -->|"Failure"| E["Show error to user"]
    D --> F["UI updates status to 'Paid'"]

Trace Table (API Call):

Step Component Action Expected Response Status
1 UI Sends POST /pay with amount=500 200 OK Pass
2 Payment API Calls NMB Bank API {"token": "ABC123"} Pass
3 Bank API Validates user credentials {"status": "APPROVED"} Pass
4 UI Displays "Payment Successful" UI updates Pass

Why it matters:

  • Daraz’s cart-to-checkout flow must integrate inventory, payment, and shipping systems seamlessly.

1.3 System Testing

Definition: Tests the entire app in a simulated real-world environment. Types:

Type Description Example (Nepal)
Functional Tests app against requirements (e.g., login works). Ncell’s myNcell app’s recharge flow.
Performance Checks speed, memory, battery usage. WhatsApp’s message delivery in slow networks.
Security Penetration testing (SQL injection, data leaks). NEPSE’s mobile app’s API encryption.
Usability Tests UI/UX (e.g., accessibility for visually impaired users). Khalti’s OTP input field design.
Compatibility Tests across devices/OS versions (e.g., Android 10 vs. 13). eSewa’s support for old Android phones.

Example: NTC’s mobile app’s performance under load

  • Tool: Android Profiler (for CPU/memory) or Xcode Instruments (iOS).
  • Test: Simulate 10,000 users checking internet speed.
  • Result:
    graph TD
        A["10,000 users"] --> B["CPU Usage: 85%"]
        B --> C["Memory Leak Detected"]
        C --> D["Fix: Optimize background threads"]

Why it matters:

  • Pathao’s app crashes if too many drivers request routes simultaneously → load testing prevents this.

1.4 User Acceptance Testing (UAT)

Definition: Real users test the app in production-like conditions. Methods:

  • Beta Testing: Release to a small group (e.g., Google Play Beta).
  • A/B Testing: Compare two versions (e.g., YouTube’s new UI vs. old).
  • Focus Groups: Gather feedback from target users (e.g., eSewa’s rural vs. urban testers).

Example: Khalti’s UAT for Nepali language support

  • Test Group: 500 users in Kathmandu and Pokhara.
  • Feedback:
    • 80% liked the Nepali UI but struggled with OTP input.
    • Fix: Added larger buttons and voice OTP.

Why it matters:

  • Daraz’s UAT revealed that Pokhara users preferred cash-on-delivery over online payments → adjusted marketing.

2. Automated Testing Tools

Manual testing is slow. Automation speeds up regression testing and improves coverage.

Tool Platform Purpose Example Use Case
Espresso Android UI + unit testing Test Ncell’s recharge button clicks.
XCTest iOS UI + unit testing Test Apple Pay’s transaction flow.
Firebase Test Lab Cross-platform Cloud-based device testing Test WhatsApp on 100+ Android devices.
Appium Cross-platform UI automation (WebDriver protocol) Test eSewa’s cross-browser compatibility.
Jest React Native Unit testing Test Facebook’s React Native ads SDK.

Example: Espresso Test for a Login Button

// Android (Java) Espresso test
@Test
public void testLoginButton() {
    onView(withId(R.id.emailEditText)).perform(typeText("user@example.com"));
    onView(withId(R.id.passwordEditText)).perform(typeText("password123"));
    onView(withId(R.id.loginButton)).perform(click());
    onView(withText("Login Successful")).check(matches(isDisplayed()));
}

Trace:

Step Action Expected Result Actual Result Pass/Fail
1 Enter email Text field updates ✅ Pass
2 Enter password Text field updates ✅ Pass
3 Click login "Login Successful" toast appears ❌ (blank) Fail
4 Debug: API returns 401 (wrong password) Show error toast ✅ (after fix) Pass

Why it matters:

  • Google uses Firebase Test Lab to test YouTube’s app on 1,000+ devices before updates.

3. Publishing Apps: Google Play Store vs. Apple App Store

Criteria Google Play Store Apple App Store
Revenue Share 15% (30% for first $1M/year) 30% (15% for subscriptions)
Approval Time ~1–2 days (automated checks) ~1–5 days (manual review)
Content Rules Less strict (e.g., ads allowed) Strict (e.g., no adult content)
Update Frequency Unlimited updates Apple reviews updates
Payment Methods Supports UPI (India), but limited in Nepal Supports Khalti, eSewa (via third-party)
Device Fragmentation High (many Android versions) Low (iOS is uniform)

Example: Publishing Pathao’s App in Nepal

  1. Prepare assets:
    • Screenshots (Nepali language).
    • Privacy policy (mentioning driver data collection).
  2. Submit to Play Store:
    • Fill metadata (app name: "Pathao – Ride & Food Delivery").
    • Pay $25 one-time developer fee.
  3. Apple App Store:
    • Submit via App Store Connect.
    • Apple may reject if driver verification isn’t clear.
  4. Post-launch:
    • Use Firebase App Distribution for beta testers.
    • Monitor crashes via Crashlytics.

Why it matters:

  • eSewa’s app was rejected by Apple initially for insecure API calls → had to implement end-to-end encryption.

4. Post-Release: Analytics & Iteration

After publishing, track:

  • Crashes: Crashlytics (Firebase) or Xcode Organizer (iOS).
  • User Behavior: Firebase Analytics or Amplitude.
  • Revenue: Google Play Console or App Store Connect.

Example: Daraz’s Post-Launch Analysis

Metric Tool Used Insight Action Taken
Crash Rate Crashlytics 5% crashes on Android 9 Added compatibility fixes.
User Drop-off Firebase Analytics 70% leave at checkout Simplified payment steps.
Revenue Google Play Console Low in Pokhara Added cash-on-delivery option.

Why it matters:

  • Khalti’s analytics showed rural users abandoned transactions due to slow internet → optimized API calls.

5. Localization & Ethical Testing

5.1 Localization for Nepal

  • Language: Support Nepali (Devanagari) + English.
  • Cultural Adaptations:
    • eSewa: Added Nepali holidays (e.g., Dashain, Tihar) for payment deadlines.
    • Pathao: Added bike taxis (common in Kathmandu).
  • Payment Methods: Khalti, eSewa, IME Pay (not just credit cards).

Example: Ncell’s Localized App

mindmap
  root((Ncell App Localization))
    Language
      Nepali
      Maithili
      Newari
    UI
      Font: "Kanji" (Nepali font)
      Colors: National flag (red, blue)
    Payments
      Khalti
      eSewa
      Bank Loans
    Support
      24/7 Helpline in Nepali

5.2 Ethical & Accessibility Testing

  • Privacy: Comply with Nepal’s Data Privacy Act (2018) (e.g., NTC’s data collection).
  • Accessibility:
    • Screen reader support (e.g., TalkBack for blind users).
    • Color contrast (e.g., Khalti’s buttons meet WCAG standards).
  • Bias Testing: Ensure algorithms (e.g., Pathao’s surge pricing) don’t discriminate.

Example: NEPSE’s Accessible App

  • Features:
    • Voice commands for stock quotes.
    • High-contrast mode for elderly users.
  • Result: 20% more users with disabilities.

In the Real World

  1. eSewa’s Testing Process:

    • Unit tests: Validate payment API responses.
    • Integration tests: Ensure NMB Bank and eSewa’s servers sync.
    • UAT: Tested with 5,000 users in Kathmandu before full launch.
    • Post-release: Crashlytics showed crashes on Android 8 → forced update.
  2. Pathao’s Load Testing:

    • Simulated 10,000 drivers requesting routes during Dashain (high demand).
    • Found server bottlenecks → upgraded to AWS.
  3. Khalti’s Localization:

    • Added Nepali voice OTP (since many users can’t read Devanagari).
    • Result: 30% increase in rural transactions.

Exam Tip

  1. Testing Pyramid: Always explain why unit tests > system tests (speed vs. coverage).
  2. Tools:
    • Android: Espresso + Firebase Test Lab.
    • iOS: XCTest + Xcode Instruments.
    • Cross-platform: Appium + Postman.
  3. App Store Differences:
    • Google Play: Faster approval, more lenient.
    • Apple App Store: Stricter, better revenue share for subscriptions.
  4. Localization:
    • Nepal-specific: Nepali language, Khalti/eSewa payments, cultural holidays.
  5. Post-Release:
    • Crashlytics for bugs, Firebase Analytics for user behavior.
  6. Ethical Testing:
    • Mention privacy laws (Nepal’s Data Privacy Act) and accessibility (WCAG).

Common Exam Questions:

  • "Compare Espresso and XCTest." → Answer: Espresso (Android) uses ViewMatchers, XCTest (iOS) uses XCUIElement.
  • "How would you test Pathao’s surge pricing algorithm?" → Answer: Load test with 10,000 users + A/B test pricing models.
  • "Why was eSewa rejected by Apple?" → Answer: Insecure API calls (no HTTPS).

Visual Summary:

flowchart TD
    A["Mobile App Development"] --> B["Unit Testing"]
    A --> C["Integration Testing"]
    A --> D["System Testing"]
    A --> E["UAT"]
    B --> F["Espresso/XCTest"]
    C --> G["Postman/Appium"]
    D --> H["Firebase Test Lab"]
    E --> I["Beta Release"]
    I --> J["Crashlytics"]
    J --> K["Iterate & Publish"]

Based on the TU BIT syllabus for Mobile Application Development, unit 4.

Discussion

Loading…