Skip to main content

Dynamic Value

When debugging interfaces in EchoAPI, it is often necessary to construct various data in request parameters and request bodies, such as values, names, addresses, etc. To simplify this process, we have introduced the "Dynamic Values" feature. Dynamic values allow you to automatically generate new data based on predefined rules each time you send a request, which not only improves testing efficiency but also ensures that each request contains unique information.

Advantages of Dynamic Values

  • Simulate Real Data: Generate a variety of test data to improve test coverage.
  • Generate Unique Values: (e.g., order numbers, user IDs)
  • Simplify Data Processing: Dynamic values can reduce manual data modifications, increasing testing efficiency.

Next, we will explore how to effectively use this feature to make your testing work more efficient and convenient.

Feature 1: Reference Variables

When we need to use environment variables/global variables in parameter values, we can directly enter {{ in the input box to reference the existing variables and quickly add them.

In addition, we can click the icon next to the input box to add them. By using this method, you can not only reference variable values but also add functions like encrypt and decrypt to process our variable values.

  1. Click the icon and select "Reference Variable".

image.png

  1. Here, you can drop down to select environment or global variables.

image.png

  1. After selecting a variable, you can preview the variable value below. You can also add function processing.

image.png

  1. Add processing functions, and you can preview the value after adding functions. Custom functions are supported. See how to use

image.png

image.png

  1. Click "Insert" or "Replace" to write the content into the parameter value input box.
    • Insert: Append at the end.
    • Replace: Replace the entire content of the input box.

image.png

tip

Note: The previewed variable value is the local value of the variable at that moment. If you modify the variable in pre-execution operations or elsewhere, the actual sent data is based on the final variable value, which can be viewed in the actual sent data section of the response.

  1. To modify an added value, hover the mouse and click "Edit".

image.png

Feature 2: Simulate Real Data

When we need to mock some real data, we can choose "Mock". The mock we use is based on the methods provided by Faker; you can go to Faker for more information.

  1. Click the icon and select "Mock".

image.png

  1. Drop down to select the type of data to mock: phone numbers, emails, task names, animal names, etc.

image.png

  1. Some functions allow further parameter configuration to generate more specific real data; you can set it by clicking "Parameters". The usage of parameters can also be referenced here Faker.

image.png

  1. Similarly, we can also add processing functions, such as encryption, to the mock data. Custom functions are supported. See how to use

image.png

  1. Click "Insert" or "Replace" to write the content into the parameter value input box.
    • Insert: Append at the end.
    • Replace: Replace the entire content of the input box.

image.png

  1. To modify an added value, hover the mouse and click "Edit".

image.png

Feature 3: Fixed Values for Function Processing

When we only need to add function processing to a specific request parameter without needing variables or mocks, we can choose "Fixed Value." Enter a specific value, then add some processing functions.

  1. Click the icon and select "Fixed Value."

image.png

  1. Input the parameter value you want to process with a function, for example, to md5 encrypt 123456. Just enter 123456.

image.png

  1. Add a processing function, select md5, and you can see the value after md5 encryption in the preview. Custom functions are supported. See how to use

image.png

image.png

  1. Click "Insert" or "Replace" to write the content into the parameter value input box.
    • Insert: Append at the end.
    • Replace: Replace the entire content of the input box.

image.png

  1. To modify an added value, hover the mouse and click "Edit".

image.png

Application in body-raw

In the raw format of the body, we also support inserting dynamic values. Just position your mouse cursor at the location where you want to insert it, then click the icon to set dynamic values as described above.

image.png

image.png

View Sent Dynamic Values

After inserting dynamic values, click send to view the actual sent data in the Actual Request section of the response.

image.png