mercredi 17 février 2021

Error for flutter integration test using the new integration_test package to test exceptions

I am writing an integration test to to try and catch an exception in my code but I am a bit stuck at where my code is going wrong. Please let me know if you have any ideas :-)

Below is my code;

Future<Null> _signInPageUnrecognizedEmailProvided(

    WidgetTester tester) async {
  await tester
      .pumpAndSettle(Duration(seconds: reasonableStartupTimeInSeconds));

  expect(emailFormField, findsOneWidget);
  expect(passwordFormField, findsOneWidget);
  expect(loginButton, findsOneWidget);

  await tester.enterText(emailFormField, unrecognizedUsername);
  await tester.enterText(passwordFormField, validPassword);
  await tester.pumpAndSettle();

  await tester.tap(loginButton);

  await tester.pumpAndSettle(
      Duration(seconds: reasonableAuthenticationTimeInSeconds));

  expect(tester.takeException(), isInstanceOf<HandledException>());

  tester.resetTestTextInput();
}

And here is my error;

I/flutter (22131): 💡  Router - generateRoute | name: LoginView arguments: null
I/flutter (22131): ⚠️  AuthenticationApiService - The user name or password is incorrect. If you have not registered, please use
the Register New Account link below.
I/flutter (22131): ⛔  LogService - identifier: AuthenticationService.getAndStoreAuthToken | exception: The user name or password
is incorrect. If you have not registered, please use the Register New Account link below. | displayMessage: The user name or      
password is incorrect. If you have not registered, please use the Register New Account link below. | alertView: AlertView.Dialog |{email: d.sillyname@smartspaces.app}
I/flutter (22131): ══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
I/flutter (22131): The following TestFailure object was thrown running a test:
I/flutter (22131):   Expected: <Instance of 'HandledException'>
I/flutter (22131):   Actual: <null>
I/flutter (22131):    Which: is not an instance of 'HandledException'
I/flutter (22131):
I/flutter (22131): When the exception was thrown, this was the stack:
I/flutter (22131): #4      main.<anonymous closure>._signInPageUnrecognizedEmailProvided```

Aucun commentaire:

Enregistrer un commentaire