EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 600+ Courses All in One Bundle
  • Login
Home Software Development Software Development Tutorials JMeter Tutorial JMeter Random Variable
Secondary Sidebar
JMeter Tutorial
  • JMeter Basic and Advanced
    • What is Jmeter
    • Install Jmeter
    • JMeter API Testing
    • JMeter if controller
    • JMeter JSON Extractor
    • JMeter Recording
    • JMeter CSV Data Set Config
    • JMeter Command Line
    • JMeter Report
    • JMeter HTTP Request
    • JMeter While Controller
    • JMeter with Selenium
    • JMeter Script
    • JMeter Constant Throughput Timer
    • JMeter Random Variable
    • JMeter tool
    • JMeter BlazeMeter
    • JMeter Parameters
    • JMeter Plugins
    • JMeter Performance Testing
    • JMeter load testing
    • JMeter BeanShell
    • JMeter User-Defined Variables
    • JMeter WebSocket
    • JMeter Aggregate Report
    • JMeter Distributed Testing
    • JMeter Summary Report
    • JMeter Response Assertion
    • JMeter Assertion
    • JMeter Thread Group
    • JMeter Loop Count
    • JMeter Variables
    • JMeter Testing
    • JMeter Version
    • Timers in Jmeter
    • JMeter Alternatives
    • JMeter Command Line Options
    • JMeter Ramp Up Period
    • JMeter Plugin Manager
    • JMeter Throughput
    • JMeter Regular Expression Extractor

JMeter Random Variable

JMeter Random Variable

Introduction to JMeter Random Variable

The following article provides an outline for JMeter Random Variable. Today, most programming languages have an API that produces random numbers. The generator algorithm produces a typical sequence of numbers without any structure, order, or format. This algorithm is based on seed value which drives the sequence generation. In JMeter, the random variables can be generated and passed in a load test. In a load test, there is a need to pass any random values to a constrained parameter in the request. It can be achieved by passing different values from the .csv file, which has distinct values to use in the request. It is also possible to generate random variables at every request execution.

What is JMeter random variable?

JMeter enables the user to produce random numbers and use them as a variable. It can be achieved with the configuration element of a random variable. It enables the user to configure all the mandatory parameters like format string, variable name, per-thread values, user counts, random speed, and minimum and maximum values. The random values can be generated in three methods using JMeter. They are epoch methods using CSV files and a random variable sampler.

How to use the JMeter random variable?

To generate random variables in JMeter, all the configuration fields must be set, and the user should determine which method he will use to generate random variables.

It can be generated using the epoch time; then, it can be generated using CSV files to produce its own set of generated values. Then in a random variable sampler, the user can choose the seed values, length of values, and other available configurations.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

In the variable name field, give the appropriate name used in the test plan, and it can be saved in this variable.

All in One Software Development Bundle(600+ Courses, 50+ projects)
Python TutorialC SharpJavaJavaScript
C Plus PlusSoftware TestingSQLKali Linux
Price
View Courses
600+ Online Courses | 50+ projects | 3000+ Hours | Verifiable Certificates | Lifetime Access
4.6 (86,560 ratings)

In the format string, give the format of the number that wants to be generated. It can be used as a prefix or suffix with a string. It is also possible to generate alphanumeric values.

In minimum and maximum fields, the user has to define the numbers’ range that needs to be generated. For example, the minimum value can be 10, and the maximum can be 50.

In the per-thread field, the user has to give whether the random generator should be shared by all the users or every thread has its instance random values. It can be set using the true or false option.

Random speed is used to choose the seed value of the generator. If the same seed is used for all threads, it generates the same number for every thread.

Create JMeter random variable

In the below section, the test plan in JMeter is created.

Select the test plan from the tree, then add the thread group. To include the thread group, right-click the test plan and include the new thread from the thread group.

JMeter Random Variable output 1

Add the elements of JMeter used in the HTTP request sampler. The control panel of HTTP requests indicates the URL request that needs to be transferred. Right-click on the thread group and choose sampler, then HTTP request. A few of the values in the HTTP request to execute the test are the name of the request, server name or IP or localhost, port, method name, and the path of the request.

JMeter Random Variable output 2

Then add a random variable by selecting configuration elements on the thread group and select a random variable from there. The variables of the cache key have parametric values, and the reqcachekey will generate random values passed to the parameter cachekey present in the request’s body.

JMeter Random Variable output 3

Seed generates random values; if left empty, the test can be executed multiple times. However, the seed is not left blank if it has the same set of repeated values.

JMeter Random Variable output 4

Then listeners can be added to the test plan, and the result can be viewed in different formats like table, graph, tree, or log file. In the view result tree of the user, request choose view result tree from listener then include in the test plan.

output 5

Save the test plan, give the appropriate name to the test plan, and it will be saved in JMX format.

Execute the test plan by clicking on the green triangle placed on the top pane.

output 6

The execution status can be viewed in the view result tree to see the status, and the successful request is marked in green.

JMeter random variable examples

The random values can be generated in the configuration element. Nowadays, generating or picking the test case of a random variable is a tough task. So the user can have a test case where the test has a random number and checks if it is an acceptable range or if the number format is valid or invalid. The other test case can be defined as the user giving a few random numbers as a URL section like order id, or page numbers can be mentioned. It is used to execute the load testing on these URL pages. The configured variable in the HTTP request can be used as a sampler on this part of the URL request. It will test the Java section pages on JCG websites.

output 7

The random variable option can be used if the user wants to execute a load test on several URL pages with parameter values that can be substituted dynamically at the execution time. It also supports load testing on both web models, client-server and host with static and dynamic resources. In addition, it works on a wide range of protocols like HTTP, JMS, HTTPS, FTP, and JDBC.

Conclusion

The user must sometimes generate JMeter scripts and then work on the request. So, the URL needs an auto-generated and constrained value as a suitable parameter in this case. JMetIn addition there uses multiple methods to generate random variables, which are briefly discussed here. So it is up to the user to select the suitable method for his generation of random variables.

Recommended Articles

This is a guide to JMeter Random Variable. Here we discuss How to use the JMeter random variable and the examples. You may also look at the following articles to learn more –

  1. JMeter Alternatives
  2. Timers in JMeter
  3. Install JMeter
  4. JMeter Interview Questions
Popular Course in this category
JMeter Testing Training (3 Courses)
  3 Online Courses |  9+ Hours |  Verifiable Certificate of Completion |  Lifetime Access
4.5
Price

View Course
0 Shares
Share
Tweet
Share
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Java Tutorials
  • Python Tutorials
  • All Tutorials
Certification Courses
  • All Courses
  • Software Development Course - All in One Bundle
  • Become a Python Developer
  • Java Course
  • Become a Selenium Automation Tester
  • Become an IoT Developer
  • ASP.NET Course
  • VB.NET Course
  • PHP Course

ISO 10004:2018 & ISO 9001:2015 Certified

© 2022 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA
Free Software Development Course

C# Programming, Conditional Constructs, Loops, Arrays, OOPS Concept

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more