Random JSON/POST content

I wanted to test out our web services by generating random email address for new account creation. I found this really helpful article that demonstrated JMeter’s innate capabilities to generate random numbers and strings. I had to struggle a bit because I was uploading JSON files’s to post and used the random number sequence within. But learned that JMeter would generate random numbers only with the “Post Body” field under HTTP Sampler Request > HTTP Request > Post Body

Here’s a sample JSON that I used to generate a random email address by using the Random function:

{
  "TransactionID": "1E90F287-AB23-923A-2E8C-28ED01A7B02D",
  "RequestorTimestamp": "2013-03-01T11:22:18.01Z",
  "UserName": "Varun Verma",
  "CompanyName": "My Own Inc.",
  "EmailAddress": "varun.verma${__Random(1, 10000)}@myinc.com",
  "TotalUsers": "4",
  "StorageSize": "50",
  "ExpirationDays": 20
}

More information on functions can be found here: http://jmeter.apache.org/usermanual/functions.html

General information: http://jmeter.apache.org/usermanual/

Advertisements

2 thoughts on “Random JSON/POST content

  1. I think you should add one http sampler in the beginning of test tree which will clear all emails which match varun.verma\d+@myinc.com regexp pattern and run this only once. Also would be useful article about JMeter functions as in official documentation there is less information about usage.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s