Test Asynchronous & Reactive Code
1 fill-in slot · from The AI Prompt Handbook for Mobile App Development
Your details
0/1 filledTest Asynchronous & Reactive Code
Background: Native [platform] app. The code under test is asynchronous/ reactive: [paste it—e.g., a Combine pipeline, a Flow, an async/await function, a debounced search]. Use case: Write reliable, non-flaky tests for this async behavior. Implementation details: - iOS: test async/await directly, or use expectations / a test scheduler for Combine; control time for debounce/delay instead of sleeping. Android: runTest with the test dispatcher, Turbine (or equivalent) for Flow, and virtual time for debounce/delay. - Never use real wall-clock sleeps—drive virtual time - Test cancellation, error emission within the stream, and completion - Assert the sequence of emitted values/states, not just the final one - Make the tests deterministic so they pass 1000/1000 runs Deliverable: The async test suite using virtual time / test schedulers, coverage of emission sequence + error + cancellation, and an explanation of how flakiness is avoided here.
Highlighted [slots] are still empty. Downloads are plain .txt — paste into any AI assistant.