#FEATURE by cg
authorClaus Gittinger <cg@exept.de>
Thu, 28 Mar 2019 13:35:53 +0100
changeset 741 5385d22dcc62
parent 740 7f2cc93c7a75
child 742 fbe26a85e34a
#FEATURE by cg class: TestCaseOutcome added: #executionTimeDuration comment/format in: #executionTime
TestCaseOutcome.st
--- 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