launch method

  1. @override
Future<TestApplicationHandle> launch(
  1. WidgetTester tester,
  2. TestLaunchContext context
)
override

Implementation

@override
Future<TestApplicationHandle> launch(
  WidgetTester tester,
  TestLaunchContext context,
) async {
  final ensembleContext = EnsembleTestContext.fromTestCase(
    context.testCase,
    config: context.config,
  );
  return runWithCleanupPreservingPrimary<TestApplicationHandle>(
    body: () async {
      // Listener startup can fail while a previous cancellation is still
      // settling. Keep it inside this ownership guard so partially completed
      // startup reaches the same teardown path as harness bootstrap failure.
      await ensembleContext.navigationFlow.startListeningWhenReady();
      return await AttemptLifecycleCoordinator.launchAndBeginTest(
        navigationFlow: ensembleContext.navigationFlow,
        launch: () => _launch(
          tester,
          context,
          ensembleContext,
          ownsNavigationFlow: true,
        ),
      );
    },
    cleanup: ensembleContext.navigationFlow.stopListening,
    onCleanupFailure: (error, stackTrace) {
      ensembleContext.logger.log(
        'navigationCleanupError: $error\n$stackTrace',
      );
    },
  );
}