当前位置:网站首页>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 .
边栏推荐
- Oracle对表进行的常用修改命令
- Today's sleep quality record 78 points
- 每年 2000 亿投资进入芯片领域,「中国芯」创投正蓬勃
- A novice asks a question. I am now deployed on a single machine. I submitted an SQL job and it runs normally. If I restart the service job, it will disappear and I will have to
- 每人每年最高500万经费!选人不选项目,专注基础科研,科学家主导腾讯出资的「新基石」启动申报...
- Experiment 6: installing eve-ng
- Microsoft win11 is still "unsatisfactory". Multi user feedback will cause frequent MSI crashes
- Koa2 addition, deletion, modification and query of JSON array
- 自动化测试工具Katalon(Web)测试操作说明
- JDBC programming of MySQL database
猜你喜欢
Gradle knowledge generalization
Can online reload system software be used safely? Test use experience to share with you
Use mitmproxy to cache 360 degree panoramic web pages offline
Daily question brushing record (XV)
Gpt-3 is a peer review online when it has been submitted for its own research
【无人机】多无人协同任务分配程序平台含Matlab代码
The problem of ASP reading Oracle Database
MySQL数据库之JDBC编程
11 preparations for Web3 and Decentralization for traditional enterprises
(1) Chang'an chain learning notes - start Chang'an chain
随机推荐
【无人机】多无人协同任务分配程序平台含Matlab代码
MySQL connected vscode successfully, but this error is reported
js导入excel&导出excel
The programmer refused the offer because of low salary, HR became angry and netizens exploded
[communication] optimal power allocation in the uplink of two-layer wireless femtocell network with matlab code
leetcode:236. The nearest common ancestor of binary tree
MATLIB从excel表中读取数据并画出函数图像
Let me ask you if there are any documents or cases of flynk SQL generation jobs. I know that flynk cli can create tables and specify items
flinksql select id ,count(*) from a group by id .
同一个作业有两个source,同一链接不同数据库账号,为何第二个链接查出来的数据库列表是第一个账号的
人均瑞数系列,瑞数 4 代 JS 逆向分析
传统企业要为 Web3 和去中心化做的 11 个准备
Penetration test --- database security: detailed explanation of SQL injection into database principle
A novice asks a question. I am now deployed on a single machine. I submitted an SQL job and it runs normally. If I restart the service job, it will disappear and I will have to
Per capita Swiss number series, Swiss number 4 generation JS reverse analysis
koa2对Json数组增删改查
【212】php发送post请求有哪三种方法
Without CD, I'll teach you a trick to restore the factory settings of win10 system
Master binary tree in one article
Knowledge * review