Separate Swift and Dart tests answer different questions. Native tests can exercise SDK adaptation and resource rules, while Dart tests can verify feature state and user recovery without loading the real native implementation.
Keep a shared behavioural contract between them. Passing both isolated suites does not prove the message boundary, registration, or real device lifecycle works, so add focused integration evidence for those seams.
Define what each layer owns
The Swift side may own native permissions, SDK calls, files, and resource cleanup. The Dart side may own presentation state, cancellation intent, business decisions, and result routing. Specify the input, success, absence, cancellation, and error meanings each side must preserve.
Flutter's plugin testing guide describes native, Dart, and integration testing roles. Use those categories to select meaningful checks rather than duplicating every assertion in every suite.
Test a fictional native recording feature
Suppose Swift starts and stops a recording session while Dart displays progress and preserves the resulting attachment. Native fixtures can verify permission-denied mapping, session cleanup, repeated stop, and file-finalisation failures.
Dart fixtures can verify idle, starting, recording, stopping, cancelled, and failed states as defined by the product. Test navigation away, account change, and a late result from an old session. Do not let a mocked success stand in for evidence that a real audio file was created.
Integration checks should exercise the actual generated or channel contract, native registration, result types, and supported device behaviour. Name the device and build version before execution. This article proposes the matrix and claims no completed device test.
Keep fixtures aligned without hiding differences
Use common scenario names and expected semantics, but retain native-specific constraints where they matter. A Swift SDK failure may need a stable Dart category rather than an identical exception representation.
Run tests around contract changes together. A nullable field added on one side can alter a failure path even if ordinary success still works. Keep generation and build configuration reproducible so another engineer can repeat the bridge check.
The tradeoff is speed versus confidence at the seam. Isolated tests are fast and precise about local logic, while integration tests reveal mismatched assumptions but cost more setup. Use the smallest combination that covers the actual boundary and lifecycle risk.
The Social App case study documents Flutter and native Swift work, including an iOS offline-messaging layer. This recording feature is fictional and does not describe its private tests or implementation.
Questions about Swift and Dart tests
Can Dart mocks prove Swift behaviour?
No. They can prove the Dart response to a fixture. Native and integration checks establish different parts of the contract.
Should all tests run on a physical device?
Not necessarily. Use appropriate isolated checks for logic and named-device checks for behaviour that depends on real platform conditions.
What should a review compare?
Compare shared scenario meanings, layer ownership, bridge coverage, and lifecycle gaps. Bring inconsistent assumptions to a Flutter native-testing review.