When I run my integration test using the Flutter driver I have found that images in my application are not loaded at all. Although If I run my application from flutter run everything works fine.

Here is my Testing code:

// Imports the Flutter Driver API
import 'package:flutter_driver/flutter_driver.dart';
import 'package:test/test.dart';

void main() {
  group('login page ignore', () {
    // First, define the Finders. We can use these to locate Widgets from the
    // test suite. Note: the Strings provided to the `byValueKey` method must
    // be the same as the Strings we used for the Keys in step 1.
    final ignoreFinder = find.byValueKey('ignore');
    final screenFinder = find.byValueKey('child_screen');

    FlutterDriver driver;

    // Connect to the Flutter driver before running any tests
    setUpAll(() async {
      driver = await FlutterDriver.connect();
    });

    // Close the connection to the driver after the tests have completed
    tearDownAll(() async {
      if (driver != null) {
        driver.close();
      }
    });

    test('test',() async {
      await driver.waitUntilNoTransientCallbacks();
      await driver.waitFor(ignoreFinder);
      await driver.tap(ignoreFinder);
      print('button clicked');
    });
  });
}

Expected:When Run using Flutter run

Actual When run test using Flutter driver


Solution 1: Esmaeil Ahmadipour

You can see DefaultAssetBundle documentation . it describes using it and a AssetBundle to provide your own assets.


Solution 2: Rudolf J

I found the issue. For me it was when I was running the tests inside the lib folder. Once I put the tests inside their own folder on the same level as the lib file, it worked.