我首先创建Flutter测试,然后遇到2个完全相同的测试,但是只有1个成功。
要点: https://gist.github.com/Mooibroek/bd6c02e5b56e4b03409ee1839a2e0b23
第二个失败并显示此错误:
The following TestFailure object was thrown running a test:
Expected: exactly one matching node in the widget tree
Actual: ?:<zero widgets with widget matching predicate (Closure: (dynamic) => bool) (ignoring
offstage widgets)>
Which: means none were found but one was expected
When the exception was thrown, this was the stack:
#4 main.<anonymous closure> (file:///Users/nicepants/Projects/flutter/generic_flutter/test/register_test.dart:38:5)
<asynchronous suspension>
#5 testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:108:25)
第38行是我们断言是否找到按钮的行。我在GIST中添加了大多数相关代码,让我知道是否需要更多。
从上次测试中是否有某种隐藏状态?还是这不行。