Search code examples
javatestingjmeterweb-testing

Use request value from list of values in JMeter


I'm sure I've already done this in the past but somehow I cannot figure out how ;-) So, here's my problem:

I'm trying to create a JUnit test plan in which a HTTP request is modified each iteration by altering a specific parameter. So, for example in five iterations I want the following HTTP requests to be made:

http://localhost:8080/test/foo.html?id=1
http://localhost:8080/test/foo.html?id=2
http://localhost:8080/test/foo.html?id=3
http://localhost:8080/test/foo.html?id=4
...

I want to configure the identifier values globally for the test plan and use them within the HTTP request samplerer like this:

Path: /test/foo.html?id=${categoryId}

The question now: How do I configure the identifiers values globally (I do not want to use StringFromFile) and how do I reference them in the sampler?


Solution

  • There are several ways you can do this.

    Given you have an array of values you could:

    • Try the pre-processor "User Parameters", creating one entry for each user/loop
    • Use a Beanshell script to create the array, select one at random and populate your variable

    You reference them exactly as you have listed: ${varName}