I have a widget test similar to:
testWidgets('Widget test', (WidgetTester tester) async {
provideMockedNetworkImages(() async {
final widget = MyWidget();
await WidgetTestFunctions.pumpWidgetTest(
tester,
widget,
);
// ....
await tester.tap(find.byType(MyWidget));
await tester.pump(new Duration(milliseconds: 3000));
// ....
expect(widget.value, myValue);
});
});
And the following implementation of the on-tap method of the widget:
_onButtonPressed() async {
await animationController.forward();
setState(() {
// ...
// Calls method that changes the widget value.
});
}
The problem that I have is that after calling the animationController.forward()
method in the test the setState
portion is not executed. How should I wait for this method to finish correctly? During the app runtime, this portion of the code is called correctly.
It seems like await tester.pump(new Duration(milliseconds: 3000));
is not working correctly, the animation has a duration of 1500 milliseconds and as you can see the pump duration is double.