当前位置:网站首页>Postman basic operations

Postman basic operations

2022-06-21 17:03:00 Expert of explosive liver fist

One 、Get request

When the request method is get when , Request parameters should be filled in params in , In the form of key value pairs .

Two 、Post request

When the request method is post when , Request parameters should be filled in body in .

  • x-www-form-urlencoded
    Corresponding to Content-Type Header field is x-www-form-urlencoded The type of , Is a form parameter sent as a key value pair , At the same time, the parameters will be carried in url in .

  • form-data
    Corresponding to Content-Type Of multipart/form-data type , You can either send key value pairs or pass file parameters .

  • raw
    raw Option, you can edit each request using the original format of the request body Content-Type Parameter format corresponding to type , Send the content directly according to the format of the request body . Such as :Json、html Equiform

  • binary
    binary Option to send a file content request .
     Insert picture description here

3、 ... and 、 environment variable

Local environment variables > Global environment variable

Four 、 Assertion

Before request :
stay pre-request scripts Column for setting request pre operation , Such as setting variables .

1. Click on Get an environment variable( Get the current environment variable value )

#ipLoc Name of the environment variable set for 
var  ip=pm.environment.get("ipLoc");
console.log(ip);

 Insert picture description here
2. Click on Set an environment variable( Set the new environment variable value )
notes : The environment variable is named ipLoc , Variable value is 11.11.11.11 Insert picture description here

After the request :
stay Test Column by writing code to the status code 、 Response head 、 Response to the body and other information for assertion operation .

  1. Status code: Code is 200( Verify whether the returned response status code is 200)
     Insert picture description here

  2. Response body: Containis string( Verify that the returned body content contains the required string )
    notes : Determine whether the returned result contains “ The United States ”, If you have any , Then the prompt is output :“ Include U.S. characters in the body of the returned result ”.
     Insert picture description here

  3. Response body: JSON value check( Judge the return result json Whether the value corresponding to the key specified in the content is the expected character value )
     Insert picture description here
     Insert picture description here

  4. Reponse body:Is equal to a string( Verify whether the content of the returned result is Completely equal

  5. Response headers:Content-Type header check ( Verify the header information in the returned result )
     Insert picture description here

  6. Response time is less than 200ms( Verify response time )
     Insert picture description here

5、 ... and 、 Test set

Run the test set : That is, run multiple interface tests at the same time .
 Insert picture description here
 Insert picture description here

6、 ... and 、 Data driven

That is, run multiple request parameters and save them in the format csv External files in .

Assertion :
 Insert picture description here
function run
 Insert picture description here
Be careful :
When there is garbled code , use Notepad++ take csv The file format is changed to UTF-8 code .
Such as :
 Insert picture description here
test result :
 Insert picture description here

原网站

版权声明
本文为[Expert of explosive liver fist]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/172/202206211318464394.html

随机推荐