Autosana Logo
    Autosana
    • SandboxesBeta
    • Enterprise
    • Pricing
    Contact salesTry for free
    Resources

    Blog

    Insights on automated testing and QA best practices.

    BlogProduct updatesCase studies
    AllComparisonsBest ToolsMobile TestingAI TestingTesting Fundamentals

    Fix bugs, not tests.

    Talk to an expert.

    Book 30 minutes with our team. We'll show you Autosana running on your app.

    Contact sales

    Start building.

    Describe a user journey and watch an agent run it on iOS, Android, and web.

    Try for free
    Autosana

    Catch bugs before your users do.

    Try for free

    Product

    • Platform
    • Use cases
    • Enterprise
    • Pricing

    Resources

    • Docs
    • Case Studies
    • Product Updates
    • Blog

    Company

    • Contact sales
    • Careers
    • LinkedIn

    Trust

    • Status
    • Security
    • SOC 2 Type 1 · Type 2 in review
    • Backed by

    © 2026 Autosana. All rights reserved.

    Autosana Logo
    Autosana
    • SandboxesBeta
    • Enterprise
    • Pricing
    Contact salesTry for free
    Written by
    Read time
    Published
    Autosana

    Catch bugs before your users do.

    Try for free

    Product

    • Platform
    • Use cases
    • Enterprise
    • Pricing

    Resources

    • Docs
    • Case Studies
    • Product Updates
    • Blog

    Company

    • Contact sales
    • Careers
    • LinkedIn

    Trust

    • Status
    • Security
    • SOC 2 Type 1 · Type 2 in review
    • Backed by

    © 2026 Autosana. All rights reserved.

    Autosana Logo
    Autosana
    • SandboxesBeta
    • Enterprise
    • Pricing
    Contact salesTry for free
    Back to Blog
    Blog

    Clean state vs warm state: when to reset the simulator between runs

    Reset the iOS Simulator or keep state? What simctl erase, pm clear, Quick Boot and reinstalls actually clear, where state hides, and when warm state is the test.

    Written by
    Yuvan Sundrani
    Read time
    8 min read
    Published
    December 1, 2026
    Clean state vs warm state: when to reset the simulator between runs

    Key Takeaways

    • Android Emulators save a Quick Boot snapshot on exit and load it on start by default, so app state carries over between sessions unless you turn that off.
    • Auto Backup restores app data on every install, adb install included, so uninstall and reinstall can bring old data back.
    • Apple doesn't document whether iOS Keychain items survive deleting an app; an Apple engineer has said they did, so a reinstall may still find a saved session token.
    • Android Test Orchestrator's clearPackageData runs pm clear after every test, and Google lists the restart cost alongside the isolation.
    • Reset to the smallest scope that removes the state under suspicion; full device erases are for the cases where you can't name it.

    Reset the simulator when leftover state could change the result and you can't clear that state more narrowly; keep state when the state is what you're testing. Most flakiness from earlier runs comes from layers a reinstall doesn't touch.

    App state that survives a reinstall

    StateApp restartApp reinstallDevice erase
     
    In-memory caches, view stateClearedClearedCleared
    Databases, prefs, filesKeptCleared, then possibly restored by Auto Backup (Android)Cleared
    iOS Keychain itemsKeptNot documented; observed to persistCleared
    Runtime permissionsKeptReset on Android; reset on iOS only via simctl privacy resetCleared
    Emulator Quick Boot snapshotKeptKeptCleared with -wipe-data
    Server-side account and dataKeptKeptKept

    Auto Backup. Android's Auto Backup guide states that data is restored whenever the app is installed, including by adb install, and that restore happens after the install and before the app can launch.

    On a device or emulator with a backup account, "reinstall for a clean state" can relaunch into the previous session. Setting android:allowBackup="false" in the debug manifest removes that path, with a documented caveat that some manufacturers still allow device-to-device transfer.

    Keychain. Apple's keychain documentation doesn't specify what happens to items when an app is deleted. An Apple DTS engineer has described items persisting after deletion as expected behavior. A test that deletes the app to log the user out can still find a valid token on the next launch.

    The server. No device reset touches the account. A test that completes onboarding leaves the account onboarded; the next run on a fresh device skips the screens it was meant to check.

    xcrun simctl erase vs pm clear vs Quick Boot

    # iOS Simulator
    xcrun simctl terminate booted com.example.app        # process only
    xcrun simctl uninstall booted com.example.app        # app container
    xcrun simctl privacy booted reset all com.example.app
    xcrun simctl shutdown booted && xcrun simctl erase booted   # whole device

    # Android
    adb shell am force-stop com.example.app              # process only
    adb shell pm clear com.example.app                   # "Delete all data associated with a package"
    emulator @Pixel_8_API_36 -no-snapshot-load           # cold boot, ignore the saved state
    emulator @Pixel_8_API_36 -wipe-data                  # factory state for the AVD

    The emulator flags come from Google's command-line reference. -wipe-data returns the AVD to its initial state, with all installed apps and settings removed, but leaves sdcard.img alone. -no-snapshot-save boots from the snapshot without saving changes, and -no-snapshot disables Quick Boot load and save entirely.

    For per-test isolation in instrumented suites, the Android Test Orchestrator docs describe clearPackageData, which runs pm clear after each test:

    testInstrumentationRunnerArguments clearPackageData: 'true'

    The same page notes the cost: the Orchestrator restarts the app after each test, which can increase execution time.

    A decision tree for state between runs: if the state is the subject of the test, keep it; if you can name the leftover state, clear only that layer with pm clear, a privacy reset or a keychain wipe in the app; if you can't, erase the device or start a fresh sandbox, and always seed server-side data per run
    A clean device for every run. Try Autosana for free.

    Emulator cold boot vs Quick Boot snapshot time

    Google's snapshot docs say an AVD can boot up to 10 times faster from a Quick Boot snapshot than from a cold boot, and that any emulator, system image or AVD settings update resets the saved state. A cold boot per test buys certainty at that multiple.

    A middle path keeps the speed: build a golden snapshot with the system settings, accounts and permissions the suite expects, load it per run with -snapshot <name>, and clear only the app with pm clear. Loading a snapshot overwrites system, user data and SD card images with their saved contents, so every run starts from the same warm device.

    On iOS, launch arguments reset app-level state without touching the device. Apple's UserDefaults argument domain holds values passed on the command line, is volatile, resets with each launch and overrides the app's own settings. XCUIApplication.launchArguments and launchEnvironment carry a reset flag that the app's startup code honors by clearing its stores and its own keychain items.

    When should a test keep app state?

    Some bugs only exist in warm state, and resetting before those tests deletes the bug along with the noise:

    • Upgrades. Data written by the previous release, read by the new one. The upgrade-in-place test depends on not resetting.
    • Returning users. Onboarding should be skipped, a session restored, a draft recovered.
    • Expiring sessions. A token saved yesterday that the server now rejects.
    • Cached content. What renders before the network answers.

    For these, the reset happens before the setup steps, never between setup and assertion.

    What each reset clears, layer by layer: an app restart clears memory only; pm clear or uninstall clears app data; a privacy reset clears permissions; a device erase clears the device but not the server; a new Autosana sandbox with a hook-created account clears both

    Autosana for test state isolation

    Autosana is an AI end-to-end testing agent for iOS, Android and web apps. We make the reset scope explicit: one command per level on the device, a new device per sandbox, and hooks for the server-side account.

    Autosana key features for test isolation

    1. One command per reset level. autosana sandbox launch --cold restarts the app and keeps its data. launch --reset reinstalls it, with the sandbox's permission grants applied again, and upload --reset installs a new build clean.
    2. A separate device per sandbox. Per our sandbox docs, idle sandboxes are returned after 30 minutes and none lasts beyond 12 hours, so leftover device state never outlives the session.
    3. A fresh account per session. Our guide to isolated, repeatable suites uses a setup hook that creates a test account with seeded data and a teardown hook that deletes it. With Run flows in parallel on, each test gets its own session and its own hooks; without it, tests in a suite share one session.
    Autosana suite results with pass and fail per test and the run duration

    Setup hooks run before a flow and teardown hooks after it, which is where a reset or data cleanup goes. Source: Autosana Hooks docs videoSuite results after isolated parallel runs: pass or fail per test, and the run's duration. Source: Autosana docs video.

    Autosana customer results

    • Lucra (white-label social competition platform) automated about 70% of a 250-step regression suite in under 15 hours of effort. See the Lucra case study.
    • Ziina (UAE financial platform) automated 69% of its E2E suite and cut active manual regression from about 12 hours to about 1 hour.

    Credentials for those accounts are covered in test credentials for AI agents.

    A fresh device per PR in CI is the subject of parallel iOS simulator testing in CI.

    Where Autosana fits less well

    • Whether launch --reset clears iOS Keychain items follows iOS behavior, which Apple doesn't document; start a new sandbox for a guaranteed clean device.
    • Server-side state isn't reset for you; it takes the setup and teardown hooks above.
    • A launch configuration restart keeps keychain, sessions and databases by design.

    Why use Autosana for test state isolation?

    • The reset level is visible in the command. Cold launch, reinstall and clean install are separate flags.
    • No device outlives its session. Leftover device state ends with the sandbox.
    • Parallel runs don't share accounts. Hooks give every session its own seeded user.
    • Warm-state tests stay possible. Suites can share one session when a later test depends on an earlier one.
    • Costs nothing to start. Pay as you go includes up to 1,000 AI actions each month.
    Flaky state, gone. Try Autosana for free.

    Conclusion

    Every test answers one question before it starts: is leftover state the subject of this test? If yes, keep it and set it deliberately. If no, clear the narrowest layer that holds it, and seed the server per run.

    Full erases and cold boots stay for the failures nobody can trace to a layer, because that's what their cost buys. Flakiness that survives all of this is usually timing; see fixing flaky tests in GitHub Actions.

    FAQs

    1. How do I reset the iOS Simulator completely?

    Shut it down, then run xcrun simctl erase on the device.

    2. Does uninstalling an Android app give a clean state?

    Not always. Auto Backup restores data on reinstall, including adb install.

    3. What does clearPackageData do?

    Android Test Orchestrator runs pm clear after each test, removing the app's data.

    4. Do iOS Keychain items survive deleting the app?

    Apple doesn't document it; items have been observed to persist.

    5. Why does my emulator keep app state after restarting?

    Quick Boot saves a snapshot on exit and loads it on start by default.

    6. Does a new Autosana sandbox start from a clean device?

    Each sandbox is a separate device, returned after 30 idle minutes.

    Sources

    • Android Developers: Back up user data with Auto Backup
    • Android Developers: AndroidJUnitRunner and Test Orchestrator

    ‍

    Fix bugs, not tests.

    Talk to an expert.

    Book 30 minutes with our team. We'll show you Autosana running on your app.

    Contact sales

    Start building.

    Describe a user journey and watch an agent run it on iOS, Android, and web.

    Try for free
    Autosana

    Catch bugs before your users do.

    Try for free

    Product

    • Platform
    • Use cases
    • Enterprise
    • Pricing

    Resources

    • Docs
    • Case Studies
    • Product Updates
    • Blog

    Company

    • Contact sales
    • Careers
    • LinkedIn

    Trust

    • Status
    • Security
    • SOC 2 Type 1 · Type 2 in review
    • Backed by

    © 2026 Autosana. All rights reserved.