Flutter कई प्रकार के testing का समर्थन करता है — unit tests (logic), widget tests (UI components), और integration tests (पूर्ण app flows)। एक अच्छी testing strategy विश्वसनीयता और आत्मविश्वास बढ़ाती है, और Flutter के testing tools इसे व्यावहारिक बनाते हैं।
Unit tests — 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);
});
