4
votes

I am thinking about how to test a servlet with two parameters: X and Y, using JMeter.

X and Y are random numbers from 0 to 100.

I am thinking of implement a nested loop which is something like

for (int x = 0; x <= 100; x++)
    for (int y = 0; y <= 100; y++)
        servlet?param1=x&param2=y

Could anyone give a hint on how to implement this using Counter and Loop Controller or something else ?

1

1 Answers

7
votes

Your schema may be like the following below:

    Thread Group
        User Defined Variables
        maxX = 100
        maxY = 100
        Loop Controller X
        Loop Count: ${__BeanShell(Integer.parseInt(vars.get("maxX"))+1)}
        Counter X
        Start: 0
        Increment: 1
        Maximum: ${maxX}
        Reference Name: loopX
            Loop Controller Y
            Loop Count: ${__BeanShell(Integer.parseInt(vars.get("maxY"))+1)}
            Counter Y
            Start: 0
            Increment: 1
            Maximum: ${maxY}
            Reference Name: loopY
                    YOUR HTTP Request
                    servlet?param1=${loopX}&param2=${loopY}
                    . . .

enter image description here

Here you can find solution for your case but with CSV data sources used instead of counters:
Looping 2 CSV files