run.py 1.17 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
    # 打开报告
29
    # os.system('allure serve ./report/tmp')
fanxun committed
30 31

    # 发送钉钉 ()
32 33 34
    dingTalk.dingTalk_markdown(secret="SEC465015385218e70a94f107a16f72dd33d8fc118c3b2a631e0433685302f2fbb3",
                 webhook="https://oapi.dingtalk.com/robot/send?access_token=229908a83825ed56abbf728d3382e446a4e8a90e9ad302c37a036bcbccbbf9ee",
                               message="")
35