import unittest
import os, datetime, time
from BeautifulReport import BeautifulReport
from framework.excel_oprate import read_config
from tomorrow import threads
root_dir = os.path.dirname(os.path.abspath(__file__)).replace('\\', '/')
test_dir = root_dir + '/testcases'
report_dir = root_dir + '/test_report'
def add_cases():
discover = unittest.defaultTestLoader.discover(test_dir, 'test*.py', None)
testsuit01 = unittest.TestSuite()
testsuit02 = unittest.TestSuite()
table_datas = read_config()
for test01 in discover:
for test02 in test01:
for test03 in test02:
testsuit01.addTest(test03)
for case in testsuit01:
case01 = str(case)
case01 = case01.split('(')[0].strip()
for i in range(len(table_datas)):
case_name = table_datas[i]['测试用例']
if case_name == case01:
if table_datas[i]['是否执行'] == float(1.0):
testsuit02.addTest(case)
print('----->要运行的测试用例:')
for te in testsuit02:
print(te)
return testsuit02
@threads(2)
def run(test_suit):
now = datetime.datetime.now().strftime('%Y-%m-%d %H_%M_%S')
filename = '测试报告' + str(now)
result = BeautifulReport(test_suit)
result.report(filename=filename, description='测试报告',
log_path=report_dir)
if __name__ == '__main__':
cases = add_cases()
for case in cases:
run(case)
通过tomorrow实现自动化脚本的并发执行
猜你喜欢
转载自blog.csdn.net/qq_37969201/article/details/87865440
今日推荐
周排行