[英]lineMatch assertion error in Flutter integration tests
I'm encountering the following error often, though it's inconsistent and I can't figure out why.我经常遇到以下错误,尽管它不一致而且我无法弄清楚原因。 I'm using tester as instructed for Flutter Integration tests.
我正在按照 Flutter 集成测试的说明使用测试仪。
Test Code:测试代码:
testWidgets('should create and save simulation', (tester) async {
await startApp(tester, app);
await login(tester);
await navigateTo(NavPage.SIMULATOR, tester);
String scenarioName = "CreateAndSaveScenario";
await createScenario(scenarioName, tester);
expect(find.text("CRQ Simulator"), findsWidgets);
expect(find.text("Edit Scenario"), findsWidgets);
expect(find.text(scenarioName), findsWidgets);
Finder fairSwitchFinder = find.byType(Switch);
tester.tap(fairSwitchFinder);
await navigateTo(NavPage.SIMULATOR, tester);
expect(find.byType(ListTile), findsOneWidget);
expect(find.text(scenarioName), findsOneWidget);
});
Error:错误:
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞═════════════════
The following assertion was thrown running a test:
Assertion failed:
file:///C:/Users/jared/dev/flutter/packages/flutter_test/lib/src/test_async_utils.dart:315:14
lineMatch != null
is not true
When the exception was thrown, this was the stack:
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 266:49 throw_
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 29:3 assertFailed
packages/flutter_test/src/test_async_utils.dart 315:23 _findResponsibleMethod
packages/flutter_test/src/test_async_utils.dart 198:42 guardSync
packages/flutter_test/src/widget_tester.dart 459:18 expect$
views/simulator/crq_simulator_test.dart 37:7 <fn>
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50 <fn>
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/zone.dart 1399:47 _rootRunUnary
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/zone.dart 1300:19 runUnary
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 147:18 handleValue
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 766:44 handleValueCallback
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 795:13 _propagateToListeners
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 566:5 [_completeWithValue]
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 639:7 <fn>
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/zone.dart 1391:13 _rootRun
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/zone.dart 1293:19 run
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/zone.dart 1201:7 runGuarded
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/zone.dart 1241:23 callback
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/schedule_microtask.dart 40:11 _microtaskLoop
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/schedule_microtask.dart 49:5 _startMicrotaskLoop
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 166:15 <fn>
The test description was:
should create and save simulation
═════════════════════════════════════════════════════════════════
end of failure 1
I was expecting the tester to navigate, but after the fairSwitchFinder tap, it seems to not be able to do anything because the lineMatch is null?我期待测试仪导航,但在 fairSwitchFinder 点击之后,它似乎无法做任何事情,因为 lineMatch 是 null? The error is not very descriptive
错误描述性不强
Okay, I figured this out fairly quickly afterward.好吧,我后来很快就想通了。 Surprised there weren't any answers up, but hopefully this question shows up in searches now.
很惊讶没有任何答案,但希望这个问题现在出现在搜索中。
I was missing an await
.我错过了
await
。
I changed tester.tap(fairSwitchFinder);
我改变了
tester.tap(fairSwitchFinder);
to await tester.tap(fairSwitchFinder);
await tester.tap(fairSwitchFinder);
and it fixed it.它修复了它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.