-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
74 lines (50 loc) · 1.46 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date : 2020/2/4
# @Author : Mcen ([email protected])
# @Name : run
"""
运行用例集:
python3 run.py
# '--allure_severities=critical, blocker'
# '--allure_stories=测试模块_demo1, 测试模块_demo2'
# '--allure_features=测试features'
"""
import sys
import pytest
from utils.shell import Shell
from base.element_path import Element
from utils.common import CommonUtil
from utils.send_email import SendMail
from utils.logging_conf import loggering
import logging
sys.path.append(Element.Allure_Path)
loggering()
def run():
xml_report_path = Element.REPORT_XML
html_report_path = Element.REPORT_HTML
CommonUtil().remore_filedir(html_report_path)
CommonUtil().remore_filedir(xml_report_path)
logging.info('运行测试用例')
# 定义测试集
# args = ['-s', '-q', '--alluredir', xml_report_path]
# pytest.main(args)
pytest.main()
run_allure_html(xml_report_path, html_report_path)
# 发送邮件
# SendMail().send_mail()
def run_allure_html(xml_report_path, html_report_path):
"""
通过XML文件生成HTML报告
:param xml_report_path:
:param html_report_path:
:return:
"""
try:
cmd = 'allure generate %s -o %s' % (xml_report_path, html_report_path)
Shell.run_shell(cmd)
except Exception:
logging.error('执行用例失败,请检查环境配置')
raise
if __name__ == '__main__':
run()