Mobile Test Automation Best Practices (2026)

Mobile test automation succeeds or fails on discipline. The frameworks are good enough — Appium, Espresso, XCUITest all mature. The teams that succeed have chosen a sensible strategy, built on solid p

June 21, 2026 · 3 min read · Testing Guides

Mobile test automation succeeds or fails on discipline. The frameworks are good enough — Appium, Espresso, XCUITest all mature. The teams that succeed have chosen a sensible strategy, built on solid practices, and committed to maintenance. This guide distills those practices.

The core principles

  1. Favor fast tests. Unit > integration > UI. Aim 70/20/10.
  2. Stable locators. Every flake is a locator problem or a timing problem.
  3. One thing per test. Each test asserts one outcome.
  4. No shared state. Tests run in any order.
  5. Fast feedback. CI runs < 15 minutes ideally.

Locator strategies (in order of preference)

  1. Accessibility ID (iOS) / resource-id (Android) — stable, semantic
  2. Test ID attribute — a11y-friendly testTag (Compose) or contentDescription
  3. Text match — fine for stable text (avoid user-editable)
  4. XPath — last resort, brittle on UI changes

Avoid: index-based (//Button[2]), class-only, or relative-to-parent-index selectors.

Synchronization

Data

Structure

Page Object Pattern


class LoginScreen(val driver: AppiumDriver) {
    private val username = By.id("username")
    private val password = By.id("password")
    private val submit = By.id("submit")

    fun login(user: String, pass: String) {
        driver.findElement(username).sendKeys(user)
        driver.findElement(password).sendKeys(pass)
        driver.findElement(submit).click()
    }
}

Tests become readable; locators change in one place.

Screen Play

For larger apps: tasks, abilities, questions. Tests describe user journeys.

BDD with Gherkin

Natural-language tests if stakeholders read them. Cost is maintenance of step definitions.

CI integration

Flake management

Device strategy

Reporting

Anti-patterns

  1. Recording macros without refactoring. Brittle.
  2. 100% UI test coverage goal. Diminishing returns.
  3. Test every permutation. Boundary cases, not exhaustive.
  4. "Temporary" disabled tests. Permanent decay.
  5. No test for new feature. Coverage gap grows.

How SUSA fits

SUSA generates Appium / Playwright scripts from exploration. These follow many best practices automatically:

The generated scripts are a starting point; teams customize for their domain-specific assertions.


susatest-agent test myapp.apk --persona curious --steps 200 --generate-scripts

Maturity checklist

Automation is a discipline, not a feature. Invest continuously; reap over quarters.

Test Your App Autonomously

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.

Try SUSA Free