How to determine the current iteration number?
The first way is to use LoadRunner parameter od 'Iteration Number' type.
The second way is to use a LoadRunner global variable.
I will explain this approach now. Also, you will see how to define and use global variables.
Define a global variable
You can add a new variable definition into vuser_init section of LoadRunner script:
Then we will add a variable incrementation and usage into Action section of LoadRunner script. For example, like this:
Please, note that LoadRunner does not require using of "extern" keyword.
And last step is to open LoadRunner Run-time Settings and to set the desired total iteration count. In my example I set it to 3:
That's all! Let's start our script and see Log-file:
As you can see, nIterationNumber variable changes its values with every new iteration.
Tip: do not forget to increment its value, for example with ++ operator.
Both proposed approaches (with LoadRunner parameter and with a global variable) are simple enough. Use any you like and track your LoadRunner iterations thoroughly :)
The first way is to use LoadRunner parameter od 'Iteration Number' type.
The second way is to use a LoadRunner global variable.
I will explain this approach now. Also, you will see how to define and use global variables.
Define a global variable
You can add a new variable definition into vuser_init section of LoadRunner script:
Then we will add a variable incrementation and usage into Action section of LoadRunner script. For example, like this:
Please, note that LoadRunner does not require using of "extern" keyword.
And last step is to open LoadRunner Run-time Settings and to set the desired total iteration count. In my example I set it to 3:
That's all! Let's start our script and see Log-file:
As you can see, nIterationNumber variable changes its values with every new iteration.
Tip: do not forget to increment its value, for example with ++ operator.
Both proposed approaches (with LoadRunner parameter and with a global variable) are simple enough. Use any you like and track your LoadRunner iterations thoroughly :)
1 comment:
This "global" counter is really a local to a context of that particular vuser.
What if you wanted something shared and modified by all vusers, really a global counter? As an example comes to mind "Total passed transactions" counter.
Post a Comment