我有一个这样的小部件测试,我可以找到带有 的小部件actionKey
,但是点击测试失败并且tapped
在之后值为 false tester.tap(...)
,我的测试有什么问题?
testWidgets('some test', (WidgetTester tester) async {
final UniqueKey actionKey = UniqueKey();
bool tapped = false;
await tester.pumpWidget(MaterialApp(
home: Scaffold(
body: SlidableListItem(
child: const ListTile(title: Text('item')),
actions: <Widget>[
InkWell(
key: actionKey,
child: const Text('action'),
onTap: () => tapped = true,
),
],
),
),
));
await tester.tap(find.byKey(actionKey));
await tester.pump();
expect(find.byKey(actionKey), findsOneWidget);
expect(tapped, isTrue); <- failes
});
The following TestFailure object was thrown running a test:
Expected: true
Actual: <false>