run<T> method

Future<T> run<T>({
  1. required WidgetTester tester,
  2. required TestServiceManager services,
  3. required ApplicationTestDriver driver,
  4. required TestSuiteContext context,
  5. required Future<T> execute(
    1. void registerCleanup(
      1. FutureOr<void> ()
      )
    ),
})

Implementation

Future<T> run<T>({
  required WidgetTester tester,
  required TestServiceManager services,
  required ApplicationTestDriver driver,
  required TestSuiteContext context,
  required Future<T> Function(
    void Function(FutureOr<void> Function()) registerCleanup,
  ) execute,
}) {
  final cleanup = AsyncCleanupStack();
  // An empty service set cannot own a process. Avoid registering and
  // invoking a no-op stop path for the common application suite, while
  // retaining the cleanup guard for configured services that may partially
  // start before setup fails.
  if (services.hasConfiguredServices) {
    cleanup.add(() => LiveAsyncCallSupport.run<void>(services.stopAll));
  }
  return cleanup.run(() async {
    if (services.hasConfiguredServices) {
      await tester.runAsync(services.startAll);
    }
    return const ApplicationSuiteLifecycle().run(
      application: driver,
      context: context,
      cleanup: cleanup,
      execute: () => execute(cleanup.add),
    );
  });
}