Skip to content

Commit 47a6688

Browse files
committed
Add repetition info to human output recorder
1 parent c44c50b commit 47a6688

1 file changed

Lines changed: 24 additions & 6 deletions

File tree

Sources/Testing/Events/Recorder/Event.HumanReadableOutputRecorder.swift

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,10 @@ extension Event.HumanReadableOutputRecorder {
365365
String(describing: TimeValue(rawValue: end.suspending.rawValue - start.suspending.rawValue))
366366
}
367367

368+
func testStartedMessage(for test: Test) -> String {
369+
"\(_capitalizedTitle(for: test)) \(testName) started"
370+
}
371+
368372
// Finally, produce any messages for the event.
369373
switch event.kind {
370374
case .testDiscovered:
@@ -425,7 +429,7 @@ extension Event.HumanReadableOutputRecorder {
425429
return [
426430
Message(
427431
symbol: .default,
428-
stringValue: "\(_capitalizedTitle(for: test)) \(testName) started."
432+
stringValue: "\(testStartedMessage(for: test))."
429433
)
430434
]
431435

@@ -565,15 +569,29 @@ extension Event.HumanReadableOutputRecorder {
565569
return result
566570

567571
case .testCaseStarted:
568-
guard let testCase, testCase.isParameterized, let arguments = testCase.arguments else {
572+
guard let test, let testCase else { break }
573+
let iteration = eventContext.iteration ?? 1
574+
575+
let shouldShowMessage = testCase.isParameterized || iteration > 1
576+
577+
guard shouldShowMessage else {
569578
break
570579
}
571580

581+
var message = if testCase.isParameterized, let arguments = testCase.arguments {
582+
"Test case passing \(arguments.count.counting("argument")) \(testCase.labeledArguments(includingQualifiedTypeNames: verbosity > 0)) to \(testName) started"
583+
} else {
584+
testStartedMessage(for: test)
585+
}
586+
587+
if iteration > 1 {
588+
message += " (repetition \(iteration))"
589+
}
590+
591+
message += "."
592+
572593
return [
573-
Message(
574-
symbol: .default,
575-
stringValue: "Test case passing \(arguments.count.counting("argument")) \(testCase.labeledArguments(includingQualifiedTypeNames: verbosity > 0)) to \(testName) started."
576-
)
594+
Message(symbol: .default, stringValue: message)
577595
]
578596

579597
case .testCaseEnded:

0 commit comments

Comments
 (0)