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