1

测试登录文件时出现错误。这些测试用例正在通过,我在测试时得到绿色勾号,但收到此错误消息

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);
  });
}

我收到此错误:

颤振测试./test/login_test.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.
4

0 回答 0