flutter 运行测试时引发了以下Assert:泵和沉降超时

2o7dmzc5  于 2023-02-16  发布在  Flutter
关注(0)|答案(1)|浏览(151)

下面是一个测试用例,它测试如果我未能将数据添加到数据库,它将在snackbar中显示错误消息,但我测试显示pumpAndSetle超时错误

testWidgets(
    'renders error snack bar '
    'when status changes to failure', (tester) async {
  whenListen<TodosOverviewState>(
      todosOverviewBloc,
      Stream.fromIterable([
        const TodosOverviewState(),
        const TodosOverviewState(status: TodosOverviewStatus.failure)
      ]));

  await tester.pumpApp(buildSubject(), todosRepository: todosRepository);

  await tester.pumpAndSettle();

  expect(find.byType(SnackBar), findsOneWidget);

  expect(
      find.descendant(
          of: find.byType(SnackBar),
          matching: find.text('todo status failed')),
      findsOneWidget);
});

错误:

bhmjp9jg

bhmjp9jg1#

删除等待测试仪.pumpAndSettle();并放入待测泵();

相关问题