简体   繁体   English

flutter 集成测试使用新的 integration_test package 测试异常时出错

[英]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```

It seems your input entries from emailFormField and passFormField is not getting registered, and is returning a null value.似乎您来自 emailFormField 和 passFormField 的输入条目没有被注册,并且正在返回 null 值。

Expected: <Instance of 'HandledException' I/flutter (22131): Actual: null预期:<'HandledException' I/flutter 的实例(22131):实际:null

As a result the authentication is failing, and this is causing the error.结果,身份验证失败,这导致了错误。 Check the code on how values are entered in your email / password fields, and directed for authentication.检查有关如何在 email / 密码字段中输入值的代码,并定向进行身份验证。 This could solve the issue.这可以解决问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用integration_test包在flutter集成测试中设置语言环境 - Setting locale in flutter integration test using integration_test package Flutter 集成测试调试同时使用 integration_test package - Flutter integration test debugging while using integration_test package 使用 Flutter 新的 integration_test 的示例集成测试? - Sample integration test with Flutter new integration_test? Flutter / Dart package integration_test with Z37A6259CC0C1DAE299A7866489 安全 - Flutter / Dart package integration_test with null safety 如何将参数传递给flutter integration_test? - How to pass parameters into flutter integration_test? Flutter integration_test - 截图 - Flutter integration_test - Making screenshot integration_test package 可以与 webview 交互吗? - Can integration_test package interact with webview? 如何解决“在 Flutter SDK 中找不到 package integration_test”错误 - How to solve 'could not find package integration_test in the Flutter SDK' error Flutter integration_test package 与我的代码冲突,无法通过调整 package 版本来解决 - 所以整个应用程序无法运行 - Flutter integration_test package conflict with my code and cannot be resolved by tweaking package versions - so the whole app cannot run Flutter integration_test:如何通过长按 shift 键和鼠标拖动来自动选择多个小部件 - Flutter integration_test: How to automate multiple selection of widgets by long pressing shift key and mouse drag
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM