Kobiton Blog

shape

Subscribe to Our Blog

Get the latest articles on all things testing delivered straight to your inbox.

Kobiton needs the contact information you provide to us to contact you about our products and services. You may unsubscribe from these communications at any time. For information on how to unsubscribe, as well as our privacy practices and commitment to protecting your privacy, check out our Privacy Policy.

State of Test Automation 2020- Front cover

Download the State of Test Automation Report

Download Now

Introduction

Application Performance Management is of prime concern for many IT organizations - a slow running application will negatively impact the customer experience and cause churn. Performance is not merely a question of load time and application responsiveness; the real question is whether the end-users are satisfied with the experience? Your software is likely to suffer from issues such as running slow while several users use it simultaneously and inconsistently across different operating systems.

Most performance-related issues revolve around speed, poor response time, load time, and poor scalability. Performance testing aims to remove Performance bottlenecks and reveal how a system behaves and reacts in various situations.

Apache JMeter is a pure Java-based open-source tool to measure performance and test Web Applications and Mobile Web Applications. Meter can simulate a heavy load on a server by creating tons of virtual concurrent users to the web server. It supports multiple operating environments like MS Window, Macintosh, and Linux. 

History

JMeter was first developed by Stefano Mazzocchi of the Apache Software Foundation. He sat down and made it primarily to test the performance of Apache JServ, which the Apache Tomcat Project later replaced. JMeter is the most popular performance testing tool provided by Apache Software Foundation.

The major release version history:

  • Apache Jmeter 1.0 Release :15/12/1998
  • Apache Jmeter 2.0 Release :12004
  • Apache Jmeter 3.0 Release :17/05/2016
  • Apache Jmeter 4.0 Release :10/02/2018
  • Apache Jmeter 5.0 Release :18/09/2018
  • Apache Jmeter 5.2.1 Release :01/04/2020
  • Latest Apache Jmeter 5.4.1

Why JMeter?

  1. Apache JMeter is an open-source load and performance tool. It’s a pure Java application designed to load functional test behavior and measure performance. It is platform-independent, and to make this tool stronger Apache JMeter development community works to enhance the JMeter features.
  2. Zero acquisition cost: Simply download the binaries from their website.
  3. Support for various Protocols: JMeter is not a browser- it works at the protocol level, supports multiple protocols such as HTTP, HTTPS, SOAP / XML-RPC, POP3, IMAP, SMTP, JMS, FTP.
  4. Ease of Learning: Anyone with software testing experience or knowledge at any level will find JMeter easy to learn and use.
  5. Extensive Documentation: There is extensive documentation on the official website.

 

If you need to test the functional behavior of your applications, there are elements in JMeter that can provide you with regression tests of your applications. A mere assertion on response code, in addition to the test scripts, helps to ensure whether your application is returning the expected response code or not. Scalability and flexibility are also intrinsic to JMeter, and you can also extend the assertions using regular expressions.

What can’t JMeter do?

It can only test performance of Web-based applications.

Architecture of JMeter

A user performs some action on the browser; the browser interacts with a Web server via HTTP/HTML requests to the Web server. JMeter acts like a group of users sending requests to a target server. It collects responses from the target server and other statistics that show the performance of the application or server via graphs or tables.

JMeter generates a virtual load on the server and simulates the real-world user activities. Each thread sends a request to the server and validates the performance of the application.

Picture1

Easy to use GUI 

A typical test plan, which describes a series of steps JMeter will execute when run, will consist of one or more:

  • Thread Groups, Samplers, Listeners, Assertions, Logic controllers, Timers, and Configuration Elements
    • Thread Group: Each thread acts as a single user. All elements of a test plan must be aligned under a thread group.
    • Samplers: Samplers informs JMeter to send requests to a server.
    • Listeners: Provide access to the information gathered by JMeter about the test cases while JMeter runs.
    • Assertions: Assertions are used to validate the response of the request made. It is the verification process of Actual vs. Expected.
    • Controllers: Logical Controllers let you customize their logic.
    • Timers: Timers allow delaying and adding pauses between each request that a thread makes to the server.
    • Configuration Elements: Works closely with a Sampler. These can add to or modify requests.

The following screenshot lets you see the icons representing these elements:

test screenshot

The User Interface of JMeter contains two panels. The left side frame includes elements of the test plan, and the right side frame has the configuration of Element. A Test plan contains all the test elements you need to perform a test.

All samplers, Listeners, Timers, Assertions, Controllers, etc., constitute a ‘Test Plan’ in JMeter.

Workbench has been dropped from the UI, you can now use Non Test Elements as immediate children of a Test Plan.

workbench screenshot

The left panel displays the elements/nodes used in your testing. The right panel displays the details of each element.

Adding and removing the elements are as easy as right-clicking a node and selecting Add/Remove respectively from the sub-menu.

threadgroup

Requirements

Prerequisites:

  1. The supported Java version should be installed on your system from the official web site of Apache JMeter. If the supported version is not installed, then uninstalled the existing version by following the below steps:
    Control panel>Program and features>Java x
  2. Download and Install the supported version of Java. Check if Java is installed on your machine. For a quick check, go to command prompt and type Java --version
    java versionIf not, then you need to first install Java in your system. And then Set up Java Path:
    -Control Panel->System->Advanced system setting->Environment variable

    System property select the variable path under the variable column and click Edit. Here you can add or update the Java path, and click OK.
  3. Machine/LG should have sufficient memory. If there is no provide guideline around minimum memory requirement, it is recommended to use a system with a good memory. The more memory a machine has, the more number of threads can be generated.
  4. Download JMeter jars from the official Apache JMeter website.
  5. Unzip and keep JMeter in any location on your system.
  6. Start JMeter by navigating to:
    For Windows Operating System->Jmeter/bin/->Jmeter.bat
    For Mac-open terminal->Jmeter/bin->sh jmeter.sh

HTTP Script Recorder

We can record and JMeter with automatically generate a ‘test’ based upon our actions.

We perform actions on a browser and JMeter will listen to our actions and generate a test. We can directly playback for some scenarios, but we need to handle some dynamic variables and cookies in the response for a few.

So, your JMeter works like a proxy with the HTTP(S) Test Script Recorder.

http screenshots

Configure Proxy server using JMeter for Record and Playback

If you are doing performance testing of an application that uses a proxy, there could be an issue with record and playback in JMeter. To fix this issue:

WINDOWS PROXY SETTING

  1. Go to start Menu, click on Internet options
  2. Inside Internet option pop up window, click on tab “Connections”
  3. Inside connection, click on Lan Settings, Checkmark on “Use proxy server for your LAN and click on Advance
  4. In Advance enter proxy of JMeter 127.0.0.1, and port number can be 8080 or 8888, depending on what proxy you set on JMeter in Https script recorder, but both ports should be the same.
    lan screenshot 2
  5. Start JMeter, by clicking on JMeter.bat
  6. Right click on Test Plan, go to add, navigate to Non-Test Element, add HTTP test script recorder.
  7. Under Test plan creation, select target controller as Test Plan->HTTP(s) Test script recording, so all recorded requests will be saved under your test plan.
  8. Click on Start, JMeter will start listening upon your request and a recorder will be displayed on your screen.
  9. After recording click on Stop, all recording will be saved under the test plans

Script Recording Best Practices

  1. Choose an appropriate Test Plan template and add proper Config Elements.
  2. Filter out those requests loaded from Cache memory such as .jpg,.mig,.gif .js, etc. Use Exclude pattern option in Http(s) Test script recorder
  3. Add the JMeter Proxy Server Certificate for secured websites to avoid unknown_ca Error.
  4. Use naming Convention for all elements

Summary

Anyone with basic knowledge in software testing or with experience at any level will discover JMeter very easy to learn and use. One doesn't need any programming competence to understand the potential use of JMeter. JMeter has ample resources on the Web and forums that may become your guiding light towards using JMeter and its possibilities in Performance Testing. Being a highly robust, scalable, and portable application makes it a suitable testing tool for today's fast-changing and market-driven application development process.

In the latest release, there is support for Mobile applications and Integration with CI tools like Jenkins. It can be integrated well with third-party tools like DynaTrace, Applicare, Grafana. From version 3.0, JMeter supports HTML Reporting.

Share Post:

Comments

Comment Form

Related Posts

JMeter-Selenium Webdriver Integration

The combination of using JMeter and some simple scripting to invoke Selenium code allows you to measure how fast HTML pa...