def reporter(testrail_client): reporter = Reporter(xunit_report='tests/xunit_files/report.xml', env_description='vlan_ceph', test_results_link="http://test_job/", case_mapper=None, paste_url='http://example.com/') reporter.config_testrail(base_url="https://testrail", username="******", password="******", milestone="0.1", project="Test Project", tests_suite="Test Suite", plan_name="Plan name") return reporter
def main(args=None): args = args or sys.argv[1:] args = parse_args(args) if not args.testrail_plan_name: args.testrail_plan_name = ('{0.testrail_milestone} iso ' '#{0.iso_id}').format(args) msg = ("--iso-id parameter is DEPRECATED. " "It is recommended to use --testrail-plan-name parameter.") warnings.warn(msg, DeprecationWarning) logger_dict = dict(stream=sys.stderr) if args.verbose: logger_dict['level'] = logging.DEBUG logging.basicConfig(**logger_dict) case_mapper = CaseMapper( xunit_name_template=args.xunit_name_template, testrail_name_template=args.testrail_name_template) reporter = Reporter(xunit_report=args.xunit_report, env_description=args.env_description, test_results_link=args.test_results_link, case_mapper=case_mapper, paste_url=args.paste_url) suite = args.testrail_suite.format(args) reporter.config_testrail(base_url=args.testrail_url, username=args.testrail_user, password=args.testrail_password, milestone=args.testrail_milestone, project=args.testrail_project, plan_name=args.testrail_plan_name, tests_suite=suite, send_skipped=args.send_skipped) reporter.execute()
def main(args=None): args = args or sys.argv[1:] args = parse_args(args) if not args.testrail_plan_name: args.testrail_plan_name = ('{0.testrail_milestone} iso ' '#{0.iso_id}').format(args) msg = ("--iso-id parameter is DEPRECATED. " "It is recommended to use --testrail-plan-name parameter.") warnings.warn(msg, DeprecationWarning) logger_dict = dict(stream=sys.stderr) if args.verbose: logger_dict['level'] = logging.DEBUG logging.basicConfig(**logger_dict) case_mapper = TemplateCaseMapper( xunit_name_template=args.xunit_name_template, testrail_name_template=args.testrail_name_template) reporter = Reporter( xunit_report=args.xunit_report, env_description=args.env_description, test_results_link=args.test_results_link, case_mapper=case_mapper, paste_url=args.paste_url) suite = args.testrail_suite.format(args) reporter.config_testrail( base_url=args.testrail_url, username=args.testrail_user, password=args.testrail_password, milestone=args.testrail_milestone, project=args.testrail_project, plan_name=args.testrail_plan_name, tests_suite=suite, send_skipped=args.send_skipped, use_test_run_if_exists=args.use_test_run_if_exists) if args.test_plan_only: plan = reporter.get_or_create_plan() reporter.print_plan_url(plan) return xunit_suite, _ = reporter.get_xunit_test_suite() mapping = reporter.map_cases(xunit_suite) if not args.dry_run: cases = reporter.fill_case_results(mapping) if len(cases) == 0: logger.warning('No cases matched, programm will terminated') return plan = reporter.get_or_create_plan() test_run = reporter.get_or_create_test_run(plan, cases) test_run.add_results_for_cases(cases) reporter.print_run_url(test_run) else: print_mapping_table(mapping)
def main(args=None): args = args or sys.argv[1:] args = parse_args(args) if not args.testrail_plan_name: args.testrail_plan_name = ('{0.testrail_milestone} iso ' '#{0.iso_id}').format(args) msg = ("--iso-id parameter is DEPRECATED. " "It is recommended to use --testrail-plan-name parameter.") warnings.warn(msg, DeprecationWarning) logger_dict = dict(stream=sys.stderr) if args.verbose: logger_dict['level'] = logging.DEBUG logging.basicConfig(**logger_dict) case_mapper = TemplateCaseMapper( xunit_name_template=args.xunit_name_template, testrail_name_template=args.testrail_name_template, testrail_case_max_name_lenght=args.testrail_case_max_name_lenght) reporter = Reporter(xunit_report=args.xunit_report, env_description=args.env_description, test_results_link=args.test_results_link, case_mapper=case_mapper, paste_url=args.paste_url) suite = args.testrail_suite.format(args) reporter.config_testrail( base_url=args.testrail_url, username=args.testrail_user, password=args.testrail_password, milestone=args.testrail_milestone, project=args.testrail_project, plan_name=args.testrail_plan_name, tests_suite=suite, send_skipped=args.send_skipped, send_duplicates=args.send_duplicates, use_test_run_if_exists=args.use_test_run_if_exists, testrail_add_missing_cases=args.testrail_add_missing_cases, testrail_case_custom_fields=args.testrail_case_custom_fields, testrail_case_section_name=args.testrail_case_section_name, testrail_configuration_name=args.testrail_configuration_name, dry_run=args.dry_run, request_timeout=args.testrail_request_timeout) xunit_suite, _ = reporter.get_xunit_test_suite() mapping = reporter.map_cases(xunit_suite) if not args.dry_run: cases = reporter.fill_case_results(mapping) if len(cases) == 0: logger.warning('No cases matched, program will terminated') return plan = reporter.get_or_create_plan() run_description = args.testrail_run_description test_run = reporter.get_or_create_test_run(plan, cases, run_description) test_run.add_results_for_cases(cases) reporter.print_run_url(test_run) else: print_mapping_table(mapping)