- Testing Flutter apps
The goal of a widget test is to verify that the widget's UI looks and interacts as expected Testing a widget involves multiple classes and requires a test environment that provides the appropriate widget lifecycle context
- Widget testing - Flutter
Widget testing A catalog of recipes for adding widget testing to your Flutter app
- An introduction to unit testing - Flutter
The test package provides the core framework for writing unit tests, and the flutter_test package provides additional utilities for testing widgets This recipe demonstrates the core features provided by the test package using the following steps:
- Handle scrolling - Flutter
To scroll through lists via integration tests, use the methods provided by the WidgetTester class, which is included in the flutter_test package: In this recipe, learn how to scroll through a list of items to verify a specific widget is being displayed, and the pros and cons of different approaches
- Find widgets - Flutter
The find constant provided by the flutter_test package provides several ways to locate widgets in the test environment This recipe demonstrated three of these methods, and several more methods exist for different purposes
- Tap, drag, and enter text - Flutter
Many widgets not only display information, but also respond to user interaction This includes buttons that can be tapped, and TextField for entering text To test these interactions, you need a way to simulate them in the test environment For this purpose, use the WidgetTester library
- Common Flutter errors
Here is an incomplete list of widgets that expect specific parent widgets within the Flutter framework Feel free to submit a PR (using the doc icon in the top right corner of the page) to expand this list
- Taps, drags, and other gestures - Flutter
If you're using Material Components, many of those widgets already respond to taps or gestures For example, IconButton and TextButton respond to presses (taps), and ListView responds to swipes to trigger scrolling
|