Software development has undergone a massive evolution in the last decade. The growth has also created an increased need for various testing tools to ensure the final product matches the expectation. JMeter is one the best open source software testing tool, which is a complete Java application for both load and performance testing. It has been specifically designed for conducting different kinds of tests like performance testing, regression testing, functional testing, load testing, etc.
Jmeter Use For Conducting Different Kinds Of Tests
Before moving on to the basics of JMeter, here is a quick brush-up of some important tests which have gained high popularity in recent times:
A). Performance Test:
Performance tests have become the most important client expectations at the time of product delivery. There are no takers for apps which are slow and do not meet the benchmark in terms of speed, loading time, user experience, and design. The test thus checks the performance expectation under a given infrastructure and highlights any changes to be made in the testing process before the application is sent for production. The basic criteria which are tested under this are:
- Response Time
Although there are many tools for performance testing like LoadRunner, WebLOAD, LoadUI, NeoLoad, etc. but JMeter has finally become the most preferred one.
B). Load Test:
As the name suggests, the test helps to check the performance of the app at its maximum load, as it is designed for.
C). Stress Test:
The test is designed to break the system by subjecting it to tremendous resource weight, so different parts of the same are overwhelmed.
What is JMeter?
JMeter has attained a level of significance over the years due to its apt performance and reliability. Stefano Mazzocchi of Apache Software was the first to develop it. It is a Java-based application for desktops and makes use of Swing graphical API. Hence it can be used in any environment like Linux, Windows, Mac, etc.
It was originally developed with a view for testing the performance of Apache JServ which is now known as the Apache Tomcat project. Apache later redesigned JMeter for enhancing the Graphical User Interface and addition of other functional capabilities. Apache JMeter 3.1 is the current version which is also available in the market although there are many more new additions to be added to in the future.
Protocols Supported by JMeter
- Web-HTTP, HTTPS sites
- Database through the JDBC drivers
- Messaging Oriented Service via JMS
- Service-POP3, IMAP, SMTP
- FTP Service
Why has JMeter Become Popular?
The popularity of JMeter is due to many reasons which compel businesses and other Quality Assurance Teams to pick it as the primary tool for taking care of performance testing. Here are some of the reasons:
Read: Database Testing Interview Questions and Answers for Fresher and Experienced
- It is a freely available tool as it is completely open-source. It is readily present in the Apache Website.
- Its user-friendly interface helps the testers to become easily familiar with it and many of its components. Documentation for help for every component is already present inside the tool.
- It is known to be easily extensible as users can create their own samplers making use of the JSR223 and many other plugins for Samplers. These allow the testers for increasing the testing capabilities.
- It has a wide range of protocol support like FTP, HTTP, LDAP, SOAP, etc.
- There is an in-built Test Script Recorder which is used for recording all kinds of actions from either a website or an app, and the load can further be simulated for testing performance under various kinds of load conditions. A Chrome extension is also available for recording the actions and then the same script which can be used in JMeter for scaling the load.
- JMeter can also be integrated with Selenium for various kinds of Automation testing.
- It is very easy to install JMeter. All you need is to install a Java application on your computer. JMeter can then be downloaded to run the .bat file.
- Results from JMeter often come in different formats like trees, graphs, and even table representation.
The only system requirement is JDK of 1.6 or above and no specific requirement of memory, disk space, and operating system.
Installation of JMeter
JMeter falls in the Java framework, and thus, the first requirement is to have JDK installed on the machine. Once Java is installed, you are next required to set the JAVA_HOME variable. The steps for the same are as follows:
- Firstly, you are required to check the directory where Java is installed. Many times it is installed in “C:\Program Files\Java\jdk1.8.0_112”
- Next, you have to click on the “My Computer” and then open properties.
- Now you have to click on the Environment Variables button.
- Then you have to click on New under the System Variables section.
- You then have to enter the JAVA_HOME in the variable name text field.
- In the case of the Variable Value Text field, you have to enter the JDK/JRE path of installation.
- Finally, you have to click OK
When Java is installed then you are required to open the console and execute either one of the Java commands depending upon which Operating System you are working on:
- In case of Windows you have to Open Command Console by the command c:\> java—version
- In case of Linux, you are required to Open Command Terminal by the command $ java -version
- In case of Mac, you have to Open Terminal by the command machine: ~ joseph $ java -version.
The output of these commands will depend on the Operating System, which is being used.
Now you have to install JMeter from the https://jmeter.apache.org/download_jmeter.cgi
Once it is downloaded and copied in the C:\>JMeter folder, the directory should look like the following:
the directory apache-jmeter can be renamed if required but you should not change the names of the sub-directories.
Next, you are required to run JMeter by going to the bin directory. The output will again depend on the Operating System. In the case of
Read: Why is Performance Testing Important?
- Windows, it will be jmeter.bat
- Linux, it will be jmeter.sh
- Mac, jmeter.sh
JMeter Graphical User Interface shows up after a short gap. It is a Swing Application and looks like the following:
The above is the main image of the tool.
Elements of JMeter
The different components of JMeter are called its elements. Every Element of JMeter has been designed for a particular purpose. Some of the primary elements are:
1). Thread group: It is basically a collection of threads. Every thread stands for a user making use of the application under test. It makes one real user make a server request. The thread group controls also allow for setting the number of threads for every group. E.g., if the number of threads is marked at 100, JMeter will allow for creation and stimulation of 100 user requests for the server under test.
2). Samplers: Many testing protocols are supported by JMeter like HTTP, FTP, JDBC, etc. As the Thread Groups help in the stimulation of user request to the server they are the samplers which assist the thread groups in deciding what requests needed to be made like HTTP, FTP, JDBC, etc. Given below are a list of Samplers:
- FTP Request: It is used in JMeter for carrying out a performance test on an FTP Server. It helps you to send an FTP “download file” or “upload file” request to the FTP Server.
- HTTP Request: It helps you to send an HTT/HTTPS request to the webserver.
- JDBC Request: It helps in the execution of Database Performance Testing by sending a JDBC Request to a database.
- BSF Sampler: It allows you to write a Sampler by making use of BSF Scripting Language.
- SMTP Sampler: This enables the user to send email messages by making use of an SMTP protocol.
- Access Log Sampler: It helps in reading of access logs and thereby help in generation of HTTP requests.
3). Listeners: They present the results of the test execution in the form of a tree, table, log file or even a graph.
- Listeners who show graph results often show the server response times on a Graph.
- View Result Tree shows that the results of the user request in the HTML format.
- Table Results present summary of a test result in the form of a table.
- Logs show the summary of test results in the form of a text file.
4). Configuration: These elements are used for setting up defaults and variables to be used later by samplers. Various types of Configuration Samplers are as follows:
- CSV Data Set Config: This element allows reading of different parameters from a text file. It is used to read lines in a file and then split them into various variables.
- HTTP Cookie Manager: It has the same features like a web browser. If you make an HTTP Request and the response has a cookie, the Cookie Manager stores the same for use in all the future requests.
- HTTP Request Default: It helps in setting the default values, which is used by this controller.
- Login Config Element: It helps add or override settings of username and password in the samplers.
Other components of JMeter include WorkBench, Pre-Processor, Post Processor, Logic Controllers, Timer, Assertions, etc.
JMeter Functions and User Variables
JMeter Functions stand for special values which can fill the fields of any Sampler or any other element in the test tree. Functions are of two kinds:
Read: Top 100 Software Testing Interview Questions and Answers
- User-defined static values
- Built-in functions
The user-defined static values let the user define variables which have to be replaced by static value when the test tree is compiled and have to be submitted to be run. It is not possible to nest these variables.
There are some restrictions on the functions which are used in a Test Plan. The thread values of JMeter are not completely set up when the functions are processed, so the names of variables which are passed as parameters will not be set up, and the variable references will not work. Hence, split () and regex () and other variable evaluation functions will not work. The thread num () function will thus not work as it does not make any sense at the test plan level.
Referencing of Functions and Variables
- Any kind of referencing of a variable in a test element is handled by bracketing of the variable name.
- Even the functions are referenced in the same way but going by the convention, the names of the functions will begin with an underscore for avoiding any kind of conflict and user value names.
- Many functions take arguments for configuring them, and all these go in parentheses, comma-delimited. If the function has no arguments, the parentheses can be avoided.
- Even the script can be defined as a variable.
A Function Helper is present in the Options tab.
- A Function helper can be used for selecting a function from a drop-down menu and assigning of values for the various arguments. A concise description of the argument is given by the left column in the table while the right column is the place where the value for the argument is written. Different functions have different arguments.
- Once done, you have to click the generate button for the generation of the appropriate string which can be used to copy-paste in the test plan.
Best Practices of JMeter
JMeter has some limitations but will little carefulness the resource requirements can be brought down significantly. These are as follows:
- If the number of threads is more, then you should prefer using multiple instances of JMeter.
- Scoping Rules and Design are checked suitably.
- Naming conventions are always used for the elements.
- Listeners can be added appropriately.
- One should use the non-GUI mode.
- You should try to use a minimum number of listeners.
- The “View Result Tree” listener can be disabled as it requires a lot of memory. If often results in freezing of the console or even JMeter running out of the memory.
- Instead of making use of many similar Samplers one can make use of the same sampler in a loop and use variables to vary the sample.
- The functional mode is not to be used.
- One has to use the CSV output rather than the XML.
- One has to save data only when needed.
- Assertions also should be minimally used.
- All the JMeter graphs have to be disabled as they involve a lot of memory.
- Before every test run, it is important to clean the Files tab.
JMeter is an emerging open-source software with a graphical interface by the Apache Software Foundation. It supports many protocols and can be run in any environment. Its popularity is based on many benefits it carries like free availability, intuitive graphical user interface and is highly extensible.
For more information on JMeter and related technologies, you may refer to www.janbasktraining.com or get in touch with us.
Testing Vs. Different Technologies
- AWS & Fundamentals of Linux
- Amazon Simple Storage Service
- Elastic Compute Cloud
- Databases Overview & Amazon Route 53
-1 day 02 Jul 2022
- Intro to DevOps
- GIT and Maven
- Jenkins & Ansible
- Docker and Cloud Computing
-1 day 02 Jul 2022
- Data Science Introduction
- Hadoop and Spark Overview
- Python & Intro to R Programming
- Machine Learning
5 days 08 Jul 2022
- Architecture, HDFS & MapReduce
- Unix Shell & Apache Pig Installation
- HIVE Installation & User-Defined Functions
- SQOOP & Hbase Installation
5 days 08 Jul 2022
- Salesforce Configuration Introduction
- Security & Automation Process
- Sales & Service Cloud
- Apex Programming, SOQL & SOSL
12 days 15 Jul 2022
- Introduction and Software Testing
- Software Test Life Cycle
- Automation Testing and API Testing
- Selenium framework development using Testing
5 days 08 Jul 2022
- BA & Stakeholders Overview
- BPMN, Requirement Elicitation
- BA Tools & Design Documents
- Enterprise Analysis, Agile & Scrum
5 days 08 Jul 2022
MS SQL Server
- Introduction & Database Query
- Programming, Indexes & System Functions
- SSIS Package Development Procedures
- SSRS Report Design
5 days 08 Jul 2022
- Features of Python
- Python Editors and IDEs
- Data types and Variables
- Python File Operation
-1 day 02 Jul 2022
- Components of AI
- Categories of Machine Learning
- Recurrent Neural Networks
- Recurrent Neural Networks
13 days 16 Jul 2022
- Introduction to Machine Learning & Python
- Machine Learning: Supervised Learning
- Machine Learning: Unsupervised Learning
26 days 29 Jul 2022
- Introduction to Tableau Desktop
- Data Transformation Methods
- Configuring tableau server
- Integration with R & Hadoop
6 days 09 Jul 2022
Receive Latest Materials and Offers on QA Testing Course