Skip to content

Commit 15df2de

Browse files
authored
Merge pull request #4 from apple/jgrynspan/fix-parameter-miscount-on-recorded-issue
Fix miscounting the number of parameters when an issue is recorded.
2 parents 6e9abf0 + 6f65917 commit 15df2de

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Sources/Testing/Events/Event.Recorder.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,11 @@ extension Event.Recorder {
530530
context.testData.insertValue(testData, at: id)
531531
}
532532
}
533+
let parameterCount = if let parameters = event.test?.parameters {
534+
parameters.count
535+
} else {
536+
0
537+
}
533538
let labeledArguments = if let testCase = event.testCase, let parameters = event.test?.parameters {
534539
testCase.labeledArguments(using: parameters)
535540
} else {
@@ -557,10 +562,10 @@ extension Event.Recorder {
557562
}
558563

559564
let atSourceLocation = issue.sourceLocation.map { " at \($0)" } ?? ""
560-
if labeledArguments.isEmpty {
565+
if parameterCount == 0 {
561566
return "\(symbol) Test \(testName) recorded a\(known) issue\(atSourceLocation): \(issue.kind)\(difference)\(issueComments)\n"
562567
} else {
563-
return "\(symbol) Test \(testName) recorded a\(known) issue with \(labeledArguments.count.counting("argument")) \(labeledArguments)\(atSourceLocation): \(issue.kind)\(difference)\(issueComments)\n"
568+
return "\(symbol) Test \(testName) recorded a\(known) issue with \(parameterCount.counting("argument")) \(labeledArguments)\(atSourceLocation): \(issue.kind)\(difference)\(issueComments)\n"
564569
}
565570

566571
case .testCaseStarted:

0 commit comments

Comments
 (0)