Postman is an interface testing tool, this article for you to introduce how to use post to complete SOAP interface testing.
Build test environment
1.1 Install test software
Here we need to install Postman and OpenSSL.
1.2 Create a certificate for Postman
Because Postman communicates HTTPS with the site, Postman needs to have its own certificate. we use OpenSSL to generate a self-signed certificate.
openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout privateKey.key -out certificate.crt
1.3 Import the certificate into Postman
First, open Postman’s setting interface.
Second, turn off ‘SSL certificate validation’ on the General tab.
Finally, on the certificate page, specify the address and port number of the server to be tested, and then add cert and then key:
Prepare test data
2.1 Get request format
The request format of SOAP can be obtained in several ways: directly accessing the webservice page or capturing packets through tools such as fiddler and weirshark.
2.2 Prepare test data
Postman supports data in CSV format, and here the previously mentioned data is made into CSV format.
Automated testing
Postman can pass test data in CSV or JSON format to collection. Here we use CSV format.
3.1 Modification request
Because the test parameter input comes from a CSV file, we will enter parameters a and b in the request to the variables input1 and input2, and the variable names are the column names of parameter 1 and parameter 2 in the CSV file, respectively.
3.2 Modify validation
In the test input box, analyze the response and compare it with the expected value. Because the value parsed from SOAP addresult is of type string, and the expected value data.output parsed from CSV is of type number.
Here we need to do a type conversion.
1 | pm.test("Test?Add?Function",?()?=>?{ |
Run Test
Load the test input on the collection runner screen, and the type of file and the number of test cases will be displayed.
Click Run to see the test results.
Summary
Here is just a brief introduction, if you need to add this test to the CI system to achieve complete automation, you also need to use Newman.
Postman still has a lot of powerful features that you need to explore in real tests.
[Reprinted from 51testing software test network]