📄️ What is a "Variable" in PostQode?
In PostQode, a variable is a data repository where the data is stored centrally and can be easily accessed without needing to re-enter it repeatedly. This becomes incredibly helpful when you're dealing with identical values across multiple instances, making your requests more adaptable and easier to understand by simplifying complex details.
📄️ Types of Variables
PostQode provides versatile variable support with various scopes to cater to diverse development, testing, and collaboration needs. In PostQode, scopes refer to the specific contexts in which your requests operate, and each variable scope serves distinct purposes depending on the task These are the three types of Variables:
📄️ Global Variable
A global variable is declared and defined at the beginning of a program and can be accessed from any part of the code within its scope. It provides a consistent way to share data across functions or modules but requires careful management to avoid conflicts or unintended side effects.
📄️ Environment Variable
These are usually used to manage and control various aspects of an application, such as database connection strings, API keys, server addresses, or other environment-specific settings. Environment variables can be set and modified outside the application code, allowing developers to configure the behavior of the program without making any changes in the code. They are particularly useful for maintaining consistency and security when deploying applications in different environments, such as development, testing, and production.
📄️ Test Suite Variable
This is a variable that you can define and use within a specific group of tests called a "Test suite". These variables are limited to that particular group and are not accessible out of the group. They are handy for storing and reusing values specific to the tests within that suite, making your testing scenarios more organized and efficient.
📄️ Local Variable
Local variables in PostQode offer a flexible and isolated way to manage the data specific to the test. By utilizing pq.variables.set and pq.variables.get in scripts or pre-request scripts within hooks, you can effectively handle the test case initialization and cleanup, ensuring smooth and independent test execution.
📄️ Dynamic Variable
The Faker library enables you to generate a sample data in PostQode using predefined variables. Use these variables same as any other variable in PostQode. Their values are generated at the time of execution. You can find the name of the variable with a $ symbol. For example, $guid or $timestamp.