当前位置:网站首页>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 .
边栏推荐
- 新手问个问题,我现在是单机部署的,提交了一个sql job运行正常,如果我重启了服务job就没了又得
- The important data in the computer was accidentally deleted by mistake, which can be quickly retrieved by this method
- 吴恩达2022机器学习课程评测来了!
- Who said that new consumer brands collapsed? Someone behind me won
- MATLIB从excel表中读取数据并画出函数图像
- Gradle知識概括
- 自动化测试工具Katalon(Web)测试操作说明
- 求帮助xampp做sqlilab是一片黑
- JS import excel & Export Excel
- Résumé des connaissances de gradle
猜你喜欢
吴恩达2022机器学习课程评测来了!
快讯 l Huobi Ventures与Genesis公链深入接洽中
leetcode:236. The nearest common ancestor of binary tree
Talking about the current malpractice and future development
Why is bat still addicted to 996 when the four-day working system is being tried out in Britain?
Restoration analysis of protobuf protocol of bullet screen in station B
AI金榜题名时,MLPerf榜单的份量究竟有多重?
Cover fake big empty talk in robot material sorting
If the request URL contains jsessionid, the solution
每日刷题记录 (十五)
随机推荐
Local deployment Zeppelin 0.10.1
请问async i/o可以由udf算子实现然后用sql api调用吗?目前好像只看到Datastre
每日刷题记录 (十五)
mysql-cdc 的jar包 ,在flink运行模式下,是不是要放在不同的地方呢?
Leetcode problem solving - 889 Construct binary tree according to preorder and postorder traversal
DevOps可以帮助减少技术债务的十种方式
这个『根据 op 值判断操作类型来自己组装 sql』是指在哪里实现?是指单纯用 Flink Tabl
I've been laid off, and I'll lose money for everything. The days when I once made a monthly salary of 20000 are not coming back
(1) Chang'an chain learning notes - start Chang'an chain
Pdf batch splitting, merging, bookmark extraction, bookmark writing gadget
Summary of three methods for MySQL to view table structure
Without CD, I'll teach you a trick to restore the factory settings of win10 system
Computer reinstallation system teaching, one click fool operation, 80% of people have learned
Where does this "judge the operation type according to the op value and assemble SQL by yourself" mean? It means simply using Flink tab
How to implement Lua entry of API gateway
Scholar doctor hahaha
MySQL数据库之JDBC编程
CRMEB 商城系统如何助力营销?
Use mitmproxy to cache 360 degree panoramic web pages offline
Common modification commands of Oracle for tables