|
An introduction to widget testing - Flutter
In the introduction to unit testing recipe, you learned how to test Dart classes using the test package. To test widget classes, you need a few additional tools provided by the flutter_test package, which ships with the Flutter SDK. The flutter_test package provides the following tools for testing widgets: The WidgetTester allows building and interacting with widgets in a test environment. The ...
Widget testing - Flutter
A catalog of recipes for adding widget testing to your Flutter app.
Testing Flutter apps
Testing a widget involves multiple classes and requires a test environment that provides the appropriate widget lifecycle context. For example, the Widget being tested should be able to receive and respond to user actions and events, perform layout, and instantiate child widgets.
Tap, drag, and enter text - Flutter
In the test environment, Flutter doesn't automatically rebuild widgets when the state changes. To ensure that the widget tree is rebuilt after simulating a user interaction, call the pump() or pumpAndSettle() methods provided by the WidgetTester. This recipe uses the following steps: Create a widget to test. Enter text in the text field.
Handle scrolling - Flutter
How to handle scrolling in a widget test. Now, you can write a test. In this example, scroll through the list of items and verify that a particular item exists in the list. The WidgetTester class provides the scrollUntilVisible() method, which scrolls through a list until a specific widget is visible. This is useful because the height of the items in the list can change depending on the device ...
Check app functionality with an integration test - Flutter
The integration_test package lets you: Use the flutter drive command to run tests on a physical device or emulator. Run on Firebase Test Lab, to automate testing on a variety of devices. Use flutter_test APIs to write tests in a style similar to widget tests.
Find widgets - Flutter
During a flutter run session on a widget test, you can also interactively tap parts of the screen for the Flutter tool to print the suggested Finder. This recipe looks at the find constant provided by the flutter_test package, and demonstrates how to work with some of the Finders it provides.
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: Add the test or flutter_test dependency. Create a test file. Create a class to test.
Test orientation - Flutter
4. Create a landscape orientation test Add the landscape orientation test to the Orientation group. This test makes sure that the orientation is landscape and that only 3 columns of data appear in the app: In test/widget_test.dart, inside of the Orientation group, add the following test after the landscape test: widget_test.dart dart ...
An introduction to widget testing - Flutter
In the introduction to unit testing recipe, you learned how to test Dart classes using the test package. To test widget classes, you need a few additional tools provided by the flutter_test package, which ships with the Flutter SDK.
|