forked from wangxiaoxi3/API_Automation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
50 lines (38 loc) · 1.11 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
# -*- coding: utf-8 -*-
# @Time : 2018/7/31 上午10:42
# @Author : WangJuan
# @File : run.py
"""
运行用例集:
python3 run.py
# '--allure_severities=critical, blocker'
# '--allure_stories=测试模块_demo1, 测试模块_demo2'
# '--allure_features=测试features'
"""
import pytest
from Common import Log
from Common import Shell
from Conf import Config
from Common import Email
if __name__ == '__main__':
conf = Config.Config()
log = Log.MyLog()
log.info('初始化配置文件, path=' + conf.conf_path)
shell = Shell.Shell()
xml_report_path = conf.xml_report_path
html_report_path = conf.html_report_path
# 定义测试集
args = ['-s', '-q', '--alluredir', xml_report_path]
pytest.main(args)
cmd = 'allure generate %s -o %s' % (xml_report_path, html_report_path)
try:
shell.invoke(cmd)
except Exception:
log.error('执行用例失败,请检查环境配置')
raise
try:
mail = Email.SendMail()
mail.sendMail()
except Exception as e:
log.error('发送邮件失败,请检查邮件配置')
raise