-
Notifications
You must be signed in to change notification settings - Fork 2
/
run_all_test_case.py
32 lines (26 loc) · 1.11 KB
/
run_all_test_case.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
import unittest
from src.util import html_report
from src.util import driver
import approot
class RunAllTests(object):
def __init__(self):
self.test_case_path = "./test_case"
self.title = "自动化测试报告"
self.description = "测试报告"
def run(self):
test_suite = unittest.TestLoader().discover(self.test_case_path, "test_unit*.py")
# 启动测试时创建文件夹并获取报告的名字
daf = html_report.DirAndFiles()
daf.create_dir(title=self.title)
report_path = html_report.GlobalMsg.get_value("report_path")
fp = open(report_path, "wb")
runner = html_report.HTMLTestRunner(stream=fp, title=self.title, description=self.description, tester=input("请输入你的名字:"))
runner.run(test_suite)
fp.close()
# 用例测试完毕,打开测试报告
driver_class = driver.Driver()
my_driver = driver_class.get_driver('firefox')
report_path = approot.get_root() + report_path
my_driver.get("file://" + report_path)
if __name__ == "__main__":
RunAllTests().run()