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.
A local variable is confined to a single test case. This ensures that variables defined in one test case do not interfere with the others, which promotes test isolation.
Creating Local Variables
"Local Variables" can be created in scripts or pre-request scripts pq.variables.set("variableName", value);
Fetching Local Variables
To retrieve the value of a local variable, use the pq.variables.get("variableName");
method.
Using Local Variables in Hooks
Local variables can also be created and managed within the hooks using pq.variables.set
in scripts or pre-request scripts. This allows you to initialize, modify, or clean up the local variables before and after each test case.