runPlan method

Future<EnsembleTestPlanRunResult> runPlan(
  1. EnsembleTestExecutionPlan plan,
  2. WidgetTester tester, {
  3. TestPlanStartListener? onTestStart,
  4. EnsembleTestProgressListener? onTestComplete,
  5. Map<String, String> serializedPlans = const {},
})

Runs every test in plan and returns results keyed by test id.

serializedPlans is an optional scheduler hand-off keyed by test id. When present, standalone execution validates and reuses those compiled graphs; missing entries retain the existing compiler path. The map is deliberately explicit so callers cannot silently mix a plan with a different selected test.

Implementation

Future<EnsembleTestPlanRunResult> runPlan(
  EnsembleTestExecutionPlan plan,
  WidgetTester tester, {
  TestPlanStartListener? onTestStart,
  EnsembleTestProgressListener? onTestComplete,
  Map<String, String> serializedPlans = const {},
}) {
  return withFlutterErrorIsolation(() async {
    try {
      return await _runPlanIsolated(
        plan,
        tester,
        onTestStart: onTestStart,
        onTestComplete: onTestComplete,
        serializedPlans: serializedPlans,
      );
    } catch (error, stackTrace) {
      // Infrastructure and orchestration errors still produce a complete
      // result set, so the report and the remaining suite lifecycle survive.
      return EnsembleTestPlanRunResult(
        resultsById: {
          for (final definition in plan.ordered)
            definition.testCase.id: EnsembleSingleTestResult.failed(
              testId: definition.testCase.id,
              metadata: definition.testCase.metadataJson,
              durationMs: 0,
              message: 'Test plan could not execute this case: $error',
              stackTrace: stackTrace.toString(),
              report: buildTestReportDetails(
                definition.testCase,
                navigationFlow: NavigationFlowRecorder(),
              ),
            ),
        },
        suiteLogs: ['Test plan orchestration failed: $error'],
      );
    }
  });
}