Skip to content

Commit 3c36853

Browse files
committed
Use 'Suite' or 'Test' label dynamically in failure summary
Track isSuite in TestData and FailedTest to correctly label suite-level issues (e.g., from TestScoping traits) vs test issues.
1 parent a371a1e commit 3c36853

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ extension Event {
3434
/// The test's display name, if any.
3535
var displayName: String?
3636

37+
/// Whether this is a suite rather than an individual test.
38+
var isSuite: Bool
39+
3740
/// For non-parameterized tests: issues recorded directly on the test.
3841
var issues: [HumanReadableOutputRecorder.Context.TestData.IssueInfo]
3942

@@ -81,6 +84,7 @@ extension Event {
8184
path: parentPath,
8285
name: parentPath.last ?? "Unknown",
8386
displayName: testData.displayName,
87+
isSuite: testData.isSuite,
8488
issues: [],
8589
testCases: (testData.testCaseArguments?.isEmpty ?? true) ? [] : [FailedTestCase(
8690
arguments: testData.testCaseArguments ?? "",
@@ -96,6 +100,7 @@ extension Event {
96100
path: path,
97101
name: testName,
98102
displayName: testData.displayName,
103+
isSuite: testData.isSuite,
99104
issues: issues,
100105
testCases: []
101106
)
@@ -197,7 +202,9 @@ extension Event {
197202
// Build fully qualified name
198203
let fullyQualifiedName = fullyQualifiedName(for: failedTest)
199204

200-
result += "\(symbol) Test \(fullyQualifiedName)\n"
205+
// Use "Suite" or "Test" based on whether this is a suite
206+
let label = failedTest.isSuite ? "Suite" : "Test"
207+
result += "\(symbol) \(label) \(fullyQualifiedName)\n"
201208

202209
// For parameterized tests: show test cases grouped under the parent test
203210
if !failedTest.testCases.isEmpty {
@@ -357,6 +364,9 @@ extension Event {
357364

358365
/// The test case arguments, formatted for display (for parameterized tests).
359366
var testCaseArguments: String?
367+
368+
/// Whether this is a suite rather than an individual test.
369+
var isSuite: Bool = false
360370
}
361371

362372
/// Data tracked on a per-test basis.
@@ -625,13 +635,15 @@ extension Event.HumanReadableOutputRecorder {
625635
)
626636
testData.issues.append(issueInfo)
627637

628-
// Capture test display name and test case arguments once per test (not per issue)
638+
// Capture test metadata once per test (not per issue)
629639
if testData.displayName == nil {
630640
testData.displayName = test?.displayName
631641
}
632642
if testData.testCaseArguments == nil {
633643
testData.testCaseArguments = testCase?.labeledArguments()
634644
}
645+
// Track whether this is a suite (for failure summary labeling)
646+
testData.isSuite = test?.isSuite ?? false
635647
}
636648

637649
context.testData[keyPath] = testData

0 commit comments

Comments
 (0)