-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_all.py
More file actions
31 lines (28 loc) · 1020 Bytes
/
Copy pathrun_all.py
File metadata and controls
31 lines (28 loc) · 1020 Bytes
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
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName:run_all.py
# @Time :2020/7/22 15:14
# @Author :Harry
'''批量执行用例生成报告'''
import time
import unittest
from HTMLTestRunner import HTMLTestRunner
# 批量执行用例
from lib.mail_lib import send_mail
from lib.path_lib import REPORT_PATH, CASE_PATH
print(CASE_PATH)
discover = unittest.defaultTestLoader.discover(start_dir=CASE_PATH,
pattern="test*.py",
top_level_dir=None)
time_str = time.strftime("%Y%m%d%H%M%S", time.localtime())
report_name = REPORT_PATH + '/reoprt-' + time_str + '.html'
title = "ECShop自动化测试"
print(report_name)
with open(report_name, 'wb+') as f:
runner = HTMLTestRunner(stream=f,
title=title,
description="自动化测试报告详情")
runner.run(discover)
# 发送邮件报告
#
send_mail(mail_title=title, mail_body=report_name, mail_type='html')