Search code examples
jmeterjmeter-pluginsjmeter-5.0jmeter-4.0jmeter-3.2

Jmeter random number generation


I have a requirement to generate a random number and use it in subsequent requests. So, before using this newly generated random number in first subsequent request, i need to check if this random number generated is already exists in the application or not by comparing with newly generated response number. So for this validation i am thinking to use an extractor to get the count and eventually verify this is >1 and make it run until this condition is invalid. So in case of random number already exists, i need to generate a new random value since the previous one is already exist in the application. Any snippet i can use here?


Solution

  • An easier option would be going for __time() function which produces an Unix timestamp in milliseconds from 1st of Jan 1970. To be on the safe side you can add current thread number to it so even in case of concurrency you would get unique values (incrementing each millisecond):

    enter image description here

    More information on JMeter Functions concept: Apache JMeter Functions - An Introduction