You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Massas <mu...@hotmail.com> on 2009/02/20 14:49:43 UTC

Controlling loop

Hello again all.

I seem to have more problems..

I'm having problems with variables in an embedded loop. 

>From an regexp i get a variable which controls how many times a loop should
run. In this loop, i want to use another variable which starts at 1 (lets
give it the origninal name of ${counter}) and increments for each embedded
loop. However, if looping the entire test case i always want to enter this
embedded loop with the ${counter} value of 1.

Here i have my problem. When running once, it works like a charm. But if i
run the whole test case more than one loop the ${counter} keeps incrementing
(not restarting at 1)

Tring to put it in a more visual way:

Thread group
+ Regexp out a variable (ex 3)
+ loop regexp variable times with ${counter}=1
++ do stuff in loop
++ ${counter}++
+ End of test

On the next loop of the whole testcase the ${counter} will enter with the
value of 4, but i need it to restart at 1. Is there a way to do this?

Thanks in advance, and have a good weekend all.


-- 
View this message in context: http://www.nabble.com/Controlling-loop-tp22120197p22120197.html
Sent from the JMeter - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: Controlling loop

Posted by Noel O'Brien <no...@newbay.com>.
I had the exact same problem and found to only solution was to create my own 
counter element, with a corresponding reset element:



Counter (Beanshell Pre-precessor):

c = Integer.parseInt(vars.get("count"));
c++;
vars.put("count", ""+c);



Reset/Initializer (Beanshell Pre-precessor):

vars.put("count", "0");



Regards,
noel

On Friday 20 February 2009 13:49:43 Massas wrote:
> Hello again all.
>
> I seem to have more problems..
>
> I'm having problems with variables in an embedded loop.
>
> From an regexp i get a variable which controls how many times a loop should
> run. In this loop, i want to use another variable which starts at 1 (lets
> give it the origninal name of ${counter}) and increments for each embedded
> loop. However, if looping the entire test case i always want to enter this
> embedded loop with the ${counter} value of 1.
>
> Here i have my problem. When running once, it works like a charm. But if i
> run the whole test case more than one loop the ${counter} keeps
> incrementing (not restarting at 1)
>
> Tring to put it in a more visual way:
>
> Thread group
> + Regexp out a variable (ex 3)
> + loop regexp variable times with ${counter}=1
> ++ do stuff in loop
> ++ ${counter}++
> + End of test
>
> On the next loop of the whole testcase the ${counter} will enter with the
> value of 4, but i need it to restart at 1. Is there a way to do this?
>
> Thanks in advance, and have a good weekend all.



---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org