我正在测试在点击按钮时显示的覆盖。覆盖层包含演示(请查看演示here)。
我在想,我是否应该使用更高级的测试框架。
代码如下:
await tester.tap(find.byType(IconButton));
await tester.pumpAndSettle();
await tester.enterText(find.byType(TextFormField), 'hi');测试在最后一行出现消息Bad state: No element时失败。
似乎overlay迷路了。有什么建议吗?
发布于 2020-07-14 08:57:26
要实现完全覆盖,应该调用两次pumpAndSettle。此外,黄金屏幕截图在调试时也是非常有用的功能:
await tester.tap(find.byType(IconButton));
await tester.pumpAndSettle();
await tester.pumpAndSettle();
await expectLater(
find.byType(MaterialApp),
matchesGoldenFile('overlay.png'),
);
await tester.enterText(find.byType(TextFormField), 'hi');运行flutter test --update-goldens以生成黄金。
https://stackoverflow.com/questions/62828221
复制相似问题