testUI function

  1. @isTest
void testUI(
  1. String description,
  2. WidgetTesterCallback callback, {
  3. bool skip = false,
  4. Timeout? timeout,
  5. Duration? initialTimeout,
  6. bool semanticsEnabled = true,
  7. TestVariant<Object?> variant = const DefaultTestVariant(),
})

Runs the callback inside the Flutter test environment.

Use this function to create test cases instead of testWidgets to be able to use setUpUI and tearDownUI.

See testWidgets for details

Implementation

@isTest
void testUI(
  String description,
  WidgetTesterCallback callback, {
  bool skip = false,
  Timeout? timeout,
  Duration? initialTimeout,
  bool semanticsEnabled = true,
  TestVariant<Object?> variant = const DefaultTestVariant(),
}) {
  testWidgets(
    description,
    (tester) async {
      for (final s in _setUpUIs) await s(tester);
      await callback(tester);
      for (final t in _tearDownUIs.reversed) await t(tester);
    },
    skip: skip,
    timeout: timeout,
    initialTimeout: initialTimeout,
    semanticsEnabled: semanticsEnabled,
    variant: variant,
  );
}