13

I need to load test a service I've developed but I need the data that I post to the web service to have some variance.

I've set up Thread with an Http Request and I've the parameter I need to set but I can't see how I'd go about changing the contents of the HTTP parameter from request to request.

Ideally I'd like to feed in a list of data Items and have JMeter iterate through them.

Omar Kooheji
  • 54,530
  • 68
  • 182
  • 238

3 Answers3

12

Prepare kind of csv-file with list of your test-params and use it to parametrize your test-samplers, using at least the following:

  1. CSV Data Set Config
    Explained example here, simple example here.

  2. Jmeter functions: __CSVRead, __StringFromFile.

  3. Variables From CSV sampler from jmeter-plugins.

asherbret
  • 5,439
  • 4
  • 38
  • 58
Aliaksandr Belik
  • 12,725
  • 6
  • 64
  • 90
10

One way would be to prepare a CSV file with all the values that you will need. There are a multitude of different ways to use it afterwards. Alies Belik's answer listed most of them. The drawback of the CSV approach, however, is that you need to generate the list of values, and in some tests you can't simply reuse it without cleaning up/reinitializing the back-end database.

Another option are the functions for generating random values, usually paired with "User Defined Variables" controller.

  • __Random for generating numbers in a given range.
  • __RandomString for generating random strings of a given length and containing a set of characters.

This is a powerful mechanism, but I find it somewhat cumbersome and clunky.

For simple variables, like generating username/password/e-mail combinations, I prefer and find it easier to use the Random Variable config element. It's available since Jmeter 2.3.3. You add it to your thread group and specify a variable to store the random value for each thread. You can later reference this variable in your HTTP sampler, in the GET/POST parameters of the request, by specifying the Value of the parameter to be testuser-${rnd} for username, testpass-${rnd} for password. Each thread will get a different value of ${rnd} so there is a small chance (but there is still a chance) that you will get duplicate values (users).

Community
  • 1
  • 1
zorlem
  • 450
  • 3
  • 6
  • Sorry, due to my low rating I've had to remove a number of links from my answer. I tried to leave in the most important ones. – zorlem Mar 13 '12 at 10:57
0

Besides the functions mentioned in @zorlem answer, You can also use:

  • __UUID for generating a pseudo random type 4 Universally Unique IDentifier, if you need to generate random & unique strings.