下面是一个测试用例,它测试如果我未能将数据添加到数据库,它将在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);
});
错误:
1条答案
按热度按时间bhmjp9jg1#
删除等待测试仪.pumpAndSettle();并放入待测泵();