当前位置:网站首页>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 .
边栏推荐
- Wu Enda 2022 machine learning course evaluation is coming!
- 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
- Laravel8 uses passport authentication to log in and generate a token
- Computer reinstallation system teaching, one click fool operation, 80% of people have learned
- 内网穿透zerotier 外网(手机、电脑等)访问内网设备(树莓派、NAS、电脑等)
- 浅谈现在的弊端与未来的发展
- Gold three silver four, don't change jobs
- The problem of ASP reading Oracle Database
- Realize colorful lines and shape your heart
- 零代码高回报,如何用40套模板,能满足工作中95%的报表需求
猜你喜欢

【通信】两层无线 Femtocell 网络上行链路中的最优功率分配附matlab代码

Résumé des connaissances de gradle

Entropy information entropy cross entropy

Asset security issues or constraints on the development of the encryption industry, risk control + compliance has become the key to breaking the platform

Please help xampp to do sqlilab is a black

After 3 years of testing bytecan software, I was ruthlessly dismissed in February, trying to wake up my brother who was paddling

The intranet penetrates the zerotier extranet (mobile phone, computer, etc.) to access intranet devices (raspberry pie, NAS, computer, etc.)

Rider离线使用Nuget包的方法

MATLIB reads data from excel table and draws function image

leetcode:236. 二叉树的最近公共祖先
随机推荐
(LeetCode)两数之和
app通用功能测试用例
Penetration test --- database security: detailed explanation of SQL injection into database principle
本地部署 zeppelin 0.10.1
ArrayExpress数据库里的细胞只有两个txt是不是只能根据Line到ENA下载测序跑矩阵?
Scholar doctor hahaha
Competition between public and private chains in data privacy and throughput
Per capita Swiss number series, Swiss number 4 generation JS reverse analysis
浅谈现在的弊端与未来的发展
谁说新消费品牌大溃败?背后有人赢麻了
The tutorial of computer reinstallation win10 system is simple and easy to understand. It can be reinstalled directly without U disk
DevOps可以帮助减少技术债务的十种方式
How does win11 restore the traditional right-click menu? Win11 right click to change back to traditional mode
Ajout, suppression et modification d'un tableau json par JS
How to find out if the U disk file of the computer reinstallation system is hidden
Oracle对表进行的常用修改命令
达晨史上最大单笔投资,今天IPO了
设计一个抢红包系统
【OFDM通信】基于深度学习的OFDM系统信号检测附matlab代码
B站大佬用我的世界搞出卷積神經網絡,LeCun轉發!爆肝6個月,播放破百萬
