当前位置:网站首页>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 .
边栏推荐
- Fonction (sujette aux erreurs)
- Power management bus (pmbus)
- Learning MVVM notes (1)
- 可观测|时序数据降采样在Prometheus实践复盘
- mxnet导入报各种libcudart*.so、 libcuda*.so找不到
- The remainder operation is a hash function
- Scope of package class package
- [phantom engine UE] realize the animation production of mapping tripod deployment
- MacBook安装postgreSQL+postgis
- Hexadecimal to decimal
猜你喜欢

防护电路中的元器件

MacBook安装postgreSQL+postgis

Managed service network: application architecture evolution in the cloud native Era
![[AI bulletin 20220211] the hard core up owner has built a lidar and detailed AI accelerator](/img/cc/06580ce7b553182968d273841a78b4.jpg)
[AI bulletin 20220211] the hard core up owner has built a lidar and detailed AI accelerator

程序员应该怎么学数学

【科普】热设计基础知识:5G光器件之散热分析
![[PCL self study: feature9] global aligned spatial distribution (GASD) descriptor (continuously updated)](/img/2b/933586b6feff1d48c5bee11cd734ba.jpg)
[PCL self study: feature9] global aligned spatial distribution (GASD) descriptor (continuously updated)

level18

Invalid bound statement (not found) in idea -- problem solving

MacBook installation postgresql+postgis
随机推荐
C26451: arithmetic overflow: use the operator * on a 4-byte value, and then convert the result to an 8-byte value. To avoid overflow, cast the value to wide type before calling the operator * (io.2)
MacBook installation postgresql+postgis
Aperçu en direct | Services de conteneurs ACK flexible Prediction Best Practices
Machine learning -- neural network
官宣!第三届云原生编程挑战赛正式启动!
【虚幻引擎UE】运行和启动的区别,常见问题分析
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)
介绍汉明距离及计算示例
CUDA Programming atomic operation atomicadd reports error err:msb3721, return code 1
All in one 1413: determine base
解密函数计算异步任务能力之「任务的状态及生命周期管理」
2022-2028 global and Chinese video coding and transcoding Market Research Report
【UNIAPP】系统热更新实现思路
Fonction (sujette aux erreurs)
指针函数(基础)
Debug insights
User behavior collection platform
[thingsboard] how to replace the homepage logo
49 pictures and 26 questions explain in detail what is WiFi?
OWASP top 10 vulnerability Guide (2021)