aboutsummaryrefslogtreecommitdiffstats
path: root/functest/tests
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/tests
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/tests')
-rw-r--r--functest/tests/unit/core/test_testcase.py29
1 files changed, 28 insertions, 1 deletions
diff --git a/functest/tests/unit/core/test_testcase.py b/functest/tests/unit/core/test_testcase.py
index cc8446d8..37948ee1 100644
--- a/functest/tests/unit/core/test_testcase.py
+++ b/functest/tests/unit/core/test_testcase.py
@@ -22,7 +22,7 @@ __author__ = "Cedric Ollivier <cedric.ollivier@orange.com>"
class TestCaseTesting(unittest.TestCase):
"""The class testing TestCase."""
- # pylint: disable=missing-docstring
+ # pylint: disable=missing-docstring,too-many-public-methods
logging.disable(logging.CRITICAL)
@@ -162,6 +162,33 @@ class TestCaseTesting(unittest.TestCase):
self.assertEqual(self.test.check_result(),
testcase.TestCase.EX_TESTCASE_FAILED)
+ def test_get_duration_start_ko(self):
+ self.test.start_time = None
+ self.assertEqual(self.test.get_duration(), "XX:XX")
+ self.test.start_time = 0
+ self.assertEqual(self.test.get_duration(), "XX:XX")
+
+ def test_get_duration_end_ko(self):
+ self.test.stop_time = None
+ self.assertEqual(self.test.get_duration(), "XX:XX")
+ self.test.stop_time = 0
+ self.assertEqual(self.test.get_duration(), "XX:XX")
+
+ def test_get_invalid_duration(self):
+ self.test.start_time = 2
+ self.test.stop_time = 1
+ self.assertEqual(self.test.get_duration(), "XX:XX")
+
+ def test_get_zero_duration(self):
+ self.test.start_time = 2
+ self.test.stop_time = 2
+ self.assertEqual(self.test.get_duration(), "00:00")
+
+ def test_get_duration(self):
+ self.test.start_time = 1
+ self.test.stop_time = 180
+ self.assertEqual(self.test.get_duration(), "02:59")
+
if __name__ == "__main__":
unittest.main(verbosity=2)