Flutter supports several types of testing — unit tests (logic), widget tests (UI components), and integration tests (full app flows). A good testing strategy improves reliability and confidence, and Flutter's testing tools make it practical.
Unit tests — test logic
// 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);
});
