The updated version of the pure python self-developed interface automation script, so that Xiaobai can also achieve 0 to 10,000+ interface automation use cases
Posted May 23, 2020 • 4 min read
Are you still using postman \ jmeter for interface automation? Do you use the open source framework of Python [unittest \ pytest]to transfer interface code codes one by one? Online surveys are for beginners or advanced testers, most people and training institutions still do this interface automation!
This issue introduces a top three Python self-developed interface automation framework. Of course, it also uses reading from Excel as a driver and storing test data to complete interface automation. Please read this article carefully and you will know the charm of the script! A
Excited, shaking hands, pick up your little bench, sit ready, and then I will lead you into the lazy team! A
Finally, the internal test is completed, and the BUG is solved. If there is still a BUG, it is natural! A
The original article on this issue is now:[Python script to achieve interface automation to easily get thousands of interface use cases]The interface automation script used in the update version! In fact, there are more than a thousand, tens of thousands of interface use cases business complex upper and lower related interfaces can be easily managed, and the new project interface is directly used, not only for regression testing, can greatly improve work efficiency.
Is efficiency still far from promotion and salary increase?
"What features are added in this version?"
1. All the status codes, response values and expected results of previous versions are judged by excel function, and now they are moved into the code and written into excel after unified judgment 2. The previous version's response value asserted that only one field can be judged, and multiple fields can now be judged. 3. The previous version test results are all statistics in the excel table, and the excel results also retain the previous format. All statistics are added. Then use the html page to display 4. Add mail sending function, support excel table [test environment configuration]table to control whether to send mail function 5. Optimize the first line parameters of excel 6. Throw an exception and write to the corresponding interface use case of excel for easy troubleshooting 7. Detailed log printout 8. Warm Heart prepares a series of scripts for you
"Full-featured content implemented by script"
Basic operation of interface automation 1. Support HTTP interface requests:post, get, put, head, delete 2. Support the advanced content of interface automation such as downloading, downloading files, pictures, etc. 3. Support multiple parameter assertion judgment of status code and response value [expected status code and response value excel form control, the code directly uses regular judgment] 4. Support constants:General constants are used globally, and parameterization in automated testing is very important. For the same type of test, you only need to maintain different data. 5. Support variables:if the response value returns a parameter, returns multiple different values, can be assigned to the corresponding variable distinguishedly, let alone extract a single value, let alone support Advanced applications for interface automation 6. Support dynamic parameters:such as dynamic parameters [upper and lower interface parameter association]configuration, support different json format response value extraction dynamic parameters 7. The batch execution of the interface will not stop because of an error in an interface, throw an exception and write it to the excel sheet 8. Detailed log output and log save function 9. Support two types of test reports automatically generated after the test is completed:detailed excel sheet report and statistical data:HTML test report display 10. Support to control whether the email is sent in excel. The email sending function needs to install PhantomJS because it intercepts the pictures in the web page. It is a non-interface, scriptable WebKit browser engine, official download:http://phantomjs.org/download 11. Can be expanded and redeveloped according to the business. For non-universal functions, the interface requires MD5 parameter verification. Remarks:pytestreport test report html display is for reference:https://github.com/five3/PyTestReport, directly borrow the API embedded script
"The overall process of the script"
"Description of the meaning of each column of the Excel table"
"Dynamic Parameter Process"
"Interface Test Case Idea"
"Intercept request for partial log printing of internal interface"
"Sample Excel Test Report"
"Interface test report html sample"
The test report of all interface tests passed is displayed There is an abnormal interface return report display
"Sample Automatically Send Successfully"
The content can be changed by yourself
The above is today's content. "Forward" Or click "Look" After scanning the QR code above to get the latest source code, thank you!
There are really few hundreds of degrees of detail that can give you the whole framework to run up, so the script design is really not easy, feel the content is worth, click below "Like the author" reward rewards "!