Skip to content

Commit d19c684

Browse files
committed
Prevent div-by-0 when producing text execution summary
1 parent 75d601c commit d19c684

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

XCTest/XCTestMain.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ internal struct XCTRun {
5757
if totalFailures == 1 {
5858
failureSuffix = ""
5959
}
60-
let averageDuration = totalDuration / Double(XCTAllRuns.count)
60+
let averageDuration = totalDuration / Double(max(XCTAllRuns.count, 1))
6161
print("Total executed \(XCTAllRuns.count) test\(testCountSuffix), with \(totalFailures) failure\(failureSuffix) (\(totalUnexpectedFailures) unexpected) in \(printableStringForTimeInterval(averageDuration)) (\(printableStringForTimeInterval(totalDuration))) seconds")
6262
exit(totalFailures > 0 ? 1 : 0)
6363
}

0 commit comments

Comments
 (0)