Forum Discussion

SIStester's avatar
SIStester
Occasional Contributor
13 years ago

incrementing test parameter

I'd like to know how to increment a test parameter automaticly when I run a test and keep it somewhere, to use that parameter where it was left.



We want to change our client name with "client(insert number)", and every time the test is run, it give a new client name

example:

client1

client2

client3

etc.



one client being created every time I run the test project.



What I've been having trouble with is keeping the value of that increment variable between those test runs.

The reason I'm trying to do that is because it would be a pain to overwrite my software's database every time I run a test and it's impossible to keep my test environement clean, so I might as well create a new item every time.



sorry for the bad english it's not my best language

5 Replies

  • vex's avatar
    vex
    Contributor
    Why not just create a project variable?



    i.e.





    If Not Project.Variables.VariableExists("Increment") then Project.Variables.AddVariable "Increment", "Integer"

    If Not Project.Variables.VariableExists("Client") then Project.Variables.AddVariable "Client", "String"



    i = Project.Variables.Increment

    i = i + 1

    Project.Variables.Increment = i

    Project.Variables.Client = "Client" & aqConvert.IntToStr(Project.Variables.Increment)





    Something along those lines



    (Apologies for sloppy code but you get the idea)



    On a side note, this is what I do for my new accounts, and keep them random:





    Sub unamegen(id, pass)



      a = DateDiff("s", "01/01/1970 00:00:00", Now())

     

      If id <> "" Then

        Project.Variables.sdUserName = id & "_" & a & "@xxxxthisisafakeemailxxxx.com"

      Else

        Project.Variables.sdUserName = "epoch_" & a & "@xxxxthisisafakeemailxxxx.com"

      End If    

     

      If pass <> "" Then

        Project.Variables.sdPassword = pass

      Else

        Project.Variables.sdPassword = "password"

      End If

     

      Log.Message "==="

      Log.Message "Username for this test iteration is " & Project.Variables.sdUserName

      Log.Message "==="

        

    End Sub





    It has the added bonus of being a timestamp of your user account too.
  • SIStester's avatar
    SIStester
    Occasional Contributor
    will that keep the variable in the state it was when I run the project again?
  • SIStester's avatar
    SIStester
    Occasional Contributor
    I had to adjust a bit of course but that worked great, thanks!