How to Write Test Cases for Offline Mode (With Examples)

How to Write Test Cases for Offline Mode (With Examples): Core Principles

April 03, 2026 · 15 min read · How-To Guides

How to Write Test Cases for Offline Mode (With Examples): Core Principles

Writing test cases for offline mode requires a shift from typical online‑centric scenarios to situations where network connectivity is absent, intermittent, or degraded. The goal is to verify that the application continues to deliver core functionality, preserves data integrity, gracefully handles UI elements that depend on remote services, and recovers smoothly when connectivity returns. A well‑designed offline‑mode test suite catches crashes, ANRs, dead buttons, data loss, and misleading user feedback before they reach production.

The first step is to treat offline mode as a distinct feature area rather than an after‑thought. Identify every user flow that may be executed without a network—login, content browsing, form submission, media playback, settings changes, and any background sync. For each flow, enumerate the assumptions the code makes about network availability and replace those assumptions with explicit checks or fallbacks. This mindset drives the creation of test cases that are both high‑signal (they expose real defects) and maintainable (they map cleanly to requirements).

How to Write Test Cases for Offline Mode (With Examples): Anatomy of a High‑Signal Test Case

A test case that reliably uncovers offline‑mode issues follows a consistent structure. Each element serves a purpose: it makes the case reproducible, isolates variables, and clarifies the pass/fail criterion.

Test‑Case ID

A unique identifier (e.g., OFF‑001) enables traceability to requirements, test‑management tools, and change‑impact analysis. Use a prefix that signals the feature area (OFF for offline mode) and a sequential number.

Preconditions

Preconditions capture the exact state the device or browser must be in before execution. For offline mode this typically includes:

Steps

Steps are the atomic actions a tester or automation script performs. They should be imperative, concise, and free of ambiguity. Include any necessary waits or verification points. For example:

  1. Launch the app from the home screen.
  2. Navigate to the “My Orders” screen.
  3. Tap the “Refresh” button.
  4. Observe the UI for a loading indicator.
  5. Verify that a toast message reads “No internet connection”.

Expected Result

The expected result describes the observable outcome after the final step. It must be testable and unambiguous. For offline scenarios, expected results often involve:

Postconditions (optional)

Postconditions reset the device to a clean state for the next test, such as re‑enabling Wi‑Fi, clearing app data, or rebooting the emulator. Including them prevents state leakage that could mask defects.

Attachments / Logs

Link to relevant logs, screenshots, or video captures. Automated frameworks can attach logs automatically; manual testers should note where to find them.

How to Write Test Cases for Offline Mode (With Examples): Positive, Negative, Edge, and Boundary Cases for Offline Mode

Categorizing test ideas helps ensure coverage across the spectrum of possible behaviors.

#### Positive Cases

Positive cases verify that the application works as intended when offline, assuming the offline mode feature is correctly implemented. Examples:

#### Negative Cases

Negative cases check that the app does not perform prohibited actions when offline. Examples:

#### Edge Cases

Edge cases explore unusual but plausible conditions that sit at the limits of normal operation. Examples:

#### Boundary Cases

Boundary cases focus on limits of data, timing, or resource usage. Examples:

How to Write Test Cases for Offline Mode (With Examples): Building the Test Matrix

A test matrix translates the categorized ideas into concrete, executable items. Below is a worked example for a typical offline‑first mobile banking app that supports account balance viewing, fund transfers, bill payments, and profile updates. The table lists 22 test cases; each row includes ID, preconditions, steps, and expected result.

IDPreconditionsStepsExpected Result
OFF‑001App v2.3.1 installed; user logged in; airplane mode ON; Wi‑Fi & cellular OFF1. Open app → 2. Navigate to “Accounts” tab → 3. View balanceBalance shown matches last synced value; no network request logged; UI shows “Offline” badge
OFF‑002Same as OFF‑0011. Open app → 2. Tap “Transfer” → 3. Enter amount and recipient → 4. Tap “Submit”Transfer form accepts input; submission shows “Saved for later sync” toast; transaction appears in “Pending” list; no network call made
OFF‑003Same as OFF‑0011. Open app → 2. Navigate to “Bills” → 3. Tap “Add New Bill” → 4. Fill details → 5. Tap “Save”Bill saved locally; appears in “My Bills” list with a sync icon; no network traffic
OFF‑004Same as OFF‑0011. Open app → 2. Go to “Profile” → 3. Change “Display Name” → 4. Tap “Save”Name change stored locally; profile screen reflects new name instantly; offline indicator present
OFF‑005Same as OFF‑0011. Open app → 2. Attempt to log outLogout button disabled; tooltip reads “Requires internet to sign out”; user remains logged in
OFF‑006Same as OFF‑0011. Open app → 2. Navigate to “Settings” → 3. Toggle “Biometric Login” ONSetting change saved locally; toggle reflects new state; no network request
OFF‑007Same as OFF‑0011. Open app → 2. Start video tutorial → 3. Play 10 secondsVideo plays from cached asset; playback continues without buffering spinner
OFF‑008Same as OFF‑0011. Open app → 2. Pull‑to‑refresh on “Accounts” screenRefresh animation stops after 800 ms; banner shows “No internet connection”; account list unchanged
OFF‑009Same as OFF‑0011. Open app → 2. Receive push notification (sent via FCM while offline)Notification stored; appears in notification tray; tapping opens app and shows relevant screen
OFF‑010Same as OFF‑0011. Open app → 2. Navigate to “Transfer” → 3. Enter amount exceeding daily limit → 4. Tap “Submit”Input rejected with inline error “Amount exceeds limit”; no network call; transaction not added to pending list
OFF‑011Same as OFF‑0011. Open app → 2. Begin transfer → 3. Switch airplane mode OFF (online) after 2 seconds → 4. Wait for syncTransfer automatically retries; success toast appears; transaction moves from pending to completed; network call observed
OFF‑012Same as OFF‑0011. Open app → 2. Begin transfer → 3. Switch airplane mode OFF after 2 seconds → 4. Immediately toggle airplane mode ON againTransfer remains in pending state; no duplicate submission; retry occurs once connectivity stable
OFF‑013Same as OFF‑0011. Open app → 2. Fill profile form with 200‑character bio → 3. Tap “Save”Bio saved locally; character counter shows remaining; UI accepts input; no network traffic
OFF‑014Same as OFF‑0011. Open app → 2. Attempt to upload profile picture (5 MB) while offlineUpload button shows error “Network required”; image not added to queue
OFF‑015Same as OFF‑0011. Open app → 2. Navigate to “Statements” → 3. Request last 3 months (requires server)Message appears: “Statement retrieval needs internet”; cached statements from last sync remain visible
OFF‑016Same as OFF‑0011. Open app → 2. Enable “Data Saver” mode → 3. Attempt to view transaction detailsDetails load from local cache; images shown as placeholders; no high‑resolution fetch
OFF‑017Same as OFF‑0011. Open app → 2. Rapidly tap “Refresh” button 10 timesUI shows only one offline banner; no flood of toast messages; app remains responsive
OFF‑018Same as OFF‑0011. Open app → 2. Leave app in background for 30 minutes with airplane mode ONApp state preserved; returning to foreground shows same offline screen; no crash or ANR
OFF‑019Same as OFF‑0011. Open app → 2. Navigate to “Help Center” → 3. Search for term (requires online)Search field shows hint “Search unavailable offline”; results list shows cached FAQs only
OFF‑020Same as OFF‑0011. Open app → 2. Go to “Settings” → 3. Tap “Clear Cache”Local cache cleared; offline indicators persist; app does not crash; reopening shows empty state where data previously cached
OFF‑021Same as OFF‑0011. Open app → 2. Attempt to add a new payee (requires server validation)Add payee button disabled; tooltip “Need internet to validate payee”; existing payees list unchanged
OFF‑022Same as OFF‑0011. Open app → 2. Simulate low storage (via adb shell cmd battery set status 2 and fill storage) → 3. Try to save a new billSave fails with toast “Insufficient storage”; no bill added; app remains usable

*Notes*: Steps that involve toggling airplane mode can be performed via the UI or using adb shell svc wifi disable && adb shell svc data disable. For web tests, Chrome DevTools → Network → Offline achieves the same state.

How to Write Test Cases for Offline Mode (With Examples): Data Setup and Environment Preparation

Reliable offline testing hinges on reproducible data and controllable network conditions.

#### Android

#### iOS

#### Web (Chrome/Firefox)

#### General Tips

How to Write Test Cases for Offline Mode (With Examples): Manual Execution vs Automated Scripts

Both manual and automated approaches have merit. The table below contrasts them across key dimensions relevant to offline‑mode testing.

DimensionManual TestingAutomated Testing
Setup speedQuick for ad‑hoc checks; requires device handling each timeInitial script development takes time; subsequent runs are fast
RepeatabilityHuman error can cause missed steps; depends on tester diligenceHighly repeatable; same steps executed identically each run
Exploratory flexibilityTester can deviate, notice odd UI glitches, try unconventional pathsLimited to scripted paths unless combined with exploratory frameworks
CostLow upfront, higher ongoing laborHigher upfront (framework, device lab), lower marginal cost per execution
Coverage of edge casesGood for discovering unexpected interactionsExcellent for regression; can stress boundaries with loops and data generators
Tooling requiredDevice, possibly USB cableTest framework (Appium, Espresso, XCTest, Playwright), device cloud or local emulators, CI integration
Feedback cycleImmediate visual feedback; tester can annotate screenshotsDepends on test runner; logs and screenshots need to be parsed
Suitability for offlineIdeal for verifying UI text, toast messages, and sensory feedbackIdeal for verifying absence of network calls, data persistence, and sync logic

A balanced strategy uses manual testing for early‑stage validation of new offline flows and exploratory checks, while automation guards against regressions and validates large data sets.

How to Write Test Cases for Offline Mode (With Examples): Prioritization and Traceability

Not all test cases carry equal risk. Prioritization ensures limited testing time focuses on the scenarios most likely to cause user‑visible harm or revenue loss.

#### Risk‑Based Priority Levels

Assign each test case a priority label in the test‑management tool. During a sprint, execute all P0 and P1 cases; schedule P2 for nightly runs; reserve P3 for weekly exploratory sessions.

#### Traceability Matrix

Link each test case to one or more requirements (user stories, design specs, or regulatory clauses). A simple matrix helps answer “If this requirement changes, which tests are affected?” and “Does every requirement have at least one verifying test?”

Requirement IDDescriptionCovered By Test IDs
REQ‑OFF‑01Display cached data when no networkOFF‑001, OFF‑008, OFF‑016
REQ‑OFF‑02Queue user‑initiated actions for later syncOFF‑002, OFF‑003, OFF‑004, OFF‑005
REQ‑OFF‑03Prevent prohibited online‑only actions offlineOFF‑006, OFF‑007, OFF‑011, OFF‑012
REQ‑OFF‑04Notify user of connectivity loss clearlyOFF‑008, OFF‑009, OFF‑015, OFF‑019
REQ‑OFF‑05Handle storage limits gracefullyOFF‑021, OFF‑022
REQ‑OFF‑06Preserve app state across background/offlineOFF‑010, OFF‑013, OFF‑014, OFF‑018
REQ‑OFF‑07Recover and sync queued actions on reconnectOFF‑002 (retry), OFF‑003 (retry)

Maintain this matrix in a spreadsheet or a dedicated traceability plugin; update it whenever a requirement is added, modified, or removed.

How to Write Test Cases for Offline Mode (With Examples): Leveraging Autonomous Exploration (SUSA) to Augment Manual Cases

Modern QA workflows benefit from combining scripted test cases with intelligent, self‑directed exploration. SUSA (SUSATest) is an autonomous QA platform that, given an APK or a web URL, drives the application through realistic user interactions without pre‑written scripts. It models several personas—curious, impatient, novice, accessibility‑aware, power user, and even adversarial—to uncover issues that scripted cases might miss.

When applied to offline‑mode testing, SUSA can:

  1. Discover hidden navigation paths that lead to screens requiring network calls but are not covered in the manual matrix (e.g., a deep‑linked promotional banner that attempts to fetch a video).
  2. Vary timing of connectivity loss by toggling airplane mode at random points during a session, revealing race conditions between UI state changes and background sync tasks.
  3. Test multiple personas simultaneously; for example, the “impatient” persona may rapidly tap buttons while offline, exposing toast‑spamming or UI lock‑up issues that a methodical manual tester might not trigger.
  4. Generate regression artifacts; after each run, SUSA exports Appium scripts for Android and Playwright scripts for the web, capturing the exact sequences it exercised. These scripts can be added to the automated suite, continuously expanding coverage.
  5. Track learning across sessions; the platform remembers which screens have been visited and which actions led to dead ends, so subsequent runs focus on unexplored areas, increasing efficiency over time.

To invoke SUSA for an offline‑mode test, first ensure the device or emulator is in the desired network state (airplane mode on). Then run the CLI:


pip install susatest-agent   # if not already installed
susatest run \
    --app ./my‑app.apk \
    --offline \
    --personas curious impatient power \
    --output-dir ./susa‑run‑2025‑09‑26 \
    --generate‑scripts

The --offline flag tells SUSA to disable network before launching the app and to keep it disabled throughout the session. The resulting scripts appear under ./susa‑run‑2025‑09‑26/scripts and can be committed to the repository alongside hand‑written Appium or Playwright tests.

How to Write Test Cases for Offline Mode (With Examples): Checklist for Reviewing Offline‑Mode Test Suites

Before signing off a test suite, run through this concise checklist to confirm that it addresses the most common sources of offline‑mode defects.

If any item is unchecked, revisit the corresponding test cases or add new ones to fill the gap.

How to Write Test Cases for Offline Mode (With Examples): Closing Takeaways

Writing effective test cases for offline mode is a disciplined exercise in defining precise preconditions, scripted steps, and observable expectations. By decomposing the feature into positive, negative, edge, and boundary scenarios, and by recording them in a structured matrix, teams gain repeatable coverage that catches data‑loss, sync faults, and misleading UI before they reach users. Pairing these manually crafted cases with autonomous exploration—using tools like SUSA—extends reach into unexpected pathways and generates reusable regression scripts. Prioritization based on risk, coupled with a traceability matrix, ensures that testing effort aligns with business impact and regulatory demands. Finally, a concise review checklist guards against common oversights such as hidden network calls or inadequate offline feedback. Apply these principles consistently, and your offline‑mode test suite will become a reliable safety net for any application that must stay useful when the network disappears.

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