Junior — Middle
Do you have experience writing unit tests in projects?
sobes.tech AI
Answer from AI
Yes, in Flutter projects I regularly wrote unit tests to verify the logic of widgets, services, and business logic. I used the flutter_test package and mockito for creating mocks.
Here's an example of a simple widget test:
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart';
void main() {
testWidgets('Text display check', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
home: Scaffold(
body: Text('Hello, test!'),
),
));
expect(find.text('Hello, test!'), findsOneWidget);
});
}
This approach helps quickly identify errors and maintain code quality.