SPONSORS:






User Tag List

Results 1 to 7 of 7
  1. #1
    Senior Member
    Join Date
    Sep 2001
    Location
    California, USA
    Posts
    164
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Same value created for Randstr

    When I try to perform a Randstr for the following: sName = Randstr ("A(10)") I get the value "dKqeYSuqmJ" the first time I run the test. I am running an initial test to make sure the test passes.

    Later on when I come back to run through my suite of tests this same value "dKqeYSuqmJ" is "randomly" entered. This causes an error because the name already exists in the site I am testing.

    Any idea as to why this value is always selected first in the random string? It doesn't seem like there is a true random selection in this string.

  2. #2
    Senior Member
    Join Date
    Aug 1999
    Location
    MA
    Posts
    129
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Same value created for Randstr

    The issue you're seeing is since the random number generator takes a seed value. If the seed is not set then it always starts with the same pattern.

    Do get a near random sequence, first call RandSeed (iSeed), and make iSeed an integer of the current time (e.g. 12:34:01 PM --> 123401 in hhmmss form). Seed the generator with this value then make the call to RandStr.

    Given that time elapses in your test suite, further seeding and RandStr will generate different patterns. You still run the off chance that you duplicate a pattern so you could save off the strings you've already used and check that you don't have a duplicate.

    ------------------
    Steven Tyler
    SQA Automation Team Manager
    Workforce Central Group
    Kronos Incorporated
    E-Mail: styler@kronos.com www.kronos.com
    Improving the Performance of People and Business™

    [This message has been edited by styler (edited 01-07-2003).]

    [This message has been edited by styler (edited 01-07-2003).]
    Steven Tyler
    Manager - Performance Engineering

    Kronos Incorporated
    tel: +1 978 947 4219

  3. #3
    Senior Member
    Join Date
    Jun 2000
    Location
    Chicago, IL USA
    Posts
    383
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Same value created for Randstr

    CrazyQABoy:

    The best way to prevent this is to seed the random number generator with the time-of-day using Randseed().

    I created a Randomize() function that I use at the beginning of all testcases that use randomness. It creates a seed using all of the parts of the clock, so that I do not accidentally recreate a previous seed. It then logs the seed in the test results. That way, if I want to recreate a scenario in which a bug appeared, I can copy the seed from the results and paste it as an argument to Randomize(). The test then does exactly what it did before. Cool Huh ?


    ------------------
    Rob Kapteyn
    Rob Kapteyn, CSTE
    RobKapteyn@gmail.com

  4. #4
    Junior Member
    Join Date
    Mar 2001
    Posts
    18
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Same value created for Randstr

    One step cooler: I also created a function that does just what Randomize() does. However, instead of placing it in every test case where you need to use it, I put it in my custom TestCaseEnter() function, so that the random functions are seeded automatically using the date-time stamp at least once per test case.

    Tom

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

  5. #5
    Senior Member
    Join Date
    Sep 2001
    Location
    California, USA
    Posts
    164
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Same value created for Randstr

    Thanks all for your responses! The assistance is appreciated

  6. #6
    Member
    Join Date
    Sep 2002
    Location
    Foster City, CA, USA
    Posts
    55
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Same value created for Randstr

    This is great. I'll try this out. I've been having this problem for a long time, contacting Segue for help and they think I am crazy. You guys are the real experts!

  7. #7
    Member
    Join Date
    Sep 2002
    Location
    Foster City, CA, USA
    Posts
    55
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Same value created for Randstr

    I actually do have a question about the RandSeed(). Seems like it only takes in integer. If I have been using a pre-existing pattern, such as RandStr("A9A9A9A9A9"), the random string contains letters, not just numbers. Would feeding the RandSeed with new integer(s) help randomize that pattern that contains nonnumerics? Or any RandStr("AAAA") that contains no numbers at all?

    [This message has been edited by kchan (edited 01-24-2003).]

 

 

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:38 PM.

Copyright BetaSoft Inc.