-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.py
57 lines (48 loc) · 1.99 KB
/
run.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from common.run_method import RunMethod
from common.get_data import GetData
from common.assert_result import CommonUtil
import json
from common.depend_data import DependdentData
from conf.set_token import Get_Token
class RunTest:
pass_count = []
fail_count = []
def __int__(self):
self.run_method =RunMethod()
self.data = GetData()
self.com_util = CommonUtil()
def go_on_run(self,i):#运行总函数
# rows_count = GetData().get_case_lines()
# for i in range(1,rows_count):
is_run = GetData().get_is_run(i)
if is_run:
url = Get_Token().get_url(client_type=GetData().get_client_type(i),api=GetData().get_api(i))
method = GetData().get_request_method(i)
case_name =GetData().get_case_name(i)
data = GetData().get_data(i)
# print(url,data,method)
data = json.loads(data)
header = Get_Token().get_header(i)
expect = GetData().get_expect_data(i)
depend_case=GetData().is_depend(i)
if depend_case !=None:
#获取响应数据
self.depend = DependdentData(depend_case)
depend_response_data=self.depend.get_data_for_key(i)
#获取依赖的key
depend_key =GetData().get_depend_field(int(depend_case))
data[depend_key]=depend_response_data
RunMethod().run_main(method, url, header, data)
res = RunMethod().run_main(method,url,header,data)
if CommonUtil().is_content(expect,res.text):
GetData().write_result(i,'测试通过')
self.pass_count.append(i)
else:
GetData().write_result(i, res.text)
self.fail_count.append(i)
return[i,case_name,method,url,data,expect,res.text]
if __name__ == '__main__':
run = RunTest()
rows_count = GetData().get_case_lines()
for i in range(1,rows_count):
run.go_on_run(i)