Interview Questions

How to maintain global variable when script is run thru test plans?

SilkTest Questions and Anwsers


(Continued from previous question...)

37. How to maintain global variable when script is run thru test plans?

Answer1:
This is the feature of Silk Test.
When u declare some global variables and initialize them in a testcase in one .t file, they are not retained to be used in another .t file in a testplan.
Here is the way out ...
Create a file and save the values in this file before u exit from the .t file.
This can be your last testcase in a file.
In the next .t file in the sequence, read this file and initialize global variables again.
This can be your first testcase in the .t file.

Answer2:
try couple of things
1. use environment variable as suggested by an other member of this group
2. copy the variable to the clipboard, every automation tool has a way to write and read content from clipboard which does not effect scope of the script.

Answer3:
I have one more solution for this problem try it out.
External file method (preferably .ini file - use ReadIni (), WriteIni () and few other functions).
Override your TestcaseEnter () and TestCaseExit () functions to get and set variable (reading values should be in called TestCaseEnter () and writing back the values in TestCaseExit ())
Even testcase failure also you will not loose the values

(Continued on next question...)

Other Interview Questions