Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
510 views
in Technique[技术] by (71.8m points)

dart - Writing a flutter integration test for logging in using the new package 'integration_test' and getting errors

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));
    });
  });
}
question from:https://stackoverflow.com/questions/65943452/writing-a-flutter-integration-test-for-logging-in-using-the-new-package-integra

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...