SPONSORS:






User Tag List

Page 1 of 3 123 LastLast
Results 1 to 10 of 21
  1. #1
    Junior Member
    Join Date
    Aug 2000
    Posts
    22
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Global variables and the Invoke method.

    Good Day All,

    I would like to run two test cases that are both based on the same application state "BaseState". This app state calls the MainWin's Invoke method.

    Both of these test cases and the Invoke method use the same global variable 'SERVER' (defined in global.inc) to determine the server being used.

    I would like the two test cases to use different servers.

    My problem is this:
    The Invoke method is called before each test case is entered so it looks to 'global.inc' to get the 'SERVER' value and always connects to the same server.

    Right now I have a situation where all test cases in a test plan must use the same server OR I have to manually go into 'global.inc' and set 'SERVER' before I run each test case that uses a different server.

    I would expect that there be a way to set global variables within test plans but I have not discovered this mystery technique.

    Any ideas or suggestions are greatly appreciated!

    Thanks

    Mark

  2. #2
    Senior Member
    Join Date
    Aug 1999
    Location
    Cambridge, UK
    Posts
    470
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Global variables and the Invoke method.

    There are probably a couple of ways of going about this. We use appstates, though not quite in the standard intended way. We have a similar situation with our aut, whereby there are a number of different flags and options (of the aut) which are enabled and disabled by means of a dll. In order to easily load up the aut with a particular set of options enabled or disabled, we have a number of start-up directories, each with a different version of the option-enabling dll.
    We have various different appstates defined for each of these configurations, and each appstate function alters the sdir property of our mainwin declaration, and restarts the aut of necessary.
    We have found this a very powerful tool, which enables us to easily test different configurations of our aut without extra effort when writing the testcase. We have also extended the technique to enable us to test on previous releases of the aut (in order to check up on client-reported bugs for example), and have also introduced a compiler constant enabling us to over-ride the appstate-defined startup directory and run testcases on a different configuration.
    An alternative way of doing it would be to define a compiler constant representing the server, and have TestcaseEnter use this compiler constant to alter whatever property of the mainwin declaration is relevant. This would be significantly simpler to set up than the previous suggestion of using appstates, but would have the disadvantage of not being able to run two scripts which require different servers consecutively in a single plan.

    Give us a shout if you need any more help/advice on this kind of stuff - we spent a long time implementing all of this appstates stuff and getting it working, so I know it's not easy to get off the ground.

  3. #3
    Junior Member
    Join Date
    Aug 2000
    Posts
    22
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Global variables and the Invoke method.

    Thanks for the reply Vince but unfortunately these solutions don't quite work for us. We want to stay away from changing the aut's startup settings so we can test the logon actions. And I'd really like to be able to write testplans that use multiple servers.

    Ideally we would like to have a global variable file for each testplan so that each testplan can be stored in SourceSafe with its own global variable settings. But we also want to be able to add global constants that all testplans use without having to open each testplan's global variables file and adding it.

    One of my attempted solutions was to have two global variable files and have the testplan-specific file include the universal global file. I was hoping that within the testplan-specific file, globals that were defined in the universal file could be reassigned. But of course the scope of these reassignments are local to the file, not global to the testplan.

  4. #4
    Senior Member
    Join Date
    Jul 1999
    Location
    New York, NY, USA
    Posts
    137
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Global variables and the Invoke method.

    I don't use planner, but I do use a 2 file approach like you are trying. You may be able to do two things to make it work for you.

    First create a derived invoke method so that you can control what happens durring the invoke of the testcase. I think you will be able to override the default login and mainwin declaration.

    Second create an include file that containd just the Login Id's Passwords and Server locations. Put this file in a 'Use' statement and where you specify the server variablize just the server extension part of the string. Like this:

    In one Include file have

    STRING sURL1 = "http://ServerName1/"
    STRING sURL2 = "http://ServerName2/"
    STRING sURL3 = "http://ServerName3/"

    And in the AUT's include file have a use statement for the above file plus this

    // The URL of this page
    const sLocation = "{sURL1}SubDir/Whatever.html"

    Than all you would have to do is Change the sURL value in the INC file before running. In your derived invoke method you could check for the value of sURL and use the appropriate login and pwd based on a switch case.


    [This message has been edited by woodman (edited 10-31-2000).]

  5. #5
    Junior Member
    Join Date
    Aug 2000
    Posts
    22
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Global variables and the Invoke method.

    Thanks woodman, this allows us to change the server being used by the testplan before we run it but we still can't run successive testcases that use different servers. I need to be able to change the server in a testplan between testcases. I've tried using symbols but I don't think they're accessible in the Invoke method or any scripts.

    Thanks for your replies guys, I'm still working on this issue (and many others :-)), I'll report any progress. I'm also trying to contact Segue.8-0

  6. #6
    Member
    Join Date
    Dec 1999
    Location
    Portland, OR, USA
    Posts
    91
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Global variables and the Invoke method.

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by MarkM:
    One of my attempted solutions was to have two global variable files and have the testplan-specific file include the universal global file. I was hoping that within the testplan-specific file, globals that were defined in the universal file could be reassigned. But of course the scope of these reassignments are local to the file, not global to the testplan.[/B]<HR></BLOCKQUOTE>
    ============

    In a test script you can reassign the value of a global variable, unless it is a constant. A variable is only local if you declare it locally.
    Quality Control Analyst at Syntel Inc
    Project Test Lead for client Daimler Trucks - North America.
    Interested in testing dot net web services and SOA systems.
    Charles F. Radley
    Oregon, USA.

  7. #7
    Junior Member
    Join Date
    Aug 2000
    Posts
    22
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Global variables and the Invoke method.

    I have no problem reassigning the value of a global variable within a test script, the problem is that this reassignment is only effective in the script in which it is made, so when the Invoke method is run (which resides in a different file, "main.inc") it uses the original hard-coded value not the newly reassigned value.


  8. #8
    Senior Member
    Join Date
    Jul 1999
    Location
    New York, NY, USA
    Posts
    137
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Global variables and the Invoke method.

    Use my method and create a counter, then where the name of the server should be in the string you could do something like this:

    for (i=1;i++;i<=10)
    const sLocation = "{sURL}{i}SubDir/Whatever.html"

    Would that work for you?
    Actually that is bad code because you would have to append the number before you grab the string. However that reminded me that you could use a DATA driven testcase to read consecutive values into the URL STRING and essentialy just rotate the testcase between servers.

    Check the DATA Driven Testcase examples in the user's guide. I think this would be the approach you want.

    [This message has been edited by woodman (edited 11-02-2000).]

  9. #9
    Junior Member
    Join Date
    Aug 2000
    Posts
    22
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Global variables and the Invoke method.

    This would work woodman, the question that this raises is "Where do you put that code so that it is global to all files?". I don't know.

    I have tried data driven test cases also, that gets the server to the testcase successfully but the invoke method is run before the testcase is entered so Invoke() uses the original server value. So to get the server name to Invoke() we can use TestCaseEnter but then we run into the same problem because TestCaseEnter will pass the same server to Invoke() every time.

    This is my experience anyway. I'm hoping someone can see an oversite I've made. There must be a way to do this. I was thinking something like Symbols in the testplan but they are not accessible inside of testcases.

    Great discussion guys! Keep it up!

    I've gotten a hold of Segue and am waiting to hear back, meanwhile I'm still working on this and other issues.

    Thanks!


  10. #10
    Member
    Join Date
    Dec 1999
    Location
    Seattle, WA
    Posts
    64
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Global variables and the Invoke method.

    took me awhile to figure out exactly what the issue was, but you've identified that indeed the test script is the widest scope available for a variable.

    on entering a new script, you cannot obtain a global 4test variable set by the prior script. the hack around this is to use either environment variables or open a handle to a file and store name/value pairs in a TXT file.

    see the HANDLE datatype for quick and dirty code on reading/writing files. it's pretty simple.

    ------------------
    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>It doesn't matter if I go to heaven or to hell, I have friends in both places.<HR></BLOCKQUOTE>
    <BLOCKQUOTE]<font size=1 face=Verdana, Arial, Helvetica]quote:</font]<HR]It doesn't matter if I go to heaven or to hell, I have friends in both places.<HR]</BLOCKQUOTE]

 

 
Page 1 of 3 123 LastLast

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:48 AM.

Copyright BetaSoft Inc.