aboutsummaryrefslogtreecommitdiffstats
path: root/functest/core
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2017-05-05 14:38:27 +0200
committerCédric Ollivier <cedric.ollivier@orange.com>2017-05-05 16:18:47 +0200
commitee26a1ca85fc5fac6df6c39f362fad83de73c0cc (patch)
tree4e649ef404854dfa62e05e74d4437bec75edb936 /functest/core
parent7489b8ed94857ba2eacb02d75fdcef3f1721b00e (diff)
Print the real testcase duration
TestCase offers a new public method to calculate and print the duration. It also adds the related unit tests and adapts run_tests.py. Change-Id: Ib6a7e637dafacb9027146199aeb033c2dcb986c6 Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
Diffstat (limited to 'functest/core')
-rw-r--r--functest/core/testcase.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/functest/core/testcase.py b/functest/core/testcase.py
index 217f07e51..fd8928494 100644
--- a/functest/core/testcase.py
+++ b/functest/core/testcase.py
@@ -43,6 +43,24 @@ class TestCase(object):
self.start_time = ""
self.stop_time = ""
+ def get_duration(self):
+ """Return the duration of the test case.
+
+ Returns:
+ duration if start_time and stop_time are set
+ "XX:XX" otherwise.
+ """
+ try:
+ assert self.start_time
+ assert self.stop_time
+ if self.stop_time < self.start_time:
+ return "XX:XX"
+ return "{0[0]:02.0f}:{0[1]:02.0f}".format(divmod(
+ self.stop_time - self.start_time, 60))
+ except Exception:
+ self.__logger.error("Please run test before getting the duration")
+ return "XX:XX"
+
def check_result(self):
"""Interpret the result of the test case.