SPONSORS:






User Tag List

Results 1 to 6 of 6
  1. #1
    Junior Member
    Join Date
    Jun 2002
    Location
    Boca Raton FL. USA
    Posts
    10
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Creating global variables

    Greetings,
    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...

    ------------------

  2. #2
    Senior Member
    Join Date
    Nov 1999
    Location
    Eagle, ID,USA
    Posts
    1,035
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Creating global variables

    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.

    ------------------
    Have you ever noticed? Anybody going slower than you is an idiot, and anyone going faster than you is a maniac.

  3. #3
    Senior Member
    Join Date
    Feb 2000
    Posts
    1,497
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Creating global variables

    Or you can pass them in with a Setup() testcase that creates an .inc file which all
    subsequent files expect.

    While globals definitely have their uses, be careful with them. Then tend to cause more problems than they solve as the number of them, and their unexpected dependencies, increase.


    John


    ------------------

  4. #4
    Member
    Join Date
    Jul 2002
    Location
    Chennai,TN,India
    Posts
    36
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Creating global variables

    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.

    Diadvantage:
    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.

    ------------------
    Babu NM
    Babu NM

  5. #5
    Senior Member
    Join Date
    Dec 2001
    Location
    Bozeman, MT, USA
    Posts
    265
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Creating global variables

    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).]
    Ryan McCullough
    RightNow Tech. Inc.

  6. #6
    Junior Member
    Join Date
    Jun 2002
    Location
    Boca Raton FL. USA
    Posts
    10
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Creating global variables

    <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.

    ------------------

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 12:43 AM.

Copyright BetaSoft Inc.