Is there any variable declaration that can be made to persist across test cases? I understand I can write what I need to a file, or hold it in an environment variable (preferred). Just curious...
Global Variables will unless your running testcases via a TestPlan then the agent gets initialized between testcases and wipes out any values to global variables in which you need to workaround that by storing the values in a file or the registry. I personally write global variable values to the registry and retrieve them from there when I need them.
1.Global Variables Using Inc Files
Declare a variable with scope as "Public" in an include file and which you can access it from the script file through an "use" statement.It can be also "shared" to take advantage in case of parallel processing.
I beleive at runtime, the include file is loaded into the memory so that the global variable.
Normally, Global variables use 255 bytes of character data. If you create a global variable*and assign even just a ‘Y’ to it, the variable will still contain 255 bytes. The more global variables that you have, the less memory available to keep other important programs or DLLs in memory.
2.Global Variables Using Ini Files
Declare a variable in an ini file,and access it from your script.This gives more maintainability and scalablity too.
Am I making sense in this?If i am wrong, let me know what it is.
You can create a seperate .inc file that is just for type definitions and global variables. You can then include this .inc file by adding a USE statement to your main .inc file. Put your variables inside a window like this:
Then you can retrieve data globally and not worry about using a common var name like sUser because you interact with the variable like this:
[This message has been edited by rmccullough (edited 08-29-2002).]
<BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by John J. Miller: Or you can pass them in with a Setup() testcase that creates an .inc file which all
subsequent files expect.<HR></BLOCKQUOTE>
This approach intrigues me as it satisfies both the access scope and persistence across test case issues. I believe compilation of other files would then be dependant on this .inc file's existence, but I can get around that with a dummy include file.
I would prefer not to change the registry or writing files as they both involve relatively slow disk I/O. This was the only real advantage to environment variable usage.
I am hoping that with further analysis, I can remove the need for globals.