Integration test default golden-file comparators changed on Android and iOS.

Summary

#

Unless a user-defined goldenFileComparator is set, either manually in a test, or using a flutter_test_config.dart file, Android and iOS devices and emulators/simulators have a new default that proxies to the local host filesystem, fixing a long-standing bug (#143299).

Background

#

The package integration_test, and its integration with flutter_test has historically had a bug where using matchesGoldenFile or similar APIs where a FileSystemException was thrown.

Some users may have worked around this issue by writing and using a custom goldenFileComparator:

dart
import 'package:integration_test/integration_test.dart';
import 'package:my_integration_test/custom_golden_file_comparator.dart';

void main() {
  goldenFileComparator = CustomGoldenFileComparatorThatWorks();

  // ...
}

Such workarounds are no longer necessary, and if type checking the default, will no longer work as before:

dart
if (goldenFileComparator is ...) {
  // The new default is a new (hidden) type that has not existed before.
}

Migration Guide

#

In most cases, we expect users to have to do nothing - this will be in a sense new functionality that replaced functionality that did not work and caused an unhandled exception which would fail a test.

In cases where users wrote custom test infrastructure and compartors, consider instead removing the goldenFileComparator overrides, and instead rely on the (new) default which should work as expected:

import 'package:integration_test/integration_test.dart';
-import 'package:my_integration_test/custom_golden_file_comparator.dart';

void main() {
-  goldenFileComparator = CustomGoldenFileComparatorThatWorks();

  // ...
}

Fun fact: The existing code that was used for the web platform was reused.

Timeline

#

Landed in version: Not yet
Stable release: Not yet

References

#

Relevant APIs:

Relevant Issues:

Relevant PRs:

  • PR 160215, where the web tool implementation was refactored to make it generic.
  • PR 160484, which uses the Dart VM service protocol to proxy between device and host.