Software testing --postman

https://blog.csdn.net/fxbin123/article/details/80428216

1. Clear a global variable
     Clear a global variable
    Corresponding to the script:
    postman.clearGlobalVariable("variable_key");
    You need to clear the key variables: Parameter
 
  2. Clear an environment variable
    Clear an environment variable
    Corresponding to the script:
    postman.clearEnvironmentVariable("variable_key");
    Parameters: the need to clear the environment variable key
 
  3.response contains content
    Response body:Contains string
    Corresponding to the script:
    tests["Body matches string"] =responseBody.has("string_you_want_to_search");
    Parameters: Expected content
 
  4. Converting response xml format into the format son
    Response body:Convert XML body to a JSON Object
    Corresponding to the script:
    var jsonObject = xml2Json(responseBody);
    :( default parameters do not need to set the parameters for the response interface) you need to convert xml
 
  5.response equal to the expected content
    Response body:Is equal to a string
    Corresponding to the script:
    tests["Body is correct"] = responseBody === "response_body_string";
    Parameters: Expected response
 
  6.json key should be verified analytical value
    Response body:JSON value check
    Corresponding to the script:
    tests["Args key contains argument passed as url parameter"] = 'test' in responseJSON.args
    Parameters: test Alternatively the measured value, args tested replacement key
 
  7. Check whether the header information with a measured response of the field
    Response headers:Content-Type header check
    Corresponding to the script:
    tests["Content-Type is present"] = postman.getResponseHeader("Content-Type");
    Parameters: Expected header
 
  8. The response time is determined
    Response time is less than 200ms
    Corresponding to the script:
    tests["Response time is less than 200ms"] = responseTime < 200;
    Parameters: response time
 
    9. Set up a global variable
      Set an global variable
      Corresponding to the script:
      postman.setGlobalVariable("variable_key", "variable_value");
      Parameters: key global variables
 
    10. Set Environment Variables
      Set an environment variable
      Corresponding to the script:
      postman.setEnvironmentVariable("variable_key", "variable_value");
      Parameters: key environmental variables
 
    11. Analyzing status code
      Status code:Code is 200
      Corresponding to the script:
      tests["Status code is 200"] = responseCode.code != 400;
      Parameters: status code
 
    12. Check code name contains content
      Status code:Code name has string
      Corresponding to the script:
      tests["Status code name has string"] = responseCode.name.has("Created");
      Parameters: Expected code name contains the string
 
    13. A successful post requests
      Status code:Successful POST request
      Corresponding to the script:
      tests["Successful POST request"] = responseCode.code === 201 || responseCode.code === 202;
 
     14. The tiny validator
       Use Tiny Validator for JSON data            
       Corresponding to the script: 
        was diagram = {
         "items": {
         "type": "boolean"
             }
         };
        was data1 = [true, false];
        was data2 = [true, 123];
        console.log(tv4.error);
        tests["Valid Data1"] = tv4.validate(data1, schema);
        tests["Valid Data2"] = tv4.validate(data2, schema);
        Parameters: key inside the items can be modified to correspond to a parameter validation json
 
————————————————
Disclaimer: This article is CSDN blogger "meaning a cavity Xi 'original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
Original link: https: //blog.csdn.net/W_C_X/article/details/88972388

  Automatic acquisition token

Guess you like

Origin www.cnblogs.com/fqqwz/p/11647368.html