-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_fail_case.py
More file actions
53 lines (48 loc) · 1.66 KB
/
run_fail_case.py
File metadata and controls
53 lines (48 loc) · 1.66 KB
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
50
51
52
from common import HTMLTestRunner_params
from common.ReadConfig import ReadConfig
from common import sendMail
from common.Log import Log
from common.get_csv import *
import unittest
import csv
log=Log()
Prodir =Propath()
def case_list(file):
caselist=[]
with open(file)as fb:
reader=csv.reader(fb)
caselists=[ read for read in reader]
for word in caselists:
if len(word) != 0:
caselist.append(word[0])
return caselist
def make_suite(caselist):
test_suite = unittest.TestSuite()
suite_module=[]
casepath = Prodir + '/testCase/'
for casename in caselist:
discover = unittest.defaultTestLoader.discover(casepath, pattern=casename+'.py', top_level_dir=None)
suite_module.append(discover)
if len(suite_module) > 0:
for suite in suite_module:
for test_name in suite:
test_suite.addTest(test_name)
else:
return None
return test_suite
def runfailcase(file):
caselist=case_list(file)
suite=make_suite(caselist)
log.info('============================TEST START============(Failcase)==================')
report=log.get_report_path()
fp=open(report,'wb')
runner=HTMLTestRunner_params.HTMLTestRunner(stream=fp,
title=u'接口测试报告',
description=u'接口测试的所有用例的执行')
runner.run(suite)
fp.close()
# sendMail.send_mail(report)
log.info('==============================TEST END=======================================')
if __name__ == '__main__':
failcasepath='failcaselist.csv'
runfailcase(failcasepath)