Writing a flutter integration test for logging in using the new package 'integration_test' and getting errors. It take a long time for the test to start and then exits the app even though it says all tests passed. It doesnt seem to be entering the email and password as well (and if it is then it is going too quick) Any help would be appreciated!
void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); //group('App Test', () { testWidgets("Sign in test example", (WidgetTester tester) async { await tester.runAsync(() async { /* * Setups the finder*/ final Finder signInEmailField = find.byKey(Key('email-field')); final Finder signInPasswordField = find.byKey(Key('password-field')); final Finder signInSaveButton = find.byKey(Key('login-button')); //await tester.pumpWidget(app.main()); await app.main(); /* * pump and settle is same like waitfor in flutter_driver * */ await tester.pumpAndSettle(); expect( find.byWidgetPredicate((Widget widget) => widget is Text && widget.data.startsWith('Login')), findsOneWidget); final loginFinder = find.byWidgetPredicate((widget) => widget is BusyButton && widget is Text && (widget as Text).data.startsWith('Login')); expect(loginFinder, findsOneWidget); await tester.tap(loginFinder); await tester.pumpAndSettle(); await tester.tap(find.byKey(Key('email-field'))); await tester.enterText(signInEmailField, "[email protected]"); await tester.tap(signInPasswordField); await tester.enterText(signInPasswordField, "Test1234!"); await tester.tap(signInSaveButton); print("button tapped"); await tester.pumpAndSettle(Duration(seconds: 1)); expect( find.byWidgetPredicate((widget) => widget is WelcomePagesViewModel), findsOneWidget); await tester.pumpAndSettle(Duration(seconds: 1)); }); }); }
2.1m questions
2.1m answers
60 comments
57.0k users