Testing Android applications

Android without internet: testing network failures and sync

A user completes a form, taps Save, and the phone loses its connection at that moment. Testing an Android app means checking what remains on the device, what the server received, and what the user was told. This approach helps teams whose apps handle forms, orders, or records away from a stable office connection.

First decide what should work without a network

A network outage does not automatically create a requirement for full offline functionality. A product may allow only reading saved records, preserve a draft form, or require a connection for every write. A valid test follows the agreed behaviour. If submission requires internet access, a clear rejection that preserves the input may be the expected outcome.

Android documentation for offline-first apps describes apps that can perform all or selected core functions without internet access. Offline reading does not require offline writing. For writes, it describes online operations, queues, and local storage followed by later submission.

For each important action, record where success is confirmed. “Saved on the phone” and “sent to the server” are different states. If the interface labels both with a green “Done” message, users may leave assuming their colleagues can already see the change.

Build scenarios around the point of interruption

One test in flight mode does not cover a slow connection or a lost server response. A failure before submission has a different result from a failure after a server write when the phone receives no confirmation. Prepare separate situations:

For each situation, define the expected screen content, the state of the change, and the next available action. Prepare a way to verify the actual write on the test server. Checking a message in the app alone cannot show whether the data arrived or was created twice.

Separate a slow network from complete disconnection

On a slow connection, the app may be waiting while the user continues working. In an isolated environment, limit bandwidth, add latency, or interrupt a selected request with a network testing tool. Record the settings so a colleague can reproduce the same condition. The current signal strength in a room is not a stable test condition.

Check whether the interface remains usable and clearly shows the operation in progress. Users may tap Save again, move to another screen, or cancel the action. The expectation depends on the product, but the test must confirm the result of every allowed step. Cancelling the wait in the interface does not necessarily mean the server will no longer start or complete the write.

Define the time limit from the app’s requirements. A test should not report a failure simply because a response took longer than on a local network. Once the agreed limit is exceeded, however, check the fallback state and the ability to continue safely instead of leaving an endless loading indicator.

Also add a delayed response after the user has opened a different record. Data from the original request should not overwrite the new screen’s content. When users refresh manually during an ongoing load, watch the order of responses. An older response may arrive last, so compare the final value with the server state and the rule for data freshness.

Switching between Wi-Fi and mobile data

Start a read or write over Wi-Fi and switch to mobile data while it is running. Repeat in the other direction and with a new connection that exists but cannot reach the server. Check the operation’s outcome, the displayed state, and any repeated request.

Android documentation on network state explains that a network configured for internet access may lack actual connectivity. Even validated internet access can fail later. A Wi-Fi icon therefore does not prove that the app’s server is reachable.

Check switching on a selected real device with a suitable test connection. An emulator helps control failures reproducibly, but does not replace every condition on a phone and mobile network. Choose device coverage according to risk, as described in Emulator or real device.

Example scenario: a service record awaits submission

Imagine a field service app that is required to preserve changes offline. A technician opens test record S-214, disconnects the phone, and adds the note “Seal replaced”. The app should save the content locally and mark it as pending submission. The server should still hold the original record at this point.

The technician leaves the app and reopens it. The note and its pending status should remain. When connectivity returns, the test observes submission and then checks the content on both the server and in the app. The synchronisation confirmation should match the agreed server acknowledgement, rather than merely detecting that the phone is online.

Next, prepare a lost-response variant. The server saves the note, but the device remains uncertain and retries. The expected outcome of this example scenario is one resulting write of the note. The number of network attempts may be higher, so check the business outcome and the operation identifier.

Prepare this variant with a controlled intervention on the test server or in a test proxy. The request must reach the server and the write must be confirmed in its storage. Hold or drop only the response travelling back to the phone. Turning off Wi-Fi after tapping Save is insufficient, as it may interrupt submission itself. Include the operation identifier and proof of the write before the retry in your evidence.

When connectivity returns, also check the transition from pending submission to confirmed. A correct note on the server is insufficient if the phone still reports an error or keeps sending it. In this example, the note should not be added twice or cause another business effect. One outcome does not mean only one HTTP request.

Request queues and retries

If the app uses a queue of pending changes, check its behaviour with several records. One invalid record should not hide the state of the others without explanation. For dependent operations, such as creating a record and adding its attachment, confirm the order against the application contract.

Processing the same operation repeatedly without another business effect is called idempotency. Verify it on the server. Blocking a second tap on the phone alone does not cover retries after an outage or restart. If the system uses an operation identifier to recognise duplicates, check that the identifier stays the same between attempts.

WorkManager supports execution constraints and retries, including network availability. Meeting the constraints does not promise immediate execution. If the app uses this mechanism, check its settings and wait for an observable result within an agreed time window.

Distinguish a temporary network failure from rejection due to permissions or invalid data. Repeating an invalid write indefinitely does not fix it. The test should show whether a failed record can be corrected, whether its state is understandable, and what happens when authentication expires.

Conflicts between the phone and the server

While the technician edits S-214 offline, a dispatcher may change the same value on the server. Define the conflict rule before testing. The product may reject a stale change, merge independent fields, or ask the user to decide. The last write is not automatically the right choice for every data type.

Prepare the same initial state, make different changes, and restore connectivity. Check the final value on both sides and the explanation in the app. Separately try changing different fields, changing the same field, and deleting the record on the server. Automatically merging a note into a deleted record may conflict with business rules.

For versioned records, record the version the phone read and the version sent with the change. The test can then distinguish a conflict-detection error from incorrect subsequent display. A detailed conflict matrix can be checked in the data layer without repeating the entire flow through the phone.

Returning to the app, restarting, and the limits of testing

Distinguish moving to the background, recreating a screen, ending the process, and restarting the device. These are different situations. When ending the process normally, retain app data to verify recovery of the pending state. Clearing data would create a different test.

Record a force stop through system settings as a separate variant. Do not automatically expect the same background-work behaviour. After reopening, verify that content is preserved and work continues according to the product contract. Also include signing out so a pending change from one account does not end up under another account.

Isolated tests can check queue rules, duplicates, and conflicts. A smaller selection of complete scenarios on a device also checks local persistence, the interface, and returning connectivity. These checks cannot predict every mobile carrier’s behaviour, but they provide reproducible evidence for specific states.

On failure, save the time of the network change, record and operation identifiers, the pending state, and responses from the test server. Include the app version and how the process was ended. Collect records through approved diagnostics without sensitive form content. A screenshot of an error message alone usually cannot distinguish a lost response from a request that was never sent.

What the team will know after testing

The outcome should show which actions survive an outage, which require connectivity, and how users recognise a pending change. When something fails, the team can compare local content, server state, and attempt history. That helps decide whether to fix submission, data recovery, or the interface message.

Start with one important write and agree on its states from draft to server acknowledgement. Check a failure before the write, a lost response, and returning to the app. Add queues, conflicts, and more devices according to how the product actually handles data.

Related topics

You might also be interested in

We will verify the decisive scenarios on real devices

Automated testing of native and hybrid Android applications, with critical runs on physical or cloud devices.