Build Testing with package:test in vertical slices that separate library boundaries, domain logic, I/O, and tests. Cover normal, null, empty, invalid, async-error, and cancellation cases with repeatable tests.
Build a Complete Mental Model
Build Testing with package:test in vertical slices that separate library boundaries, domain logic, I/O, and tests. Cover normal, null, empty, invalid, async-error, and cancellation cases with repeatable tests.
Apply It in Modern Dart
Run and test an original Testing with package:test example with null, empty, boundary, invalid, async-error, and cancellation cases. Use dart format, dart analyze, and dart test, and verify Future or Stream subscriptions and isolate boundaries where relevant.
After This Lesson
import 'package:test/test.dart';
int total(Iterable<int> values) => values.fold(0, (a, b) => a + b);
void main() {
group('total', () {
test('handles empty and populated values', () {
expect(total([]), 0);
expect(total([1, 2, 3]), 6);
});
});
}All tests passed!Try It Yourself
Run and test an original Testing with package:test example with null, empty, boundary, invalid, async-error, and cancellation cases. Use dart format, dart analyze, and dart test, and verify Future or Stream subscriptions and isolate boundaries where relevant.
Null and Async Warning
Assuming one sample output proves every null, promotion, Future, Stream, and isolate path.
Dart testing — Dart