Functions

Similar to functions in Excel, Testfully functions allow you to compute values dynamically and add them to your requests. The values are computed using a wide range of methods. For example, you could use step() to extract values from one step and add them to others. This page includes all you need to know about functions.

How to use

To start using functions, wrap them using the {{}} interpolator tag and when needed, you can also pass arguments to functions. In summary:

  1. Call a function by wrapping it with {{}}.
  2. Named and unnamed arguments can be passed to a function.
    1. {{sum(1,2,3)}}` is an example of a function call with 3 unnamed arguments: 1,2,3.
    2. {{step(index:1, path:variables.token )}} is an example of a function with two named arguments: index and path.
  3. You can nest function calls within each other.
    1. {{sum(step(index: 1, segment:response_headers, path:x-avail-credit), 1)}}

The order in which you provide a range of named params does not matter. You do not need to wrap params with ' or ".

Supported Functions

Testfully comes with a range of pre-defined functions to streamline your work. User-defined functions are in our roadmap and will be added in the future.

sum()

Use the sum() function to get the sum of two or more values. Pass values as unnamed arguments.

Examples

  1. {{sum(1,2,3)}} equals to 1+2+3=6.
  2. {{sum(10,-1)}} equals to 10-1=9.
  3. {{sum(10,sum(10,20))}} equals to 10+(10+20)=40.

step()

Use the step() function to resolve values of other steps within the same multi-step request. Function step() supports the following named params:

Param NameDescriptionDefault Value
indexIndex of the target step -- starts from 00
pathPath to valueN/A
segmentSegment of the request to extract the value. One of: request_body, response_body, request_headers, and response_headers.response_body
default_valueThe default value to be used when value could not be resolvedN/A

Examples

  • step(index:0, segment:response_headers: path:x-avail-credit) reads value of the x-avail-credit response header from the 1st step.
  • step(index:0, segment:response_body, path: data.success) reads value of the data.success field from the response body of the 1st step.

Randoms

Testfully offers a range of functions to generate random data.

Function NameDescriptionExample
int()A random integer greater than zero98605
float()A random float greater than zero27643.886
email()A random email address.addie@green-plus.bm
string()Generates a random string4x49cSMPKv0eypg1iec9k0HHjsW
guid()Generates a random UUID V4e9b1f1db-1fab-47f1-95f8-f625eb8be23c
uuid()Generates a random UUID V4e9b1f1db-1fab-47f1-95f8-f625eb8be23c
uuidv4()Generates a random UUID V4e9b1f1db-1fab-47f1-95f8-f625eb8be23c

Date & Time

Functions that relate to date & time.

Function NameDescriptionExample
isoTimestamp()current time in ISO String format2023-06-06T04:25:37.667Z
timestamp()The current UNIX timestamp in milliseconds1686025537667