Tutorial

Video Icon

In the near future we will upload videos for every chapter of the tutorial which will lead you step by step through QF-Test.

6.5
Variable binding levels

Note This section may be difficult to understand when you are a programming beginner. Then it may be better to come back to it when you started writing procedures for your own tests.

In QF-Test there are many places where you can set a variable:

  • The test-suite node,
  • in test-cases and procedures as default or local variables,
  • as a parameter in a procedure call,
  • as a global variable and
  • as a command line parameter.

Now the question is: Which is the correct place for defining a variable?

And the answer is: It depends on the use-case.

Each level of the variable bindings has its own use-case:

Procedure parameters
When you call the same procedure several times in a test-case and with different values each time you should set the values via a parameter at a procedure call. This is done by adding a row to the variable definitions table of a 'Procedure call' node specifying the respective variable name and value.
Local variables in a procedure
They are created in the procedure and are deleted when the execution of the procedure finishes. Use a local variable when you do not need it outside of the current procedure. In procedures they are predestined for intermediate results.
Local variables in a test-case
Variables local to a test-case are either created during execution of a test-case or defined in the respective table in the details of the test-case node. They will be deleted from the variable bindings table once the test-case finishes. Use them for values you want to refer to in several nodes of a test case and you do not need outside of it.
Global variables
Global variables are created at some point of the test execution and exist until they are explicitly deleted or QF-Test is stopped. They survive stops and restarts of test execution. Use them for values that need to be accessible by all test-cases. A typical example is the variable client created in the 'Setup' node when starting the application. To get rid of them you need to either exit QF-Test or select the menu item »Run«-»Clear global variables«.
Command line parameters
In batch mode you may want to run test with various parameters. They are valid throughout the batch run. A typical example would be the browser to be used.
Test-suite variables
Test-suite variables can be referred to by all test-cases. Their usage is the same as that of global variables. Only that they can be overridden at batch execution by command line parameters, whereas global variables cannot.
Default values (Fallback stack)
You can define default values for variables of procedures, test-cases and test-sets. In case you do not define a variable of the same name on a higher level QF-Test will use the default value set.