toJson method

Map<String, dynamic> toJson()

Implementation

Map<String, dynamic> toJson() => {
      'testId': testId,
      if (metadata.isNotEmpty) 'metadata': metadata,
      'status': status.name,
      'durationMs': durationMs,
      if (attempts > 1) 'attempts': attempts,
      if (retry > 0) 'retry': retry,
      if (failedStepIndex != null) 'failedStepIndex': failedStepIndex,
      if (failedStep != null) 'failedStep': failedStep!.toJson(),
      // Failed results have one canonical message. Older execution paths
      // can leave a blank legacy message while structured failure details
      // contain the useful text; serializing the raw field would make JSON
      // disagree with the other report projections.
      if (status == TestStatus.failed)
        'message': effectiveFailureMessage
      else if (message != null)
        'message': message,
      if (status == TestStatus.failed) 'failure': _failureJson(),
      if (secondaryFailures.isNotEmpty)
        'secondaryFailures':
            secondaryFailures.map((failure) => failure.toJson()).toList(),
      if (capabilityStatus.isNotEmpty) 'capabilities': capabilityStatus,
      if (effectiveFailureStackTrace != null)
        'stackTrace': effectiveFailureStackTrace,
      if (failureOperation != null) 'failureOperation': failureOperation,
      if (failureSource != null)
        'failureSource': {
          'path': failureSource!.path,
          'stepPath': failureSource!.stepPath,
        },
      'logs': logs,
      if (report != null) 'report': report!.toJson(),
    };