postman built-in scripting Description

1 . A global variable Clear 
     Clear a global variable 
    corresponding to the script: 
    postman.clearGlobalVariable ( "variable_key" ); 
    Parameters: key variables need to remove

 2 . Clear environment variable 
    Clear an environment variable 
    corresponding to the script: 
    postman.clearEnvironmentVariable ( "variable_key" ); 
    parameters: key to clear the environment variables

 . 3 .response contains content 
    Response body: contains string 
    corresponding to the script: 
    Tests [ "body the matches String"] = responseBody.has ( "string_you_want_to_search" ); 
    parameters: the desired content

 4 the xml son response format into the format 
    response body: JSON Object 
    corresponding to the script:
    jsonObject var the Type header check 
    corresponds script:= Xml2json (the responseBody); 
    Parameter :( default takes no parameters, response to the interface) to be converted XML

 . 5 .response equal to the desired content 
    Response body: Is equal to a string 
    corresponding to the script: 
    Tests [ "Body IS correct"] = === the responseBody "response_body_string" ; 
    parameters: expected Response

 . 6 .json value resolution of key verify 
    Response body: JSON value check 
    corresponding to the script: 
    Tests [ "key the contains the Args argument passed AS URL parameter"] = 'Test' in the responseJSON .args 
    parameters: test Alternatively the measured value, args replaced tested Key

 . 7 whether the response header information checking fields are measured. 
    the response headers: the Content -
    Tests [variable_value");"Present the Content-the Type IS"] = postman.getResponseHeader ( "the Type-the Content" ); 
    Parameters: expected header

 . 8 . Analyzing the response time 
    Response time is less than 200ms 
    corresponding to the script: 
    Tests [ "Response time is less than 200ms"] = responseTime <200 is ; 
    parameters: response time

 9 set a global variable. 
      the set global AN variable 
      corresponding to the script: 
      postman.setGlobalVariable ( "variable_key", "variable_value" ); 
      parameters: key global variables

 10 . set the environment variable 
      set an environment variable 
      corresponding to script: 
      postman.setEnvironmentVariable ( "variable_key", "variable_value"
      Parameters: key environment variable

 11 determines the status code. 
      Status code: Code IS 200 is 
      corresponding to the script: 
      Tests [ ! "IS Status code 200 is"] = responseCode.code = 400 ; 
      Parameters: status code

 12 Check code name contains the contents of 
      Status code: code name has string 
      corresponding to the script: 
      Tests [ "code name has the Status string"] = responseCode.name.has ( "the Created" ); 
      parameters: expected code name string comprising

 13 successful post requests. 
      the Status code: successful the pOST request 
      corresponding to the script: 
      Tests [ "Successful the POST request"] = || responseCode.code responseCode.code === 201 === 202 ;

 14 minute validator.
       Tiny the Validator the Use for the JSON Data             
       corresponding to the script: 
        var Schema = {
          "items" : {
          "type": "Boolean" 
             } 
         }; 
        var DATAl = [ to true , to false ]; 
        var DATA2 = [ to true , 123 ]; 
        the console.log ( tv4.error); 
        Tests [ "! Valid Datal"] = tv4.validate (DATAl, Schema); 
        Tests [ "! Valid the Data2"] = tv4.validate (DATA2, Schema); 
        parameters: key inside the items can be modified to be authentication parameter corresponding to the json

 

Guess you like

Origin www.cnblogs.com/xinxin1994/p/11260209.html