From 91973dfa3823a8b423abdce59ac19de0a17ef9c1 Mon Sep 17 00:00:00 2001 From: Tanguy Date: Sat, 16 Sep 2023 08:51:29 +0200 Subject: [PATCH] Add total running time (#33) --- unittest2.nim | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/unittest2.nim b/unittest2.nim index a29d1ed..8bf195e 100644 --- a/unittest2.nim +++ b/unittest2.nim @@ -228,6 +228,8 @@ type statuses: array[TestStatus, int] + totalDuration: Duration + results: seq[TestResult] failures: seq[TestResult] @@ -560,6 +562,7 @@ proc printTestResultStatus(formatter: ConsoleOutputFormatter, testResult: TestRe method testEnded*(formatter: ConsoleOutputFormatter, testResult: TestResult) = formatter.statuses[testResult.status] += 1 + formatter.totalDuration += testResult.duration if formatter.outputLevel == NONE: return @@ -643,9 +646,11 @@ method testRunEnded*(formatter: ConsoleOutputFormatter) = formatter.statuses[TestStatus.FAILED] > 0): return + let totalDurStr = formatDuration(formatter.totalDuration, false) + try: let total = foldl(formatter.statuses, a + b, 0) - stdout.write("[Summary ] ", $total, " tests run: ") + stdout.write("[Summary] ", $total, " tests run ", totalDurStr, ": ") var first = true for s, c in formatter.statuses: