Skip to content

Commit a371a1e

Browse files
committed
Add labels and move failure summary to end of output
1 parent dd6105b commit a371a1e

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -306,15 +306,6 @@ extension Event.ConsoleOutputRecorder {
306306
/// destination.
307307
@discardableResult public func record(_ event: borrowing Event, in context: borrowing Event.Context) -> Bool {
308308
let messages = _humanReadableOutputRecorder.record(event, in: context)
309-
310-
// Print failure summary when run ends, unless an environment variable is
311-
// set to explicitly disable it.
312-
if case .runEnded = event.kind, Environment.flag(named: "SWT_FAILURE_SUMMARY_ENABLED") != false {
313-
if let summary = _humanReadableOutputRecorder.generateFailureSummary(options: options) {
314-
// Add blank line before summary and after summary for visual separation
315-
write("\n\(summary)\n")
316-
}
317-
}
318309

319310
// Padding to use in place of a symbol for messages that don't have one.
320311
var padding = " "
@@ -349,6 +340,17 @@ extension Event.ConsoleOutputRecorder {
349340
}
350341

351342
write(lines.joined())
343+
344+
// Print failure summary when run ends, unless an environment variable is
345+
// set to explicitly disable it. The summary is printed after the main
346+
// output so it appears at the very end of the console output.
347+
if case .runEnded = event.kind, Environment.flag(named: "SWT_FAILURE_SUMMARY_ENABLED") != false {
348+
if let summary = _humanReadableOutputRecorder.generateFailureSummary(options: options) {
349+
// Add blank line before summary for visual separation
350+
write("\n\(summary)")
351+
}
352+
}
353+
352354
return !messages.isEmpty
353355
}
354356

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,15 @@ extension Event {
197197
// Build fully qualified name
198198
let fullyQualifiedName = fullyQualifiedName(for: failedTest)
199199

200-
result += "\(symbol) \(fullyQualifiedName)\n"
200+
result += "\(symbol) Test \(fullyQualifiedName)\n"
201201

202202
// For parameterized tests: show test cases grouped under the parent test
203203
if !failedTest.testCases.isEmpty {
204204
for testCase in failedTest.testCases {
205-
// Show test case arguments with additional indentation
206-
result += " (\(testCase.arguments))\n"
205+
// Show test case with argument count phrase and arguments
206+
let argumentCount = testCase.arguments.split(separator: ",").count
207+
let argumentPhrase = argumentCount.counting("argument")
208+
result += " Test case with \(argumentPhrase): (\(testCase.arguments))\n"
207209
// List each issue for this test case with additional indentation
208210
for issue in testCase.issues {
209211
result += formatIssue(issue, indentLevel: 2)

0 commit comments

Comments
 (0)