Flutter understøtter flere typer test — unit tests (logik), widget tests (UI-komponenter) og integration tests (fulde app-flows). En god teststrategi forbedrer pålidelighed og tillid, og Flutters testværktøjer gør det praktisk.
Unit tests — test logik
// test pure logic (functions, classes, business logic) — fast, no UI
test('adds two numbers', () {
expect(add(2, 3), 5);
});
test('Cart calculates total', () {
final cart = Cart()..add(Item(price: 10));
expect(cart.total, 10);
});
