How to get LoadRunner iteration number - using global variable?

How to get LoadRunner iteration number - using global variable?

I continue explaning about LoadRunner iteration number.
Well, how to determine the current iteration number?

  • The first way is to use LoadRunner parameter od 'Iteration Number' type.
    It is described here
  • 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.

  1. Define a global variable
    You can add a new variable definition into vuser_init section of LoadRunner script:

  2. 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.

  3. 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:

  4. 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 :)
--
Dmitry Motevich



Related articles:

No comments: