运行文件的设定

不多讲。。。。。

 1 import sys, os, time, unittest
 2 from BSTestRunner import BSTestRunner
 3 from Email import sendemail
 4 
 5 base_dir = os.getcwd()
 6 
 7 sys.path.append(base_dir + '\public')
 8 
 9 '''执行测试报告的路径'''
10 run_dir = os.path.join(base_dir + '\TestProject\')
11 
12 '''存放测试报告的路径'''
13 report_dir = os.path.join(base_dir + '\TestReport\testresult\')
14 now_date = time.strftime("%Y-%m-%d %H_%M_%S")
15 
16 reportNAME = report_dir + now_date + 'htmlResult.html'
17 
18 discover = unittest.defaultTestLoader.discover(run_dir, pattern='test_url.py')
19 
20 if __name__ == "__main__":
21     with open(reportNAME, 'wb') as fp:
22         runner = BSTestRunner(stream=fp,
23                               verbosity=2,
24                               title='自动化测试报告',
25                               description='BBS Login test')
26 
27         runner.run(discover)
28     fp.close()
29     '''发送邮件'''
30     sendemail()
View Code
原文地址:https://www.cnblogs.com/97xiaolai/p/11738865.html