0PricingLogin
Dart Academy · Lesson

Testing async Code and Streams

Await futures and verify event sequences.

Async Needs Care

Lots of real code returns a Future. If a test forgets to wait, it may pass before the work even finishes. ⏳

Return or await

The runner waits when your test body is async and you await the work, or when you return the Future directly.

test('loads user', () async {
  final u = await fetchUser();
  expect(u.name, 'Ada');
});

All lessons in this course

  1. Your First test and expect
  2. group, setUp, and tearDown
  3. Testing async Code and Streams
  4. Mocks, Fakes, and Coverage
← Back to Dart Academy