diff options
author | Cédric Ollivier <cedric.ollivier@orange.com> | 2017-04-23 08:59:43 +0200 |
---|---|---|
committer | Cédric Ollivier <cedric.ollivier@orange.com> | 2017-04-26 09:35:47 +0200 |
commit | e620488a6747318c40eb973c2607ae6d44e95b8f (patch) | |
tree | 7654490079abb39af4a48b2edf249efc66cb9874 /functest/core | |
parent | 9d4e6cb10fef5f0cef104861034340cda5e48a3e (diff) |
Switch TestCase attribute criteria to result
It mainly avoids mixing input and output.
Criteria is now an input set in functest/ci/testcases.yaml and then
must be passed as __init__() args (which will be proposed in an
additional change).
Then it also renames the related TestCase method to
check_result().
Change-Id: Ifc3c8e3ea6cde7e3edf7174bed4bf2bf0894e8e3
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
Diffstat (limited to 'functest/core')
-rw-r--r-- | functest/core/feature.py | 10 | ||||
-rw-r--r-- | functest/core/pytest_suite_runner.py | 4 | ||||
-rw-r--r-- | functest/core/testcase.py | 24 | ||||
-rw-r--r-- | functest/core/vnf_base.py | 6 |
4 files changed, 22 insertions, 22 deletions
diff --git a/functest/core/feature.py b/functest/core/feature.py index 5f8a0873..08500a26 100644 --- a/functest/core/feature.py +++ b/functest/core/feature.py @@ -59,7 +59,7 @@ class Feature(base.TestCase): It sets the following attributes required to push the results to DB: - * criteria, + * result, * start_time, * stop_time. @@ -74,15 +74,15 @@ class Feature(base.TestCase): """ self.start_time = time.time() exit_code = base.TestCase.EX_RUN_ERROR - self.criteria = "FAIL" + self.result = "FAIL" try: if self.execute(**kwargs) == 0: exit_code = base.TestCase.EX_OK - self.criteria = 'PASS' + self.result = 'PASS' ft_utils.logger_test_results( self.project_name, self.case_name, - self.criteria, self.details) - self.logger.info("%s %s", self.project_name, self.criteria) + self.result, self.details) + self.logger.info("%s %s", self.project_name, self.result) except Exception: # pylint: disable=broad-except self.logger.exception("%s FAILED", self.project_name) self.logger.info("Test result is stored in '%s'", self.result_file) diff --git a/functest/core/pytest_suite_runner.py b/functest/core/pytest_suite_runner.py index 775f0a66..8b5da05e 100644 --- a/functest/core/pytest_suite_runner.py +++ b/functest/core/pytest_suite_runner.py @@ -48,10 +48,10 @@ class PyTestSuiteRunner(base.TestCase): if ((result.errors and len(result.errors) > 0) or (result.failures and len(result.failures) > 0)): self.logger.info("%s FAILED" % self.case_name) - self.criteria = 'FAIL' + self.result = 'FAIL' else: self.logger.info("%s OK" % self.case_name) - self.criteria = 'PASS' + self.result = 'PASS' self.details = {} return exit_code diff --git a/functest/core/testcase.py b/functest/core/testcase.py index 309842e3..b9dcbb2d 100644 --- a/functest/core/testcase.py +++ b/functest/core/testcase.py @@ -38,25 +38,25 @@ class TestCase(object): self.details = {} self.project_name = kwargs.get('project_name', 'functest') self.case_name = kwargs.get('case_name', '') - self.criteria = "" + self.result = "" self.start_time = "" self.stop_time = "" - def check_criteria(self): - """Interpret the results of the test case. + def check_result(self): + """Interpret the result of the test case. - It allows getting the results of TestCase. It completes run() + It allows getting the result of TestCase. It completes run() which only returns the execution status. - It can be overriden if checking criteria is not suitable. + It can be overriden if checking result is not suitable. Returns: - TestCase.EX_OK if criteria is 'PASS'. + TestCase.EX_OK if result is 'PASS'. TestCase.EX_TESTCASE_FAILED otherwise. """ try: - assert self.criteria - if self.criteria == 'PASS': + assert self.result + if self.result == 'PASS': return TestCase.EX_OK except AssertionError: self.logger.error("Please run test before checking the results") @@ -74,7 +74,7 @@ class TestCase(object): The new implementation must set the following attributes to push the results to DB: - * criteria, + * result, * start_time, * stop_time. @@ -99,7 +99,7 @@ class TestCase(object): * project_name, * case_name, - * criteria, + * result, * start_time, * stop_time. @@ -110,12 +110,12 @@ class TestCase(object): try: assert self.project_name assert self.case_name - assert self.criteria + assert self.result assert self.start_time assert self.stop_time if ft_utils.push_results_to_db( self.project_name, self.case_name, self.start_time, - self.stop_time, self.criteria, self.details): + self.stop_time, self.result, self.details): self.logger.info("The results were successfully pushed to DB") return TestCase.EX_OK else: diff --git a/functest/core/vnf_base.py b/functest/core/vnf_base.py index 2de28c12..fe4e427f 100644 --- a/functest/core/vnf_base.py +++ b/functest/core/vnf_base.py @@ -196,19 +196,19 @@ class VnfOnBoardingBase(base.TestCase): def parse_results(self): exit_code = self.EX_OK - self.criteria = "PASS" + self.result = "PASS" self.logger.info(self.details) # The 2 VNF steps must be OK to get a PASS result if (self.details['vnf']['status'] is not "PASS" or self.details['test_vnf']['status'] is not "PASS"): exit_code = self.EX_RUN_ERROR - self.criteria = "FAIL" + self.result = "FAIL" return exit_code def log_results(self): ft_utils.logger_test_results(self.project_name, self.case_name, - self.criteria, + self.result, self.details) def step_failure(self, error_msg): |