Widget Testing
flutter_test, testWidgets, find, pump, WidgetTester, golden tests, integration tests
1Which package should be used to write widget tests in Flutter?
Which package should be used to write widget tests in Flutter?
Jawaban
The flutter_test package is the official package for writing widget tests in Flutter. It is automatically included in the Flutter SDK and provides all the necessary functions and classes to test widgets, such as testWidgets, find, pump and WidgetTester. This package extends Dart's test package with Flutter-specific features.
2Which function should be used to define a widget test in Flutter?
Which function should be used to define a widget test in Flutter?
Jawaban
The testWidgets function is specifically designed for testing Flutter widgets. It provides a WidgetTester as a parameter to the callback which allows interaction with the widget under test. Unlike test() used for unit tests, testWidgets automatically manages the binding framework needed to render widgets and interact with them.
3How to find a widget by its text in a Flutter test?
How to find a widget by its text in a Flutter test?
Jawaban
The find class provides several methods to locate widgets, including find.text() which searches for a widget containing exactly the specified text. This is one of the most commonly used finders as it allows easily verifying the presence of text on screen. Other common finders include find.byType(), find.byKey() and find.byIcon().
What is the difference between pump() and pumpAndSettle() in widget tests?
How to simulate a tap on a button in a Flutter widget test?
+15 pertanyaan wawancara
Topik wawancara Flutter lainnya
Dart Basics
Dart Language Essentials
Flutter Fundamentals
Widget Lifecycle
Local Storage
Application Lifecycle
Layouts & Constraints
ListView & GridView
Navigation & Routing
Basic State Management
Provider Pattern
Networking & HTTP
JSON Serialization
Local Database
Forms & Validation
Animations
Firebase Integration
Unit Testing
Build & Deployment
Package Management
Memory & Performance
Streams & RxDart
Advanced State Management
Flutter Design Patterns
Performance Optimization
Platform Channels
Custom Painting
Flutter Application Architecture
Kuasai Flutter untuk wawancara berikutnya
Akses semua pertanyaan, flashcards, tes teknis, latihan code review dan simulator wawancara.
Mulai gratis