Python测试用例,本地运行器

1. 通过os.walk扫描代码,记录路径;

2. 导入每个测试用例,运行;收集返回值;

script_dict = {'test_case01': 'script/module_A/test_case01'}
test_conf = {'argsA': 'hw'}
run_result = {}
for script, path in script_dict.items():
    import_path = os.path.join(path, script).replace('\\', '.')
    now_i = importlib.import_module(import_path)
    dir_key = import_path.split('.')[-2]
    current_script = now_i.__getattribute__(script)
    now_result_dict = {script: current_script.main(current_script, config=test_conf)}
    if dir_key in run_result:
        run_result[dir_key].update(now_result_dict)
    else:
        run_result[dir_key] = now_result_dict

3. 再根据结果,及用例脚本运行日志,生成测试报告;

posted on 2020-04-23 13:19  旧楚布衣  阅读(230)  评论(0编辑  收藏  举报