def on_exec_testcase_button_click(self, event): """ Action performed when user clicks the run testcase button. """ self.log.trace("Handle run testcase button click by user.") result = {'successful': False} try: self.log.debug("Building test run ...") # determine test path from input fields data = self.determine_test_path_from_input_fields() module_name = data['module'] feature_name = data['feature'] story_name = data['user story'] test_name = data['test'] case_name = data['testcase'] # determine publish plan id publish_id = self.input_publish_id.GetString(0, -1) # build test run testrun = TestRun(self.log, self.database, name='Debug Test Run', submodule_id=3, testcases=[], results_plan_id=publish_id) testcases_to_run = testrun.build_testcase_list_for_run(module_id=module_name, feature_id=feature_name, story_id=story_name, test_id=test_name, case_id=case_name)['testcases'] # determine class self.log.trace("Getting string from testcase class input field ...") testcase_class = self.input_testcase_class.GetString( self.input_testcase_class.GetSelection()) testrun.filter_testcases_by_class(testcases_to_run, testcase_class) # execute test case testrun.testcases = testcases_to_run testrun.run() self.log.trace("Handled run testcase button click by user.") result['successful'] = True except BaseException, e: self.handle_exception(e, "handle run testcase button click by user")
# filter by type if testcase_type is not None: testrun.filter_testcases_by_type(testcases, testcase_type) if testcase_type.lower() != 'dvr integration' and module.lower() != 'dvr integration': testrun.filter_testcases_by_type(testcases, 'dvr integration', inclusive=False) # set testcase list for test run testrun.testcases = testcases if build is not None: # setup test environment testrun.setup_test_environment(build, test_name) # execute test run testrun.run() # teardown test environment testrun.teardown_test_environment() else: log.error("Failed to setup test environment. %s is not a valid build." % build) elif mode == 'webtesting': # instance with trace logging and correct db path for Cerberus (web2py) testing database = Database(Logger(logging_level='trace'), path=TARTAROS_WEB_DB_PATH) # initialize test run object testrun = TestRun(log, database, name=test_name, submodule_id=2, results_plan_id=results_plan_id, int_dvr_ip=int_dvr_ip)
def run_test(self, build, test_name, results_plan_id, module=None, feature=None, story=None, test=None, case=None, case_class=None, case_type=None, int_dvr_ip=None, mode=None): """ Run test with given parameters. """ operation = inspect.stack()[0][3] result = None try: self.log.trace("%s ..." % operation.replace('_', ' ')) # instance database for TeamCity testing if str(mode).lower() == 'thanatos': database = Database(Logger(logging_level='info'), path=getcwdu()+"\\tartaros.sqlite") testcase = ThanatosTestCase(self.log, database, case) testcase.run() else: database = Database(Logger(logging_level='info')) # initialize test run object testrun = TestRun(self.log, database, name=test_name, submodule_id=2, results_plan_id=results_plan_id, int_dvr_ip=int_dvr_ip) # build testcase list for test run testcases = testrun.build_testcase_list_for_run(module_id=module, feature_id=feature, story_id=story, test_id=test, case_id=case, case_class=case_class)['testcases'] # filter by class if case_class is not None: testrun.filter_testcases_by_class(testcases, case_class) # filter by type if case_type is not None: testrun.filter_testcases_by_type(testcases, case_type) if case_type.lower() != 'dvr integration' and str(module) != '9'\ and str(module).lower() != 'dvr integration': testrun.filter_testcases_by_type(testcases, 'dvr integration', inclusive=False) # set testcase list for test run testrun.testcases = testcases if str(build).lower() != 'none': # setup test environment testrun.setup_test_environment(build, test_name) else: testrun.setup_test_environment(build, test_name, installing=False) # execute test run testrun.run() # teardown test environment testrun.teardown_test_environment() #else: # self.log.error("Failed to setup test environment. %s is not a valid build." % build) # compile results result = None except BaseException, e: self.handle_exception(self.log, e, operation)