当前位置:网站首页>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 .
边栏推荐
- Reading and visualization of DICOM, MHD and raw files in medical imaging
- How to force activerecord to reload a class- How do I force ActiveRecord to reload a class?
- Raki's notes on reading paper: soft gazetteers for low resource named entity recognition
- A solution to the problem that variables cannot change dynamically when debugging in keil5
- [crampon programming] lintcode decoding Encyclopedia - 872 termination process
- Introduction to RT thread kernel (5) -- memory management
- 机器学习 --- 神经网络
- Realize the attention function of the article in the applet
- PHP reads the INI file and writes the modified content
- 函数(易错)
猜你喜欢
The principle of attention mechanism and its application in seq2seq (bahadanau attention)
函數(易錯)
10 programming habits that web developers should develop
OWASP top 10 vulnerability Guide (2021)
官宣!第三届云原生编程挑战赛正式启动!
【thingsboard】替换首页logo的方法
美国5G Open RAN再遭重大挫败,抗衡中国5G技术的图谋已告失败
Kwai, Tiktok, video number, battle content payment
Discussion on the dimension of confrontation subspace
2022-2028 global and Chinese virtual data storage Market Research Report
随机推荐
WeNet:面向工业落地的E2E语音识别工具
Rk3399 platform development series explanation (network debugging) 7.29 summary of network performance tools
Discussion on the dimension of confrontation subspace
美国5G Open RAN再遭重大挫败,抗衡中国5G技术的图谋已告失败
[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)
MacBook installation postgresql+postgis
PHP reads the INI file and writes the modified content
How should programmers learn mathematics
Key review route of probability theory and mathematical statistics examination
File upload bypass summary (upload labs 21 customs clearance tutorial attached)
QT Bluetooth: a class for searching Bluetooth devices -- qbluetooth devicediscoveryagent
[crampon programming] lintcode decoding Encyclopedia - 1100 strange printer
直播預告 | 容器服務 ACK 彈性預測最佳實踐
Mode in BST (binary tree & Notes on question brushing)
Sword finger offer 04 Search in two-dimensional array
NetSetMan pro (IP fast switching tool) official Chinese version v5.1.0 | computer IP switching software download
官宣!第三届云原生编程挑战赛正式启动!
[crampon programming] lintcode decoding Encyclopedia - 872 termination process
Fuel consumption calculator
Function (basic: parameter, return value)