Flutter Widget and Integration Tests — some Surprises about Timeouts and Durations

Alfred Schilken
7 min readDec 26, 2021

I’ve been working on a big Flutter project for half a year now. One of my tasks is writing integration tests. In this article I summarize what I have learned about timouts.

You will learn:

  • how to fail early when pumpAndSettle() waits on endless running animations.
  • how to set the default timeout for all widgetTests.
  • some surprises of time and size when running widgetTests.

Preparation of a Tiny Project

I modified the standard counter app for a little experiment:

  • I removed the floating action button and replaced it with a timer which increases the _counter every second.
  • I added an endless running CircularProgressIndicator.
  • I figured out the size of the widget using context.findRenderObject().

Here I start the timer in initState():



Alfred Schilken

Software Developer for more than 35 years, started with C and C++, after Java, Python, Groovy, Lua, Golang and Swift now focussing on Dart and Flutter