logFailureAuto<T> method

void logFailureAuto<T>({
  1. required String testName,
  2. DateTime? startTime,
  3. T? result,
  4. Object? input,
  5. Object? exception,
  6. StackTrace? stackTrace,
})

Implementation

void logFailureAuto<T>({
  required String testName,
  DateTime? startTime,
  T? result,
  Object? input,
  Object? exception,
  StackTrace? stackTrace,
}) {
  final start = DateTime.now();
  final end = DateTime.now();

  final reason = exception is TestFailure
      ? FailureFormatter.format(
          condition: 'Check failed assertion',
          actualResult: result,
          input: input,
          error: exception,
        )
      : exception?.toString();

  _writer.add(
    TestLogEntry<T>(
      testName: testName,
      startTime: startTime ?? start,
      endTime: end,
      status: 'failed',
      message: 'Test failed.',
      result: result,
      exception: reason,
      stackTrace: stackTrace?.toString(),
    ),
  );
}