diff --git a/docs/BUILTIN.md b/docs/BUILTIN.md new file mode 100644 index 00000000..e90b0a04 --- /dev/null +++ b/docs/BUILTIN.md @@ -0,0 +1,44 @@ +# Builtin + +## Assertion Methods + +### Usage +In "teststeps" of each json/yaml testcase, the "validate" part contains four fields: "check", "assert", "expect" and +"msg", when using assertion methods, method name should be put in "assert" field. The assertion result of "check" +element will be checked out using the regulation you put in "assert" field and compared with the element in "expect" +field. + +### Method List + +- equals: assert the element to check equals the expected element. +- equal: alias for equals. +- greater_than: assert the element to check is greater than the expected element. +- less_than: assert the element to check is less than the expected element. +- greater_or_equals: assert the element to check is greater than or equal with the expected element. +- less_or_equals: assert the element to check is less than or equal with the expected element. +- not_equal: assert the element to check is not equal with the expected element. +- contained_by: assert the expected element contains the element to check. +- regex_match: assert the element to check matches the expected element using regex. +- type_match: assert the element to check matches the expected element in type. +- startswith: assert the element to check starts with the expected element. +- endswith: assert the element to check ends with the expected element. +- length_equals: assert the length of the element to check is equal with the expected element. +- length_equal: alias for length_equals. +- contains: assert the element to check contains the expected element. +- string_equals: assert the string is equal with the expected string. + +## Common Functions + +### Usage +The common functions are useful during the variables configuration, you can use "${FUNCTION_NAME}" to call the specific +function to define variables. + +### Function List +- get_timestamp: get the thirteen-digit timestamp of current time. (call without argument) +- sleep: sleep n seconds to simulate the thinking time. (call with one argument n) +- gen_random_string: get the n-digit random string. (call with one argument n) +- max: get the maximum of two numbers m and n. (call with two argument m and n) +- md5: get the MD5 of the input string s. (call with one argument s) + + + diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 67354670..d428e4f1 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,5 +1,7 @@ # Release History +-feat: add more plentiful response assertion methods + ## v0.3.0 (2021-12-22) - feat: implement `transaction` mechanism for load test diff --git a/internal/builtin/function.go b/internal/builtin/function.go index d1d3dd3b..e11529eb 100644 --- a/internal/builtin/function.go +++ b/internal/builtin/function.go @@ -13,7 +13,7 @@ var Functions = map[string]interface{}{ "sleep": sleep, // call with one argument "gen_random_string": genRandomString, // call with one argument "max": math.Max, // call with two arguments - "md5": MD5, + "md5": MD5, // call with one argument } func init() {