首页 > 解决方案 > 一个接一个地运行相同的颤振测试。1成功1失败

问题描述

我从创建 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 中添加了大部分相关代码,如果您需要更多,请告诉我。

是否有可能从之前的测试中留下一些隐藏状态?或者这不应该工作。

标签: flutterdartflutter-test

解决方案


推荐阅读