A repository test should verify how the app resolves local and remote data, not merely that a mocked method was called. Offline fixtures are useful when they make freshness, writes, retries, and conflicts reproducible.
Start with the repository's contract. State what callers may assume about returned data, pending changes, and failures before building the test doubles.
Control both data sources and time
Provide a known local dataset, a scripted remote response, and controlled timing where retries or freshness matter. Include stable operation identifiers so repeated execution can be distinguished from a new user action.
Flutter's offline-first guidance describes combining local and remote sources through a repository. Your tests still need to establish the exact policy chosen for this product.
Exercise a fictional offline request edit
Suppose the local store contains request version 4. A staff member edits its note while disconnected. The repository saves the local change and records a pending operation. On reconnect, the remote fixture reports version 5 with a changed assignment.
The expected outcome depends on the conflict policy: merge independent fields, require review, or reject the stale change while preserving the draft. Write that expectation explicitly. A test that merely expects any success value will miss the important decision.
Add remote timeout, unauthorised response, malformed payload, missing record, duplicate acknowledgement, and local-write failure. Check local state, queue state, emitted presentation data, and remote attempts. A correct stream emission does not prove the pending operation was safely persisted.
Keep fixtures realistic enough to challenge assumptions
Use two users and two workspaces where ownership matters. Include a record with an optional value absent and an unknown server status. Avoid fixtures so tidy that they encode every assumption the implementation already makes.
Keep test setup readable and small. A long shared fixture file can hide why a case exists. Name the business condition in each test and preserve only the fields needed to establish it.
The tradeoff is speed versus fidelity. Repository tests can isolate logic and run deterministically, but they do not prove real database durability, plugin behaviour, or network integration. Add the appropriate integration or device check for those boundaries rather than stretching a fake into a claim about the whole app.
The Social App portfolio page documents offline and mobile engineering work. This repository scenario is a proposed test design, not a description of its private test suite.
Questions about offline repository tests
Should a fake return the same response every time?
Only for cases where that is the intended condition. Script sequences to expose stale reads, retries, and recovery.
Is checking the final value enough?
Often no. Pending state, intermediate emissions, stored operations, and duplicate effects can matter to the contract.
What should the first fixture cover?
Cover one local edit followed by a remote conflict, with a named expected policy. Bring ambiguity in that policy to a Flutter data-layer review.