testExecutable function
Future<void>
testExecutable({
- required FutureOr<
void> testMain(), - required List<
TestingTheme> themes, - required WidgetWrapperBuilder wrapper,
- required Color backgroundColor(),
- required List<
TestDevice> devicesForTest, - List<
LocalizationsDelegate> localizations = const [], - List<
Locale> locales = const [Locale('en')], - double tolerance = 0.18,
- LocalFileComparator? customComparator,
Entry point for the widget test.
testMain
- function that contains the actual test.themes
- list of themes used for testing.localizations
- localization delegates used for testing.locales
- list of locales used for testing. If not provided, generate goldens only for english.wrapper
- wrapper for the widget test.backgroundColor
- background color for the golden file.devicesForTest
- list of devices used for testing.customComparator
- custom comparator for the golden file.
Implementation
Future<void> testExecutable({
required FutureOr<void> Function() testMain,
required List<TestingTheme> themes,
required WidgetWrapperBuilder wrapper,
required Color Function(ThemeData) backgroundColor,
required List<TestDevice> devicesForTest,
List<LocalizationsDelegate<dynamic>> localizations = const [],
List<Locale> locales = const [Locale('en')],
double tolerance = 0.18,
LocalFileComparator? customComparator,
}) {
themesForTesting = themes;
localizationsForTesting = localizations;
localesForTesting = locales;
widgetWrapper = wrapper;
getBackgroundColor = backgroundColor;
return GoldenToolkit.runWithConfiguration(
() async {
await loadAppFonts();
await testMain();
if (goldenFileComparator is LocalFileComparator) {
goldenFileComparator = customComparator ??
CustomFileComparator(
'${(goldenFileComparator as LocalFileComparator).basedir}/goldens',
tolerance,
);
}
},
config: GoldenToolkitConfiguration(
defaultDevices: devicesForTest,
enableRealShadows: true,
),
);
}