当前位置:网站首页>Interface joint commissioning test script optimization V5.0 (end)
Interface joint commissioning test script optimization V5.0 (end)
2022-07-05 04:34:00 【Night * star】
introduction : This chapter will be based on v4.0, Prepare interface test report , At the same time, summarize the previous optimization stages .
Directory of interface joint commissioning test optimization stage :
This time v5.0 List of articles
Finally, the complete script implementation
V5.0 Optimization task
Write test report
Design thinking
- The actual response results and test conclusions of the interface need to be stored in the test report .
- The test report should include : The name of the interface , The actual return value of the interface , Interface test conclusion .
- You can define a result_data The dictionary of is used to store the actual return value of the interface and the test conclusion , Last need return After obtaining data result_data
- Define a new method to write the dictionary data content into the test report .
- Because the dictionary contains keys + value , So when writing content circularly, use :for key, value in result_data.items():
# Write relevant test conclusions into the test report def result_report(self, interfacename, reportfilename, result_data): # This time it is written in the form of addition , use a( Of course w Overwriting is also possible ) file = open(reportfilename, "a") for key, value in result_data.items(): file.write(interfacename + "," + key + "," + value + ",") # Write a line of test conclusion and then wrap file.write("\n") # Remember to close the file after writing file.close()
Finally, the complete script implementation
# Optimize the test script structure , Script parameterization and test report all technologies are combined import requests import csv # Define test classes class Workflow_Test_v6(): # Interface test general script def userinterface_test(self, url, userinfo, expected_result, interfacename): # Define dictionary data , Store the actual interface response results and test conclusions result_data = {} # Send the request and get the response response = requests.post(url, data=userinfo).text # print(response) # Store the actual return value of the interface into the dictionary result_data[" The actual return value of the interface "] = str(response) r = response.find(expected_result) if r > 0: print(interfacename, " The test passed ") # Store the test conclusion in the dictionary result_data[" Test conclusion "] = " The test passed " else: print(interfacename, " Test to fail ") result_data[" Test conclusion "] = " Test to fail " print(result_data) return result_data # Write relevant test conclusions into the test report def result_report(self, interfacename, reportfilename, result_data): # This time it is written in the form of addition , use a( Of course w Overwriting is also possible ) file = open(reportfilename, "a") for key, value in result_data.items(): file.write(interfacename + "," + key + "," + value + ",") # Write a line of test conclusion and then wrap file.write("\n") # Remember to close the file after writing file.close() if __name__ == '__main__': workflowobj6 = Workflow_Test_v6() file = open("test1.csv", "r") reportfilename = "test_result6.csv" 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 = {} result_data = {} 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 result_data = workflowobj6.userinterface_test(url, userinfo, expected_result, interfacename) # Call write test report file , Incoming test conclusion and actual interface response result workflowobj6.result_report(interfacename, reportfilename, result_data)
Be careful : Every time open csv Remember to close the file after viewing it , Otherwise, if the document is open , The program won't run .
advantage :
- A scripted program can correspond to several interface tests
- You only need to maintain the test data to complete the test of any group of interfaces
- All interface test conclusions can automatically generate test report files .
边栏推荐
- CSDN正文自动生成目录
- 【虚幻引擎UE】实现背景模糊下近景旋转操作物体的方法及踩坑记录
- level17
- 概率论与数理统计考试重点复习路线
- Matplotlib draws three-dimensional scatter and surface graphs
- English topic assignment (27)
- Key review route of probability theory and mathematical statistics examination
- QT Bluetooth: a class for searching Bluetooth devices -- qbluetooth devicediscoveryagent
- [thingsboard] how to replace the homepage logo
- Machine learning -- neural network
猜你喜欢
Managed service network: application architecture evolution in the cloud native Era
American 5g open ran suffered another major setback, and its attempt to counter China's 5g technology has failed
【thingsboard】替换首页logo的方法
Live broadcast preview | container service ack elasticity prediction best practice
[crampon game] MC tutorial - first day of survival
【虚幻引擎UE】运行和启动的区别,常见问题分析
Function (error prone)
Qt蓝牙:搜索蓝牙设备的类——QBluetoothDeviceDiscoveryAgent
揭秘技术 Leader 必备的七大清奇脑回路
[PCL self study: feature9] global aligned spatial distribution (GASD) descriptor (continuously updated)
随机推荐
Neural networks and deep learning Chapter 5: convolutional neural networks reading questions
函數(易錯)
English topic assignment (27)
【UNIAPP】系统热更新实现思路
[moteur illusoire UE] il ne faut que six étapes pour réaliser le déploiement du flux de pixels ue5 et éviter les détours! (4.26 et 4.27 principes similaires)
防护电路中的元器件
Sword finger offer 07 Rebuild binary tree
[PCL self study: feature9] global aligned spatial distribution (GASD) descriptor (continuously updated)
介绍汉明距离及计算示例
[phantom engine UE] package error appears! Solutions to findpin errors
Invalid bound statement (not found) in idea -- problem solving
【虚幻引擎UE】打包报错出现!FindPin错误的解决办法
【虚幻引擎UE】运行和启动的区别,常见问题分析
Kwai, Tiktok, video number, battle content payment
Seven join join queries of MySQL
File upload bypass summary (upload labs 21 customs clearance tutorial attached)
About the prompt loading after appscan is opened: guilogic, it keeps loading and gets stuck. My personal solution. (it may be the first solution available in the whole network at present)
【虚幻引擎UE】实现测绘三脚架展开动画制作
【科普】热设计基础知识:5G光器件之散热分析
Function (basic: parameter, return value)