Forum Discussion

RaMup29's avatar
RaMup29
Occasional Contributor
9 years ago

how can I give a variable in my load test,

I have Soap request which I will be using in LoadTest But the problem is LoadTest will run the same query again n again in the loop I want the loadtest to have a variable assigned, so the variabl...
  • rupert_anderson's avatar
    rupert_anderson
    9 years ago

    Hi,

     

    So to generate a random number every time (with the same number of digits that you have in your example) you can use:

     

    ${= ((String)(int)(Math.random()*10000000000000)).padLeft(14,'0')}

    This would generate something like:

     

    00002147483647

     

    Breaking the one-liner down:

     

    (int)(Math.random()*10000000000000) //generates a random integer >0 and <10000000000000

    Then, to get the right number of digits every time, I padded the number with zeros from the left:

     

    .padLeft(14,'0')

    Will this do?

     

    Regards,

    Rup