You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jmeter.apache.org by Zhaoxia Yang <ya...@gmail.com> on 2012/10/28 04:48:01 UTC

RandomStrings in for loop are not random at all

> Hi,
> 
> I have below script in post or pre processor of JMeter. I want the Strings are generated randomly for each loop.
> 
> for(i=0;i<5;i++)
> {
>   var rdStrA="${__RandomString(5,abcdefghijklmnopqrstuvwxyz)}";
>   var rdStrB="${__RandomString(5,abcdefghijklmnopqrstuvwxyz)}";
>  vars.put("rdStrA"+i, rdStrA);
>  vars.put("rdStrB"+i, rdStrB);
> }
> 
> The result is:
> For the 5 times loop, rdStrAs are always same, rdStrB is different from rdStrA but 5 rdStrBs are same.
> 
> The response data of Debug Sampler shows:
> ...
> rdStrA0=cnbyw
> rdStrA1=cnbyw
> rdStrA2=cnbyw
> rdStrA3=cnbyw
> rdStrA4=cnbyw
> rdStrB0=bomad
> rdStrB1=bomad
> rdStrB2=bomad
> rdStrB3=bomad
> rdStrB4=bomad
> 
> This is really odd.
> I also tried __Random(min,max) to generate random integer inside for loop, it also performs the same way.
> 
> Thanks.
> 
> Zhaoxia Yang
> 
> 
> 
> 


Re: RandomStrings in for loop are not random at all

Posted by sebb <se...@gmail.com>.
This is off-topic for the JMeter developer list.

Please subscribe to the JMeter user list and repost there.

On 28 October 2012 03:48, Zhaoxia Yang <ya...@gmail.com> wrote:
>
>> Hi,
>>
>> I have below script in post or pre processor of JMeter. I want the Strings are generated randomly for each loop.
>>
>> for(i=0;i<5;i++)
>> {
>>   var rdStrA="${__RandomString(5,abcdefghijklmnopqrstuvwxyz)}";
>>   var rdStrB="${__RandomString(5,abcdefghijklmnopqrstuvwxyz)}";
>>  vars.put("rdStrA"+i, rdStrA);
>>  vars.put("rdStrB"+i, rdStrB);
>> }
>>
>> The result is:
>> For the 5 times loop, rdStrAs are always same, rdStrB is different from rdStrA but 5 rdStrBs are same.
>>
>> The response data of Debug Sampler shows:
>> ...
>> rdStrA0=cnbyw
>> rdStrA1=cnbyw
>> rdStrA2=cnbyw
>> rdStrA3=cnbyw
>> rdStrA4=cnbyw
>> rdStrB0=bomad
>> rdStrB1=bomad
>> rdStrB2=bomad
>> rdStrB3=bomad
>> rdStrB4=bomad
>>
>> This is really odd.
>> I also tried __Random(min,max) to generate random integer inside for loop, it also performs the same way.
>>
>> Thanks.
>>
>> Zhaoxia Yang
>>
>>
>>
>>
>