当前位置:网站首页>Interface joint debugging test script optimization v4.0
Interface joint debugging test script optimization v4.0
2022-07-06 23:46:00 【Night * star】
introduction : Next chapter Interface joint commissioning test script optimization v2.0, This chapter optimizes script parameters , Put the parameters into the file , After the implementation script is compiled once , Later, you only need to maintain files .
Catalog
Optimization task :
Put the relevant interface test parameters into csv In file , Read the relevant parameters through the program , Pass it into the interface test script .
Problems encountered :
Create a csv file , Write the interface parameters into the file ,csv The documents are as follows :
- For common parameters url、expected_result、interfacename Just call it directly .
- But because each interface has different parameters , The number of parameters is also different , You need to use the loop again to read .
- Here, the number of parameters is written directly in front of the parameters , Then define a j The variable is equal to the number of parameters .
- It's not hard to find out ,H Column starts as a loop index The value is 7, And the end value of the loop is 2*j+7.
- So the following different parameter data can be read in the loop , The code reference is as follows .
Script implementation :
# Use parameterization technology to optimize the test script of joint debugging of multiple interfaces import requests import csv class Workflow_Test_v4(): def userinterface_test(self, url, userinfo, expected_result, interfacename): response = requests.post(url, data=userinfo).text print(response) r = response.find(expected_result) if r > 0: print(interfacename, " The test passed ") else: print(interfacename, " Test to fail ") if __name__ == '__main__': workflowobj4 = Workflow_Test_v4() file = open("test1.csv", "r") table = csv.reader(file) for row in table: # Read relevant contents line by line , And set it as the corresponding parameter url = row[1] expected_result = row[3] interfacename = row[5] # print("url yes :", url, " ", "expected_result yes :", expected_result, " ","interfacename yes :", interfacename) # Read interface test data userinfo = {} j = int(row[6]) for i in range(7, 2*j+7, 2): userinfo[row[i]] = row[i+1] # print(userinfo) # Instantiate the test class , Incoming test data workflowobj4.userinterface_test(url, userinfo, expected_result, interfacename)
Summary :
- The problem of script parameterization is mainly to find the rules of parameters
- Common parameters are :
- url: Interface access address
- expected_result: The interface responds to the expected results
- interfacename: The name of the interface
- Parameters of personality : Interface test data is different
- Manually count the number of test data , Write it into the test data template
- Circulation mode : Find the law of circulation , Just analyze a few values
- Initial value ----index = 7
- Termination value ----index = 2*j+7( because python Can't get the last place , So take it as the end value of the range )
- Change a few at a time ---- Because parameters have two values: key value and attribute , So when taking down a parameter , want i+2.
- Save the found parameters in the dictionary : Dictionary name [key] = value namely userinfo[row[i]] = row[i+1]
advantage :
Future interface tests , You only need to maintain the document of interface test data , There is no need to modify any code .
边栏推荐
- [unmanned aerial vehicle] multi unmanned cooperative task allocation program platform, including Matlab code
- Experiment 5: common automation libraries
- Should the jar package of MySQL CDC be placed in different places in the Flink running mode?
- How does crmeb mall system help marketing?
- Station B Big utilise mon monde pour faire un réseau neuronal convolutif, Le Cun Forward! Le foie a explosé pendant 6 mois, et un million de fois.
- 人均瑞数系列,瑞数 4 代 JS 逆向分析
- flinksql select id ,count(*) from a group by id .
- Restoration analysis of protobuf protocol of bullet screen in station B
- The intranet penetrates the zerotier extranet (mobile phone, computer, etc.) to access intranet devices (raspberry pie, NAS, computer, etc.)
- 自动化测试工具Katalon(Web)测试操作说明
猜你喜欢

Cover fake big empty talk in robot material sorting

快手的新生意,还得靠辛巴吆喝?

The programmer said, "I'm 36 years old, and I don't want to be rolled, let alone cut."

Zero code and high return. How to use 40 sets of templates to meet 95% of the reporting needs in the work

How to find out if the U disk file of the computer reinstallation system is hidden

How to implement Lua entry of API gateway

B站大佬用我的世界搞出卷积神经网络,LeCun转发!爆肝6个月,播放破百万

koa2对Json数组增删改查

Station B boss used my world to create convolutional neural network, Lecun forwarding! Burst the liver for 6 months, playing more than one million

电脑重装系统u盘文件被隐藏要怎么找出来
随机推荐
每年 2000 亿投资进入芯片领域,「中国芯」创投正蓬勃
Up to 5million per person per year! Choose people instead of projects, focus on basic scientific research, and scientists dominate the "new cornerstone" funded by Tencent to start the application
若依请求url中带有jsessionid的解决办法
Where does this "judge the operation type according to the op value and assemble SQL by yourself" mean? It means simply using Flink tab
不要再说微服务可以解决一切问题了
The largest single investment in the history of Dachen was IPO today
The problem of ASP reading Oracle Database
The programmer refused the offer because of low salary, HR became angry and netizens exploded
AI金榜题名时,MLPerf榜单的份量究竟有多重?
短链的设计
Isomorphism + cross end, knowing applet +kbone+finclip is enough!
Scholar doctor hahaha
Should the jar package of MySQL CDC be placed in different places in the Flink running mode?
Per capita Swiss number series, Swiss number 4 generation JS reverse analysis
ArrayExpress数据库里的细胞只有两个txt是不是只能根据Line到ENA下载测序跑矩阵?
Please help xampp to do sqlilab is a black
MySQL数据库之JDBC编程
STM32通过串口进入和唤醒停止模式
The "white paper on the panorama of the digital economy" has been released with great emphasis on the digitalization of insurance
Asset security issues or constraints on the development of the encryption industry, risk control + compliance has become the key to breaking the platform
