buildComplete static method

Map<String, dynamic> buildComplete(
  1. EnsembleTestRunResult result, {
  2. required String artifactRoot,
  3. required String displayRoot,
  4. int? wallTimeMs,
})

Full document after the suite finishes.

Implementation

static Map<String, dynamic> buildComplete(
  EnsembleTestRunResult result, {
  required String artifactRoot,
  required String displayRoot,
  int? wallTimeMs,
}) {
  final ordered = [
    ...result.results.where((r) => r.status == TestStatus.failed),
    ...result.results.where((r) => r.status != TestStatus.failed),
  ];
  final totalMs = result.results.fold<int>(0, (sum, r) => sum + r.durationMs);

  return {
    'state': 'complete',
    'generatedAt': DateTime.now().toIso8601String(),
    'summary': {
      'passed': result.passedCount,
      'failed': result.failedCount,
      'totalMs': totalMs,
      'wallTimeMs': wallTimeMs ?? totalMs,
    },
    'suiteArtifacts': _suiteArtifacts(
      result.suiteLogs,
      artifactRoot: artifactRoot,
      displayRoot: displayRoot,
    ),
    'tests': [
      for (final test in ordered)
        _buildTestEntry(
          test,
          artifactRoot: artifactRoot,
          displayRoot: displayRoot,
        ),
    ],
  };
}