In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
. Built-in script description
1. Clear a global variable Clear a global variable corresponding to the script: postman.clearGlobalVariable ("variable_key"); parameter: key 2 of the variable to be cleared. Clear an environment variable Clear an environment variable corresponding script: postman.clearEnvironmentVariable ("variable_key"); parameter: the key 3.response of the environment variable to be cleared contains the content Response body:Contains string corresponding script: tests ["Body matches string"] = responseBody.has ("string_you_want_to_search"); parameter: expected content 4. Convert xml format response to son format Response body:Convert XML body to a JSON Object corresponding script: var jsonObject = xml2Json (responseBody); Parameter: (default does not need to set parameters, for the response of the interface) the xml 5.response to be converted is equal to the expected content Response body:Is equal to a string corresponding script: tests ["Body is correct"] = responseBody = "response_body_string" Parameters: response 6.json is expected to parse the value of key to verify the Response body:JSON value check corresponding script: tests ["Args key contains argument passed as url parameter"] = 'test' in responseJSON.args parameter: test replaces the tested value, args replaces the tested key 7. Check whether the header information of response has the tested field Response headers:Content-Type header check corresponding script: tests ["Content-Type is present"] = postman.getResponseHeader ("Content-Type"); parameter: expected header 8. Response time judgment Response time is less than 200ms corresponding script: tests ["Response time is less than 200ms"] = responseTime < 200; parameters: response time 9. Set the global variable Set an global variable corresponding to the script: postman.setGlobalVariable ("variable_key", "variable_value"); parameter: global variable key value 10. Set the environment variable Set an environment variable corresponding to the script: postman.setEnvironmentVariable ("variable_key", "variable_value"); parameters: the key value of the environment variable 11. Judge the status code Status code:Code is 200 corresponding to the script: tests ["Status code is 200"] = responseCode.code! = 400; parameters: status code 12. Check whether code name contains content Status code:Code name has string corresponding script: tests ["Status code name has string"] = responseCode.name.has ("Created"); parameter: expected code name contains string 13. The script for a successful post request Status code:Successful POST request: tests ["Successful POST request"] = responseCode.code = 201 | | responseCode.code = = 202; 14. Use Tiny Validator for JSON data corresponds to script: var schema = {"items": {"type": "boolean"}}; var data1 = [true, false]; var data2 = [true, 123]; console.log (tv4.error) Tests ["Valid Data1"] = tv4.validate (data1, schema); tests ["Valid Data2"] = tv4.validate (data2, schema); parameters: you can modify the key-value pairs in items to correspond to the parameters of the verification json
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.