Interface postman do automated testing

The interface is used to connect the server and the client, the data is generally returned json.

get and post requests differences:

1. get requests than post request security

2. get request parameters have length restrictions, post request does not

3. get request does not have body, url parameters are placed inside the post request is on the inside of the body.

http request status code:

1.200 # 2 on behalf of the request was successful

2.404 # 4 requesting the code issued to the client in question

3 represents 3.300 # redirect

4. 500,502 # 5 on behalf of the server in question

How to define variables postman

Open the postman, click Settings -Global the top right corner, set the name and contents of the variable. Directly using {{}} variable name can be invoked

 

 

How do postman Interface Automation

1, ready interface script

2, preparation of test data

     A first write line parameter name, an interface with {{}} parameter names referenced.

 

3, according to the check result data preparation test (different for each one corresponding to the test data results, if you want to check one by the same need to be verified in data write text file)

All checkpoints are written in the test. There are many right content inspection, may be selected as desired

Which "Response body: Contains string" is included in the content of test results (red font replaceable variable)

pm.test ( "Body The matches String", function () {
. pm.expect (pm.response.text ()) to.include ( " check the contents ");
});

When examining the content of each piece of data is not the same, you need to use "Set a global variable" as a variable to replace the content inspection

pm.globals.set ( " variable name ");

The final should be:

pm.test("Body matches string", function () {
pm.expect(pm.response.text()).to.include("pm.globals.set("变量名")");
});

 

 

4, the script and the data is ready, click on the upper left corner of the postman "Runner", select the script you want to test, set up after the completion of the data click Run, tests will be performed automatically after the execution is complete will return the test results.

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/tata-learning/p/11470571.html