SPONSORS:






User Tag List

Results 1 to 8 of 8
  1. #1
    Senior Member
    Join Date
    Jun 2002
    Posts
    119
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can I set a variable in one testcase and have it hold that value for another?

    I thought I could declare a variable at file level, then assign it a value in one testcase and it would hold that value and in a later testcase I could use it to verify something else. In fact I thought I had it working and now a week after I wrote the script I find it doesn't work. But I thought I saw it working at first ... I'm sure I did .. didn't I ... ??? Alas, I don't have any output files from a week ago still lying around that I could prove that I'm not losing my memory.

    It's a web portal application. I declare a

    LIST of String lsPortletsOnPage

    at the beginning of the script, before any testcases, and in testcase_2 I have code that reads the names of the portlets on the page and stores the names in that LIST.

    lsPortletsOnPage = GetListOfPortletsFromPage()

    That's a utility method I wrote and use as needed.

    Later, in testcase_6 I have to test that the same set of portlets showed up on a different page. So I use the same code to determine what's on the page as testcase_6 is running and want to verify it against the LIST, whose contents were supposedly stored away in testcase_2.

    Verify(lsPortletsOnPage, GetListOfPortletsFromPage())

    In testcase_6, however, lsPortletsOnPage is showing up empty.

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

  2. #2
    Member
    Join Date
    Aug 2002
    Location
    Durham, NC USA
    Posts
    60
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Can I set a variable in one testcase and have it hold that value for another?

    The global variable should hold your values, it is true.

    I thought it was interesting you said it was an empty list, not undefined. This leads me to believe your definition function has broken somehow. (?)

    Could this be a timing error? The web page may not be settled before your function reads the 'portlets.' It's just a shot in the dark

    My basic test for this, to make sure I read correctly what you have:
    Sorry to be of no more help.

    -TC

    [This message has been edited by tdcrone (edited 02-10-2003).]
    --
    Tim Crone
    Broadcom

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

    Re: Can I set a variable in one testcase and have it hold that value for another?

    It's not good practice to make any testcase dependent on the successful completion of any other testcase. You should always be able to run them in any (even random) sequence. That said...

    Are you running from a .PLN file or from a .T ? .Pln-based runs ignore main() unless it is explicitly listed as a testcase.

    Another way to isolate shared data-dependencies is to use the appstate modifier on each affected testcase.

    Yet another possibility it to prime the list of string when it is defined.

    LIST of String lsPortletsOnPage = GetListOfPortletsFromPage()

    This however presumes that the function being called knows how to do everything necessary to get to that point where it can collect the needed data.


    John


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

  4. #4
    Senior Member
    Join Date
    Jun 2002
    Posts
    119
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Can I set a variable in one testcase and have it hold that value for another?

    So that's it, and I wasn't losing my memory. It works from a .t, but not from a .pln

    I haven't been ignoring your responses, I've been busily trying things here.

    I had built the script, always testing my ideas by running it from the .t file. Now that it's in service, it runs from a master plan.

    Any way around that? tdcrone's code is the same - it works from a .t, not from a .pln. That is, after I edited it so it only called the testcases from the plan, not calling main() at all.

    The app that I'm testing pretty much has to do the gathering of the information about the contents of a page, and hold it for later. It has a feature where one user can share a page with another user, by sending an email with a link embedded in it, full of info, and the receiver opens the emial, clicks the link, and a browser opens which takes him to the portal where he can add the shared page to his own account. I need to verify that the sender's page contents are there when the receiver finishes adding them to his own account. I suppose I could try to build it into one gigantic testcase, but it is a very tricky script, and the smaller the pieces I can build it with, the better.

    I haven't been ignoring your responses, I've been busily trying things here.


    Thank you both, so much

    F


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

  5. #5
    Junior Member
    Join Date
    Jan 2003
    Posts
    27
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Can I set a variable in one testcase and have it hold that value for another?

    You could always have the first testcase write the data to a file, and then have the following testcase read the data from that file to make it work in a .pln.

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

  6. #6
    Senior Member
    Join Date
    Jun 2002
    Posts
    119
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Can I set a variable in one testcase and have it hold that value for another?

    well, now, there's an idea.

    I looked in Help, and there's a FileReadLine() method that should do it

    Thanks


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

  7. #7
    Senior Member
    Join Date
    Jun 2002
    Posts
    119
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Can I set a variable in one testcase and have it hold that value for another?

    it works slick!!

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

  8. #8
    Senior Member
    Join Date
    Jul 2001
    Location
    Brookline,NH USA
    Posts
    147
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Can I set a variable in one testcase and have it hold that value for another?

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by xmako:
    You could always have the first testcase write the data to a file, and then have the following testcase read the data from that file to make it work in a .pln.

    <HR></BLOCKQUOTE>I do this occasionally, but with significant enhancements, so to speak. As previously mentioned, however, I try to ensure one test doesn't rely on another -- if the latter test is a verification, then technically it should be part of the first test.

    Anyway, what I do for file operations is to use .ini files instead of .txt files. SilkTests provided INI file functions are FAR superior to the FileWriteLine and FileReadLine functions. Besides, having your data segregated in sections withing the .ini file makes things simpler anyway.

    As for storing data to keep it static between testcases, I use properties. Then, I write the property set and get methods such that they store and retrieve the values in/from an INI file.

    Additionally, I create custom objects when there isn't a window that the property specifically applies to -- winclass oMyObject : customwin. You can then define as many properties for the object as you care to use. I also find this VERY useful whenever the need arises to debug, as all the data values from a run can be stored in the .ini file and compared to your results.

    ~ Fred

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

 

 

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 10:44 PM.

Copyright BetaSoft Inc.