widget_driver_test 1.0.4 widget_driver_test: ^1.0.4 copied to clipboard
Contains helper classes/methods for DrivableWidgets, WidgetDrivers, helps with TestDrivers mocking
Testing WidgetDrivers #
void main() {
group('MyAppDriver:', () {
late MockLocalization mockLocalization;
setUp(() {
mockLocalization = MockLocalization();
});
testWidgets('Shows correct app title', (WidgetTester tester) async {
when(() => mockLocalization.appTitle).thenReturn('Some app title');
final driverTester = await tester.getDriverTester<MyAppDriver>(
driverBuilder: (context) => MyAppDriver(context),
parentWidgetBuilder: (driverWidget) {
return Provider<Localization>.value(
value: mockLocalization,
child: driverWidget,
);
});
final driver = driverTester.driver;
expect(driver.appTitle, equals('Some app title'));
});
});
}
To learn more about WidgetDrivers
, please read the documentation for widget_driver and check tests for example app there.