run.py 1.16 KB
Newer Older
jiaqiying committed
1 2 3
#coding:utf-8
import os
import pytest
4 5 6
import argparse
from config import BaseConfig
from common.tools import get_case_dir
taoke committed
7
from common.utils import dingTalk
8 9 10


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

jiaqiying committed
15 16

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

    #删除之前报告
25
    os.system('rm ./report/tmp/*.json')
jiaqiying committed
26
    # 生成报告数据
jiaqiying committed
27
    pytest.main(['-v', '-s', test_case_dir, '--alluredir', './report/tmp'])
jiaqiying committed
28
    # 打开报告
taoke committed
29
    # os.system('allure serve ./report/tmp')
30
    # 发送钉钉
taoke committed
31
    dingTalk.dingTalk_markdown(secret="SEC1d08f46da74337cc0e1cd5bb9ad19622d825483343fdfa43ce396881e4745bdb",
taoke committed
32 33
                 webhook="https://oapi.dingtalk.com/robot/send?access_token=f9e005c1a984b9607960345d38669337b1115d1141a0294e98666443b312115b",
                               message="")
34