flutter - 如何调试颤振单元测试?
问题描述
我正在尝试点击 aFlatButton
我在屏幕上有很多东西,但它们都有独特Key
的 s。我有一个print
作为函数中唯一的行onPressed
。
这是有效的,我在控制台中看到了打印行:
expect(find.byKey(Key('q1a2')), findsOneWidget);
await tester.tap(find.byKey(Key('q1a2')));
await tester.pumpAndSettle(Duration(milliseconds: 500));
这不起作用,我在控制台中看不到打印行:
expect(find.byKey(Key('q3a2')), findsOneWidget);
await tester.tap(find.byKey(Key('q3a2')));
await tester.pumpAndSettle(Duration(milliseconds: 500));
两个示例中的expect
通行证。我该如何调试呢?
小FlatButton
部件代码:
FlatButton(
key: Key('q${questionId}a$score'),
color: isSelected ? Colors.amberAccent : Colors.transparent,
highlightColor: Colors.transparent,
splashColor: Colors.amberAccent.withOpacity(0.2),
shape: CircleBorder(
side: BorderSide(
color: isSelected ? Colors.amberAccent : Colors.grey[300],
width: 1.0
)
),
onPressed: () {
print('WTF!');
},
child: Text(
score.toString(),
style: TextStyle(
color: isSelected ? Colors.grey[900] : Colors.grey[600],
fontSize: isSelected ? 20.0 : 18.0,
fontWeight: isSelected ? FontWeight.normal : FontWeight.w300
)
)
),
解决方案
推荐阅读
- powerbi - 如何在 Power BI 中管理“加载因加载上一个表时出错而取消”?
- html - 我无法将所需的网址发送到地址栏
- android - 想知道使用 api 而不是实现添加依赖项是否会增加 Android apk 大小?
- javascript - Angular EventEmitter 未在订阅者中发出
- r - 使用 R 中的人口比率和最小/最大标准将价值分配给区域
- c# - 在 C# 中是否有无需修改即可使用的正则表达式双引号匹配语法?
- mysql - 多次存储与特定列相关的日期的正确方法是什么
- laravel-echo - Laravel Echo 加入,获取当前用户对象
- c# - 为什么 YamlDotNet 不序列化类的私有字段?
- csv - 如何为 weka 阅读器转义 csv 文件中的单引号?