当前位置:网站首页>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 .
边栏推荐
- 自动化测试工具Katalon(Web)测试操作说明
- 短链的设计
- MySQL connected vscode successfully, but this error is reported
- [212] what are three methods for PHP to send post requests
- 本地部署 zeppelin 0.10.1
- 【通信】两层无线 Femtocell 网络上行链路中的最优功率分配附matlab代码
- How does crmeb mall system help marketing?
- Common modification commands of Oracle for tables
- Per capita Swiss number series, Swiss number 4 generation JS reverse analysis
- What does front-end processor mean? What is the main function? What is the difference with fortress machine?
猜你喜欢

若依请求url中带有jsessionid的解决办法

Penetration test --- database security: detailed explanation of SQL injection into database principle

Résumé des connaissances de gradle

Per capita Swiss number series, Swiss number 4 generation JS reverse analysis

matplotlib画柱状图并添加数值到图中

资产安全问题或制约加密行业发展 风控+合规成为平台破局关键

Efficient ETL Testing

Talking about the current malpractice and future development

How to implement Lua entry of API gateway

传统企业要为 Web3 和去中心化做的 11 个准备
随机推荐
Realize colorful lines and shape your heart
Stop saying that microservices can solve all problems
不要再说微服务可以解决一切问题了
同一个作业有两个source,同一链接不同数据库账号,为何第二个链接查出来的数据库列表是第一个账号的
How does win11 restore the traditional right-click menu? Win11 right click to change back to traditional mode
Efficient ETL Testing
B站大佬用我的世界搞出卷積神經網絡,LeCun轉發!爆肝6個月,播放破百萬
Experiment 5: common automation libraries
DevOps可以帮助减少技术债务的十种方式
Koa2 addition, deletion, modification and query of JSON array
Per capita Swiss number series, Swiss number 4 generation JS reverse analysis
The "white paper on the panorama of the digital economy" has been released with great emphasis on the digitalization of insurance
【系统分析师之路】第七章 复盘系统设计(面向服务开发方法)
B 站弹幕 protobuf 协议还原分析
Gradle知识概括
为什么完全背包要用顺序遍历?简要解释一下
MySQL implementation of field segmentation from one line to multiple lines of example code
基础图表解读“东方甄选”爆火出圈数据
Master binary tree in one article
AI表现越差,获得奖金越高?纽约大学博士拿出百万重金,悬赏让大模型表现差劲的任务...
