QApilot - AI-Powered Mobile App Testing
    Back to Blogs
    Flaky Tests: What They Are, Why Mobile UI Tests Flake, and How to Detect, Quarantine and Fix Them - QApilot Blog

    Flaky Tests: What They Are, Why Mobile UI Tests Flake, and How to Detect, Quarantine and Fix Them

    Summarise with AI

    Key takeaways

    What a flaky test is, how it differs from a broken or failing test, the six causes behind flaky Android and iOS UI tests, and a routine to detect, quarantine and fix them.

    ConceptsFlaky TestsMobile Test AutomationAndroid TestingiOS TestingTest ReliabilityRegression Testing

    Charan Tej Kammara

    Product Marketing Lead

    14 min read

    Flaky tests are automated tests that pass on some runs and fail on others against the same build, with nothing changed in the app or in the test itself. They matter because they turn every red result into a guess, and once a team has to guess, people quietly stop reading failures at all. Picture the team behind a parcel tracking app with an Android build and an iOS build: their nightly regression run shows a different set of red tests each morning, and nobody can say which ones point at a real defect. This guide gives that team a routine they can repeat: confirm the flake, record it, take it out of the release gate with an owner, and fix the cause, which on a phone often sits somewhere a web or unit test never goes.

    What is a flaky test?

    A flaky test is an automated check whose verdict changes between runs of an identical build, even though no one touched the code under test or the test script. Android's own testing documentation puts it plainly: when a test doesn't have a deterministic behavior, it's flaky. So the flaky test meaning people search for comes down to one idea: you cannot predict the outcome, so you cannot trust it.

    Three labels get mixed up in stand-ups, and separating them saves hours:

    • A broken test fails on every single run. The script itself is wrong, so you repair the script.
    • A failing test goes red because the app really changed or regressed. You repair the app.
    • A flaky test flips between green and red while both the app and the script stay frozen.

    One caution belongs right here. A flip can still be a rare, genuine app bug that shows up only under certain timing. Treat "flaky" as a reason to look closer, never as permission to look away.

    Why do flaky tests matter?

    Flaky tests cost trust first and time second. When a handful of checks flip without warning, every red build in the pipeline becomes ambiguous, and engineers learn to hit rerun instead of opening the failure. That habit is exactly how a real regression slips through to the store.

    On mobile, the cost of "just rerun it" is heavier than on a laptop browser. Each rerun claims a real phone or an emulator slot for the length of the suite, so a habit of blind reruns slows the queue for every other job waiting on those devices. Kobiton's guide to random mobile test failures makes the same point about device time and wasted reruns. The parcel team feels it every morning when the nightly batch spills into the working day.

    Why do mobile UI tests become flaky?

    Most flaky mobile tests trace back to six causes: timing and waits, fragile element targeting, system dialogs and notifications, leftover app or device state with shared test data, differences between devices, OS versions and the two platforms, and unstable networks or test infrastructure. Web and unit suites meet some of these, but a phone adds several that a browser tab never shows.

    Timing and waits. The shipment list loads from the network, and the test taps the first parcel before the rows exist. On a fast night it passes; on a slow one it fails. Android's guidance warns that arbitrary sleeps make suites slow or flaky, and that synchronization is a primary source of unstable results.

    Element targeting. A designer renames a button label on the sign-in screen, and a locator built on that visible text now matches nothing, or matches the wrong control. BrowserStack's App Automate stability notes recommend accessibility IDs first and XPath only as a last resort.

    System dialogs. The location permission prompt appears only on a fresh install, so the map test passes on a reused device and fails on a clean one.

    App state and test data. One test reuses an account that a previous test already signed out, so it passes when run alone and fails inside the full suite.

    Device and platform differences. A coordinate tap that lands on the "Track" button on a large Android phone misses it on a smaller iPhone screen.

    Network and infrastructure. Emulators that fail to boot, cloud sessions that drop, and backends that time out all produce red results the app never caused. Kobiton advises waiting for the condition your next action actually depends on rather than for a guessed number of seconds.

    Table 1: Why mobile UI tests flake, and the first fix to try

    Cause What it looks like First fix Android note iOS note
    Timing and waits A tap fires before the parcel list finishes loading; rerun passes Wait on the exact condition the next step needs, never a fixed sleep Espresso idling resources; switch off animations on test phones Explicit waits on element existence or state
    Element locators Sign-in button not found after a label tweak, or a tap hits the wrong row Target stable accessibility or resource IDs; keep XPath for last Resource IDs and Compose test tags Accessibility identifiers
    System dialogs and notifications A permission prompt or banner covers the map screen on some runs Handle known dialogs on purpose; begin from a defined install state Runtime permission dialogs System alerts drawn outside the app
    App state and test data Green alone, red after a sibling test or on a shared login Reset the app and give each test its own account and data Clear app data between cases Reset authorization and app state
    Device, OS and platform differences Green on one handset or platform, red on another Split platform-specific steps; drop coordinate taps OEM skins and OS versions Screen sizes and OS versions
    Network and infrastructure Timeouts, dropped device sessions, emulator boot errors Mock or stabilise backends; retry only infrastructure steps, and log it Emulator or device farm sessions Simulator or device sessions

    How do you detect flaky tests?

    Run the same build again and compare. A test that fails and then passes with nothing changed is a flaky candidate, and a history of status flips across recent runs confirms it. Sauce Labs calls an immediate pass on rerun, with no code change, the most obvious sign of flakiness. Good flaky test detection rests on three habits.

    Rerun on failure and keep the result. Apple's WWDC21 session on diagnosing unreliable code with test repetitions walks through Xcode test plan modes, including retry on failure and repeat until failure. Bitrise documents test steps that rerun failed cases and mark a case flaky when it passes on the second attempt. On the web side, Playwright labels a test "flaky" in its report when the first attempt fails and a retry succeeds.

    Track flips across runs. One rerun tells you little; a pattern tells you a lot. BrowserStack's reporting product applies a "Flaky" Smart Tag based on retry passes and status changes over recent runs, and Bitrise Insights highlights cases that report different outcomes on the same commit.

    Compare evidence from both runs. Put the screenshot, video and device log of the red run beside the green one. For the parcel team, the failed nightly screenshot shows a loading spinner where the shipment list should be. That single image moves the case from "random" to "timing."

    Keep one rule in view: a retry is a detector, not a cure. A retry whose result nobody reads only paints a red build green, a warning the Bitrise guide to flaky tests makes as well.

    How do you handle flaky tests once you find them?

    Give each flaky test a named owner, move repeat offenders out of the release gate into a quarantine where they keep running but cannot block a merge, and set a date to fix or delete them. Flaky test management is mostly ownership and deadlines; tooling only helps once those two exist.

    Several teams describe the same order. Bitrise sets it out as detect, quarantine, then fix the root cause. Momentic's mobile CLI includes a quarantine command so that a quarantined case's failures stop changing pipeline status. Android ships a @FlakyTest annotation that marks a case as non-deterministic, so a run can include or skip it on purpose.

    Quarantine is a waiting room, not a retirement home. If a check in your automated smoke testing suite starts flipping, either fix it quickly or move it into the wider regression run, because a smoke gate that nobody trusts protects nothing.

    Table 2: Quarantine, fix or delete: deciding what to do with a flaky test

    Situation Action Risk if ignored
    A normally steady test flips for the first time Rerun that build, compare screenshots and logs, open a ticket A rare real bug gets waved away as noise
    A release-gate test keeps flipping Quarantine it with an owner and a fix date; keep it running The team learns that red builds mean nothing
    The cause is known (wait, locator, dialog, data) Fix the test inside the current sprint Copy-paste spreads the same weakness into new tests
    The case repeats coverage a stable test already gives Delete it and write down why Upkeep continues with no extra signal
    The failure sits in devices, network or the pipeline Fix the environment; retry infrastructure steps only, with logging Test code gets patched for a problem it never had
    A tool repaired a locator or a retry passed Review the change before it becomes the new baseline Silent fixes bury real regressions

    How do you fix flaky mobile tests at the root?

    Replace fixed sleeps with waits on the condition the next step needs, target elements by stable IDs, plan for system dialogs, start every test from a known state with its own data, keep separate steps where Android and iOS differ, and stabilise the devices themselves.

    Waits. For the parcel list, wait until the first row is present and tappable, not for a fixed pause. On Android, idling resources tell Espresso when the app is busy, and turning off system animations on test phones removes a common race; the guide to flaky Espresso tests covers both. On iOS, explicit waits on element state and accessibility identifiers do the same job, and the article on flaky XCUITest runs explains where retries in test plans help and where they mask the problem.

    Locators. Ask developers to add resource IDs and accessibility identifiers to the controls your tests touch. Text and screen position are the two things a design change alters first.

    Dialogs. Decide how each run begins: fresh install with the location prompt handled by an explicit step, or a device where the permission is granted ahead of time. Either is fine, as long as it is the same every run.

    State and data. Reset the app before each case and give every test its own account, so one sign-out never leaks into another test's morning.

    Platform differences. Swap coordinate taps for element-based actions, and keep a platform-specific step wherever the iOS screen really differs from the Android one.

    Devices. Retire handsets that disconnect often, and keep OS versions on the test pool deliberate rather than accidental.

    Finish with a review rule: every automatic fix, whether a passing retry or a repaired locator, should appear in the report and get a person's approval before it counts. For deeper cause-by-cause help, see the guide to troubleshooting automated mobile tests, and for choosing where these practices live in code, the overview of an automated test framework for mobile apps.

    Where does QApilot fit with flaky mobile tests?

    QApilot is an AI-native mobile testing platform for Android, iOS and Flutter apps that works alongside a team's device cloud and existing frameworks. Its own guidance on reducing flaky mobile tests treats flakiness as something a team reduces on purpose, not something a tool makes disappear.

    Teams record Android (APK) and iOS (IPA) flows into reusable test cases and run them through test plans on supported cloud devices such as BrowserStack and Sauce Labs, or on local devices, with iOS run locally from a Mac with Xcode. The recorder includes keywords for waits (Implicit Wait, Wait till element not found), for alerts, and Reset App for a clean start. Test plan settings cover Auto close Contextual popup, wait time between steps and command timeout, and cross-platform execution supports platform-specific steps where screens differ.

    Execution reports hold screenshots, video, step logs and crash logs, show the recorded screenshot beside the execution screenshot for each step, flag frame freezes in video splits, and let a person rerun from the report or compare two reports for the same plan and device. AI auto-healing handles changed locators only: it tries the element ID, then XPath, then a visual match, then recorded coordinates, tags the step "AI Assisted" and waits for a person to click Update XPath. On Android, the crawler explores the app and builds a knowledge graph of app flows and screens for coverage. Plans can be triggered from CI with the downloaded .sh or .bat script, or scheduled once or daily. If you are still comparing options, the roundup of test automation tools and the guide to mobile testing tools are good next reads.

    Flaky tests FAQ

    What is a flaky test?

    It is an automated check that gives a pass on one run and a fail on another while the build and the script stay exactly the same. Its outcome is not deterministic. That sets it apart from a broken test, which goes red every time, and from a failing test, which goes red because the app genuinely changed.

    What causes flaky tests in mobile apps?

    The usual suspects are steps that fire before a screen or animation is ready, locators tied to text or position, permission prompts and other system dialogs that appear only sometimes, state or accounts shared between cases, gaps between handsets, OS versions and the two platform builds, and shaky networks or test devices.

    How do you detect flaky tests?

    Repeat the run on the identical build. If a case goes red and then green with nothing changed, it is a candidate. Confirm it by watching for status flips across recent runs and by laying the screenshots, video and logs of the red run beside the green one. Retries only help detection when someone records and reads their results.

    How do you handle flaky tests?

    Assign an owner, pull repeat offenders out of the release gate into a quarantine where they still execute but cannot block a merge, and put a fix or delete date on each one. Then repair the cause, most often a wait, a locator, a system dialog, shared state or a platform gap, instead of stacking up more retries.

    Should you retry flaky tests?

    Retries earn their place for spotting flakes and for brief device or infrastructure hiccups, but they are not the repair. Log each retry, label any case that passes on a second attempt as flaky, and schedule the fix. An unread retry turns the build green while the cause, and occasionally a genuine bug, stays exactly where it was.

    Treat a flaky test as a bug in the suite

    Confirm the flake by running the same build again, record it, take it out of the gate with an owner, and fix the cause. Durable tests come from fewer surprises, not from more retries, so review every retry and every automatic repair before you trust a green build.

    Written by

    Charan Tej Kammara

    Charan Tej Kammara

    Product Marketing Lead

    Charan Tej is the Product Marketing Lead at QApilot. He started his career in QA and later pivoted into product management, giving him a hands-on understanding of both testing challenges and product strategy. He holds a Master’s degree from IIM Bangalore and writes about technology, AI, software testing, and emerging trends shaping modern engineering teams.

    Read More...

    Mobile Testing Tools: The Main Types and How to Choose the Right Mix for Android and iOS - QApilot

    Mobile Testing Tools: The Main Types and How to Choose the Right Mix for Android and iOS

    Mobile testing tools cover five separate jobs: writing functional tests, helping more of the team author and maintain them, supplying real devices, measuring performance and checking security. This guide follows one grocery delivery app to show which kind of tool takes each job on Android and iOS, where Appium and device clouds fit, and a trial checklist for picking the next tool your release actually needs.

    Read More
    Automated Smoke Testing for Mobile Apps: What to Include and How It Differs from Sanity and Regression - QApilot

    Automated Smoke Testing for Mobile Apps: What to Include and How It Differs from Sanity and Regression

    Automated smoke testing runs a short set of critical journey checks on every new build to decide whether it deserves deeper testing. This guide follows one ride hailing app to show what a mobile smoke suite should include and leave out on Android and iOS, how smoke differs from sanity and regression testing, and six steps for turning the suite into a CI gate that stops a broken build.

    Read More
    AI Test Automation for Mobile Teams: What It Really Changes, and What It Doesn't - QApilot

    AI Test Automation for Mobile Teams: What It Really Changes, and What It Doesn't

    AI test automation takes over steps that used to need a person each time: repairing broken locators, turning written cases into runnable steps, exploring an app for unscripted flows and replanning around surprises. This guide explains each change on Android and iOS with one food delivery example, shows what your team still owns, and lists six questions to ask any AI test automation tool before a trial.

    Read More

    Get started

    Start Your Journey to Smarter Mobile App QE

    Rethink how your team approaches mobile testing.

    QApilot - Mobile-First Businesses Need Mobile-First App Testing | Product Hunt
    SOC 2 Type 2 compliance badge
    SOC 2: In Progress
    HIPAA compliance badge
    HIPAA: In Progress
    Copyright © 2026 | Powered by QApilot