1、测试用例批量执行

1、run.py 运行方式:新建一个run.py 通过在命令行运行 python run.py 执行。
2、run.bat运行方式:在win系统下建一个run.bat批处理文件,通过双击该文件执行。
3、在linux系统 run.sh
4、jenkins环境下 构建shell脚本运行指令。

示例1:run.py 运行方式,run.py 文件内容如下(仅供参考)

import pytest
import allure
import os
if __name__ == '__main__':
    for one in os.listdir('report/tmp'):  # 列出对应文件夹的数据
        if 'json' in one:
            os.remove(f'../report/tmp/{one}')
    # pytest.main(['test_myShop.py', '-s', '--alluredir', '../report/tmp'])
    print(__file__)
    print(os.getcwd())  #当前路径
    pytest.main(['test_1.py','test_Shop.py','-s', '-v', '--alluredir', '../report/tmp'])
    os.system('allure serve ../report/tmp')

示例2:run.bat运行方式,run.bat 文件内容如下(仅供参考)

cd ./test_case
pytest -s --alluredir ../report/tmp
allure serve ../report/tmp

更多推荐