Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 小部件测试用例正在通过,但我遇到了错误_Flutter_Dart_Testing_Widget Test Flutter - Fatal编程技术网

Flutter 小部件测试用例正在通过,但我遇到了错误

Flutter 小部件测试用例正在通过,但我遇到了错误,flutter,dart,testing,widget-test-flutter,Flutter,Dart,Testing,Widget Test Flutter,我在测试登录文件时出错。 这些测试用例都通过了,我在测试它的时候得到了绿色的记号,但是得到了这个错误消息 void main() { testWidgets('login page test', (WidgetTester tester) async { await tester.pumpWidget(MaterialApp(home: Login())); var usernameField = find.byKey(Key('username-field'));

我在测试登录文件时出错。 这些测试用例都通过了,我在测试它的时候得到了绿色的记号,但是得到了这个错误消息

void main() {
  testWidgets('login page test', (WidgetTester tester) async {
    await tester.pumpWidget(MaterialApp(home: Login()));
    var usernameField = find.byKey(Key('username-field'));
    var passwordField = find.byKey(Key('password-field'));
    var loginButton = find.text('Login');
    expect(usernameField, findsOneWidget);
    expect(passwordField, findsOneWidget);
    expect(loginButton, findsOneWidget);
  });
}
我得到这个错误:

颤振试验/试验/登录试验.dart

00:03+0:登录页面test Shell:[错误:flatter/Shell/testing/tester_main.cc(302)]未处理的异常
Shell:异常:堆栈溢出
Shell:堆栈跟踪:#0 _CustomZone.runUnaryGuarded(dart:async/zone.dart:1003:3)
Shell:#1 _BufferingStreamSubscription._sendData(dart:async/stream_impl.dart:357:11)
Shell:#2 _BufferingStreamSubscription._add(dart:async/stream_impl.dart:285:7)
Shell:#3 SyncStreamControllerDispatch.sendData(dart:async/stream_controller.dart:808:19)
Shell:#4 StreamController.add(dart:async/stream_controller.dart:682:7)
Shell:#5 _StreamController.add(dart:async/stream_controller.dart:624:5)
Shell:#6 rootrunary(dart:async/zone.dart:1206:13)
Shell:#7 _CustomZone.runUnary(dart:async/zone.dart:1100:19)
Shell:#8 _CustomZone.runUnaryGuarded(dart:async/zone.dart:1005:7)
Shell:#9 BufferingStreamSubscription.sendData(dart:async/stream_impl.dart:357:11)
Shell:#10 _BufferingStreamSubscription._add(dart:async/stream_impl.dart:285:7)
Shell:#11 SyncStreamControllerDispatch.sendData(dart:async/stream_controller.dart:808:19)
Shell:#12 _StreamController._add(dart:async/stream_controller.dart:682:7)
Shell:#13 _StreamController.add(dart:async/stream_controller.dart:624:5)
Shell:#14 _StreamSinkWrapper.add(dart:async/stream_controller.dart:900:13)
Shell:#15 _guarantesink.add(包:stream_channel/src/guarantesink.dart:125:12)
Shell:#16#多通道。虚拟通道。
00:04+0-1:加载H:\ERPAXT颤振应用程序\erpapp\。/test/login\u test.dart[E]
测试完成后,Shell子进程干净地报告了一个错误。检查上面的日志中是否有错误消息。
测试:H:\erpnext颤振应用程序\erpapp\/测试/登录\u Test.dart
Shell:C:\Users\Acer\flatter\bin\cache\artifacts\engine\windows-x64\flatter\u tester.exe
dart:async/stream_controller.dart 634:44_StreamController.addError
dart:async/stream\u controller.dart 904:13\u StreamSinkWrapper.addError
软件包:stream\u channel/src/guaranty\u channel.dart 145:14\u guarantesink.\u addError
包:stream\u channel/src/guaranty\u channel.dart 136:5\u guarantesink.addError
包装:颤振工具/src/测试/颤振平台。dart 480:29颤振平台。开始测试。
======异步间隙===========================
dart:async/zone.dart 1121:19\u CustomZone.registerUnaryCallback
dart:async patch/async_patch.dart 83:23\u asyncThenWrapperHelper
包装:颤振工具/src/测试/颤振平台。dart颤振平台。开始测试。
包装:颤振工具/src/测试/颤振平台。dart 658:26颤振平台。\开始测试
00:04+0-1:登录页面测试-未完成[E]
00:04+0-1:某些测试失败。

屏幕可能已溢出。用scaffold或Material and builder小部件包装您的Login()。我已经解决了它,实际上它与我的测试用例无关。这是我的Login.dart文件中的一个错误,是由于我所做的更改导致的。这是由于在登录文件中使用了相同的方法名,并调用它而不是调用另一个方法。可能屏幕溢出了。用scaffold或Material and builder小部件包装您的Login()。我已经解决了它,实际上它与我的测试用例无关。这是我的Login.dart文件中的一个错误,它是由于我所做的更改造成的。这是由于在登录文件中使用了相同的方法名,并调用它而不是另一个方法
00:03 +0: login page test                                                                                                                                    Shell: [ERROR:flutter/shell/testing/tester_main.cc(302)] Unhandled exception
Shell: Exception: Stack Overflow
Shell: Stack trace: #0      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1003:3)
Shell: #1      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:357:11)       
Shell: #2      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:285:7)
Shell: #3      _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:808:19)
Shell: #4      _StreamController._add (dart:async/stream_controller.dart:682:7)
Shell: #5      _StreamController.add (dart:async/stream_controller.dart:624:5)
Shell: #6      _rootRunUnary (dart:async/zone.dart:1206:13)
Shell: #7      _CustomZone.runUnary (dart:async/zone.dart:1100:19)
Shell: #8      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
Shell: #9      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:357:11)       
Shell: #10     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:285:7)
Shell: #11     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:808:19)
Shell: #12     _StreamController._add (dart:async/stream_controller.dart:682:7)
Shell: #13     _StreamController.add (dart:async/stream_controller.dart:624:5)
Shell: #14     _StreamSinkWrapper.add (dart:async/stream_controller.dart:900:13)
Shell: #15     _GuaranteeSink.add (package:stream_channel/src/guarantee_channel.dart:125:12)
Shell: #16     _MultiChannel.virtualChannel.<anonymous closure> 
00:04 +0 -1: loading H:\erpnext-flutter-app\erpapp\./test/login_test.dart [E]
Shell subprocess cleanly reported an error after tests finished. Check the logs above for an error message.
  Test: H:\erpnext-flutter-app\erpapp\./test/login_test.dart
  Shell: C:\Users\Acer\flutter\bin\cache\artifacts\engine\windows-x64\flutter_tester.exe
  dart:async/stream_controller.dart 634:44                       _StreamController.addError
  dart:async/stream_controller.dart 904:13                       _StreamSinkWrapper.addError
  package:stream_channel/src/guarantee_channel.dart 145:14       _GuaranteeSink._addError
  package:stream_channel/src/guarantee_channel.dart 136:5        _GuaranteeSink.addError
  package:flutter_tools/src/test/flutter_platform.dart 480:29    FlutterPlatform._startTest.<fn>
  ===== asynchronous gap ===========================
  dart:async/zone.dart 1121:19                                   _CustomZone.registerUnaryCallback
  dart:async-patch/async_patch.dart 83:23                        _asyncThenWrapperHelper
  package:flutter_tools/src/test/flutter_platform.dart           FlutterPlatform._startTest.<fn>
  package:flutter_tools/src/test/flutter_platform.dart 658:26    FlutterPlatform._startTest
00:04 +0 -1: login page test - did not complete [E]
00:04 +0 -1: Some tests failed.