run.py 912 Bytes
Newer Older
jiaqiying committed
1 2 3
#coding:utf-8
import os
import pytest
4 5 6 7 8 9
import argparse
from config import BaseConfig
from common.tools import get_case_dir


def get_parser():
jiaqiying committed
10
    parser = argparse.ArgumentParser(description="argparse")
jiaqiying committed
11
    parser.add_argument('--product', type=str, default=BaseConfig.current_name)
12 13
    return parser

jiaqiying committed
14 15

if __name__ == "__main__":
16
    parser = get_parser()
jiaqiying committed
17
    args = parser.parse_args()
jiaqiying committed
18
    BaseConfig.current_name = args.product
19 20
    # 获取要执行的产品的用例目录
    test_case_dir = get_case_dir(args.product)
jiaqiying committed
21
    print("********此次执行的产品测试用例是:%s********"%test_case_dir)
22 23

    #删除之前报告
jiaqiying committed
24
    for one in os.listdir('./report/tmp'):
jiaqiying committed
25
        if 'json' in one:
jiaqiying committed
26
            os.remove(f'./report/tmp/{one}')
jiaqiying committed
27
    # 生成报告数据
jiaqiying committed
28
    pytest.main(['-v', '-s', test_case_dir, '--alluredir', './report/tmp'])
jiaqiying committed
29
    # 打开报告
30 31 32
    os.system('allure serve ./report/tmp')