Description
Use case
Most real apps need to do some initialization on startup. Example from my project:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
final userAgent = await getUserAgent();
await Logo.preload();
final dataDir = await getApplicationDocumentsDirectory();
final tempDir = await getTemporaryDirectory();
runApp(AppWidget(userAgent, dataDir, tempDir));
}
When following the docs "An introduction to integration testing", I copied the example code which includes this boilerplate:
group('test-group', () {
late FlutterDriver driver;
setUpAll(() async {
driver = await FlutterDriver.connect();
});
tearDownAll(() async {
driver.close();
});
The test fails immediately with #41029. Any user writing a real app will hit this eventually. They will waste time reading the test output, using a search engine to look for the solution, reading through the 12 pages of text on #41029, identifying the fix, implementing the fix, and running the test again to see if it was fixed. This is a big waste of time for folks using Flutter professionally.
Proposal
Update the example to this:
group('test-group', () {
late FlutterDriver driver;
setUpAll(() async {
driver = await FlutterDriver.connect();
await driver.waitUntilFirstFrameRasterized(); // <---- ADD THIS
});
tearDownAll(() async {
driver.close();
});
Even better, update FlutterDriver.connect()
to wait for the first frame. That will eliminate 1 of the 10 lines of boilerplate required by every flutter_driver test.