diff options
author | Cédric Ollivier <cedric.ollivier@orange.com> | 2016-12-15 16:54:45 +0100 |
---|---|---|
committer | Cédric Ollivier <cedric.ollivier@orange.com> | 2016-12-15 18:24:38 +0100 |
commit | 0d875d44c3d67e049c165365add1084467143b62 (patch) | |
tree | eb5cb1bab09f90e9196371c2aa446a11ef085610 /functest/tests/unit/core | |
parent | 41ccc6e8a54f11e0014707730bf3ef80385a01fa (diff) |
Add check_criteria() in testcase_base
It allows checking testcase results and then returning an error value
to CI. Now run() should return EX_OK even if criteria is FAILED.
It also fixes an issue induced by [1].
[1] https://gerrit.opnfv.org/gerrit/#/c/24561/
Change-Id: Iaa095696f9dcb87f8cc95179b4f404b092d1e23e
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
Diffstat (limited to 'functest/tests/unit/core')
-rw-r--r-- | functest/tests/unit/core/test_testcase_base.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/functest/tests/unit/core/test_testcase_base.py b/functest/tests/unit/core/test_testcase_base.py index fe7b0d05..181eed94 100644 --- a/functest/tests/unit/core/test_testcase_base.py +++ b/functest/tests/unit/core/test_testcase_base.py @@ -24,7 +24,7 @@ class TestcaseBaseTesting(unittest.TestCase): self.test.case_name = "base" self.test.start_time = "1" self.test.stop_time = "2" - self.test.criteria = "100" + self.test.criteria = "PASS" self.test.details = {"Hello": "World"} def test_run_unimplemented(self): @@ -82,6 +82,21 @@ class TestcaseBaseTesting(unittest.TestCase): self.test.project, self.test.case_name, self.test.start_time, self.test.stop_time, self.test.criteria, self.test.details) + def test_check_criteria_missing(self): + self.test.criteria = None + self.assertEqual(self.test.check_criteria(), + testcase_base.TestcaseBase.EX_TESTCASE_FAILED) + + def test_check_criteria_failed(self): + self.test.criteria = 'FAILED' + self.assertEqual(self.test.check_criteria(), + testcase_base.TestcaseBase.EX_TESTCASE_FAILED) + + def test_check_criteria_pass(self): + self.test.criteria = 'PASS' + self.assertEqual(self.test.check_criteria(), + testcase_base.TestcaseBase.EX_OK) + if __name__ == "__main__": unittest.main(verbosity=2) |