相同的测试使用“颤振测试”通过,但在使用“颤振运行”时失败

时间:2021-04-21 17:22:14

标签: flutter flutter-test

测试代码

testWidgets('testing amount form field error ', (tester) async {
  await tester.pumpWidget(createAddTransactionPage());
  await tester.tap(find.byType(FloatingActionButton));
  await tester.pumpAndSettle();

  expect(find.text('Amount required'), findsOneWidget);
});

控制台日志

PS D:\projects\expense-tracker\codebase\flutter\expense_tracker> flutter test test/screens/add_transaction/add_transaction_page_test.dart
00:03 +1 ~7: All tests passed!
PS D:\projects\expense-tracker\codebase\flutter\expense_tracker> flutter run test/screens/add_transaction/add_transaction_page_test.dart 
Launching test/screens/add_transaction/add_transaction_page_test.dart on Redmi Note 5 in debug mode...
Running Gradle task 'assembleDebug'...                                  
Running Gradle task 'assembleDebug'... Done                        31.3s
√ Built build\app\outputs\flutter-apk\app-debug.apk.
Installing build\app\outputs\flutter-apk\app.apk...                12.4s
I/flutter ( 3958): 00:00 +0: Add Transaction Page Widget Tests :  Testing if floating action button shows up
I/flutter ( 3958): 00:00 +0 ~1: Add Transaction Page Widget Tests :  Testing if floating action button icon is correct
I/flutter ( 3958): 00:00 +0 ~2: Add Transaction Page Widget Tests :  Testing if app bar shows up
I/flutter ( 3958): 00:00 +0 ~3: Add Transaction Page Widget Tests :  Testing if app bar title is correct
I/flutter ( 3958): 00:00 +0 ~4: Add Transaction Page Widget Tests :  Testing amount form field
I/flutter ( 3958): 00:00 +0 ~5: Add Transaction Page Widget Tests :  Testing form field label and hints
I/flutter ( 3958): 00:00 +0 ~6: Add Transaction Page Widget Tests :  testing amount form field error 
Syncing files to device Redmi Note 5...                            178ms

Flutter run key commands.
r Hot reload.
R Hot restart.
h Repeat this help message.
d Detach (terminate "flutter run" but leave application running).
c Clear the screen
q Quit (terminate the application on the device).
An Observatory debugger and profiler on Redmi Note 5 is available at: http://127.0.0.1:51204/VG-adfW3FiE=/

Flutter DevTools, a Flutter debugger and profiler, on Redmi Note 5 is available at:
http://127.0.0.1:9102?uri=http%3A%2F%2F127.0.0.1%3A51204%2FVG-adfW3FiE%3D%2F

Running with unsound null safety
For more information see https://dart.dev/null-safety/unsound-null-safety
I/zygote64( 3958): Do partial code cache collection, code=30KB, data=21KB
I/zygote64( 3958): After code cache collection, code=30KB, data=21KB
I/zygote64( 3958): Increasing code cache capacity to 128KB
I/flutter ( 3958): (The following exception is now available via WidgetTester.takeException:)
I/flutter ( 3958): ══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
I/flutter ( 3958): The following TestFailure object was thrown running a test:
I/flutter ( 3958):   Expected: exactly one matching node in the widget tree
I/flutter ( 3958):   Actual: _TextFinder:<zero widgets with text "Amount required" (ignoring offstage widgets)>
I/flutter ( 3958):    Which: means none were found but one was expected
I/flutter ( 3958): 
I/flutter ( 3958): When the exception was thrown, this was the stack:
I/flutter ( 3958): #4      main.<anonymous closure>.<anonymous closure> (file:///D:/projects/expense-tracker/codebase/flutter/expense_tracker/test/screens/add_transaction/add_transaction_page_test.dart:80:7)
I/flutter ( 3958): <asynchronous suspension>
I/flutter ( 3958): <asynchronous suspension>
I/flutter ( 3958): (elided one frame from package:stack_trace)
I/flutter ( 3958): ...
I/flutter ( 3958):
I/flutter ( 3958): This was caught by the test expectation on the following line:
I/flutter ( 3958):   file:///D:/projects/expense-tracker/codebase/flutter/expense_tracker/test/screens/add_transaction/add_transaction_page_test.dart line 80
I/flutter ( 3958): The test description was:
I/flutter ( 3958):   testing amount form field error
I/flutter ( 3958): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter ( 3958): (If WidgetTester.takeException is called, the above exception will be ignored. If it is not, then the above exception will be dumped when another exception is caught by the framework or when the test ends, whichever happens first, and then the test will fail due 
to having not caught or expected the exception.)
I/flutter ( 3958): ══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
I/flutter ( 3958): The following TestFailure object was thrown running a test:
I/flutter ( 3958):   Expected: exactly one matching node in the widget tree
I/flutter ( 3958):   Actual: _TextFinder:<zero widgets with text "Amount required" (ignoring offstage widgets)>
I/flutter ( 3958):    Which: means none were found but one was expected
I/flutter ( 3958):
I/flutter ( 3958): When the exception was thrown, this was the stack:
I/flutter ( 3958): #4      main.<anonymous closure>.<anonymous closure> (file:///D:/projects/expense-tracker/codebase/flutter/expense_tracker/test/screens/add_transaction/add_transaction_page_test.dart:80:7)
I/flutter ( 3958): <asynchronous suspension>
I/flutter ( 3958): <asynchronous suspension>
I/flutter ( 3958): (elided one frame from package:stack_trace)
I/flutter ( 3958): ...
I/flutter ( 3958):
I/flutter ( 3958): This was caught by the test expectation on the following line:
I/flutter ( 3958):   file:///D:/projects/expense-tracker/codebase/flutter/expense_tracker/test/screens/add_transaction/add_transaction_page_test.dart line 80
I/flutter ( 3958): The test description was:
I/flutter ( 3958):   testing amount form field error
I/flutter ( 3958): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter ( 3958): 00:05 +0 ~6: Add Transaction Page Widget Tests :  testing amount form field error  [E]
I/flutter ( 3958):   Test failed. See exception logs above.
I/flutter ( 3958):   The test description was: testing amount form field error
I/flutter ( 3958):
I/flutter ( 3958): 00:05 +0 ~6 -1: Add Transaction Page Widget Tests :  Adding transactions
I/flutter ( 3958): 00:05 +0 ~7 -1: Some tests failed.

0 个答案:

没有答案
相关问题