Skip to content

Commit b3ba640

Browse files
committed
Refactor to simplify and consolidate some logic in fullyQualifiedName()
1 parent e6558c5 commit b3ba640

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,17 @@ extension Event {
187187
/// - Returns: The fully qualified name, with display name substituted if
188188
/// available.
189189
private func fullyQualifiedName(for failedTest: FailedTest) -> String {
190-
var name = failedTest.path.dropFirst().joined(separator: "/")
191-
192-
// Use display name for the last component if available
193-
if let displayName = failedTest.displayName, !failedTest.path.isEmpty {
194-
let pathWithoutLast = failedTest.path.dropFirst().dropLast()
195-
name = (pathWithoutLast + [#""\#(displayName)""#]).joined(separator: "/")
190+
// Omit the leading path component representing the module name from the
191+
// fully-qualified name of the test.
192+
let path = failedTest.path.dropFirst()
193+
194+
// Use display name for the last component if available. Otherwise, join
195+
// the path components.
196+
return if let displayName = failedTest.displayName, !failedTest.path.isEmpty {
197+
(path.dropLast() + [#""\#(displayName)""#]).joined(separator: "/")
198+
} else {
199+
path.joined(separator: "/")
196200
}
197-
198-
return name
199201
}
200202

201203
/// Format a single issue entry.

0 commit comments

Comments
 (0)