#FEATURE by cg
class: TestCaseOutcome
added: #executionTimeDuration
comment/format in: #executionTime
--- a/TestCaseOutcome.st Thu Mar 28 13:35:41 2019 +0100
+++ b/TestCaseOutcome.st Thu Mar 28 13:35:53 2019 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"{ Package: 'stx:goodies/sunit' }"
"{ NameSpace: Smalltalk }"
@@ -76,7 +78,10 @@
!
executionTime
- "the execution time in millis; nil if not yet executed"
+ "the execution time in millis;
+ nil if not yet executed.
+ If still running, the millis spent executing
+ is returned"
|startTime endTime|
@@ -91,6 +96,28 @@
^ (endTime millisecondDeltaFrom:startTime)
"Modified (format): / 18-08-2011 / 21:02:28 / cg"
+ "Modified (comment): / 28-03-2019 / 13:29:02 / Claus Gittinger"
+!
+
+executionTimeDuration
+ "the execution time as TimeDuration;
+ nil if not yet executed.
+ If still running, the time spent executing
+ is returned"
+
+ |startTime endTime|
+
+ (startTime := self startTime) isNil ifTrue:[
+ "/ not yet executed
+ ^ nil
+ ].
+ (endTime := self endTime) isNil ifTrue:[
+ "/ assume it is still running...
+ endTime := Timestamp now
+ ].
+ ^ (endTime - startTime)
+
+ "Created: / 28-03-2019 / 13:28:53 / Claus Gittinger"
!
propertyAt: aSymbol