The Importance of Testing and Apache JMeter
Greetings, I have not dealt with testing of the projects until recently. I made tests via JMeter in the first month of my new job.
There are certain environments where a product is installed before it is live. The first one is the test environment. The product is set up in test servers in the first step. At this point, we look for answers to this question: “Are the expected responses for user-made requests received?” Of course, we do not work with real data at this stage. If there are problems, the product is corrected on the testing machine, and it continues to test the new version. If there is no problem, the results of the test cases are checked for other environments. A new version can be installed in the real environment if everything is smooth.
In this article, I explain what JMeter is, the types of tests, and the primary test concepts.
JMeter, a project of Apache Software Foundation, was initially designed to test web applications but later developed to perform different test functions. In JMeter web applications, it is possible to test static files such as HTML, CSS, and JS, as well as dynamically generated web services based on SOAP (Simple Object Access Protocol) and REST (Representational State Transfer). JMeter helps to simulate the web requests of real users while using a web app.
Since JMeter is fully written in Java, it can run smoothly on Linux, Windows or Mac OS as long as Java Runtime Environment (JRE) or Java Development Environment (JDK) is installed.
Types of Testing
* Functional Testing
Tests the functional accuracy of the service provided. Some functional tests to be performed in a web application where the exam results are presented to the students: each student querying their own exam results, having no authorization to query other’s exam results, returning own results, returning no results for students who did not take the exam, and returning information that the student has not taken the exam.
* Load Testing
Observes how an application behaves under a specific load (delay in responses, user experience, etc.).
* Performance Testing
Tests whether the application is running within the scope of planned performance criteria. Each application should have a specific performance target. For example, the resources of a website (number of servers, server properties, network bandwidth, etc.) are planned according to the maximum number of users expected for a certain period of time (for example, 1 minute). Performance tests simulate the performance of a website in a realistic way and ensure that the system can still be stable when it reaches the maximum number of users.
* Stress Testing
Observes how the system behaves when the load is above the planned maximum capacity, and most importantly, at what point it breaks. The expected behavior is that the application stops performing partially or entirely when the load is high but becomes stable after the tests are over.
* Ramp-up Time
Let’s assume we intend to test our application with a sample of 1000 users. It is not realistic to get all 1000 of 1000 users in the system right away. Ramp-up time determines how many users the test tool includes in the system each second. When the ramp-up time is 20 seconds for 1000 users, the system adds 50 users at the end of the 1st, and 100 users at the 2nd second. At the end of 20 seconds, the system includes all users in the test.
* Think Time
Computers process very quickly, unlike people. Real users need some time between two test steps to log in using a mouse/keyboard. To simulate this user behavior in the test scenario and make the virtual user (the test user) wait between two steps, we use a timer. Defined waiting time between two test steps is called Think Time. For example, the actual user who loads the page containing an HTML form needs a certain amount of time to fill out before submitting the form.
* Loop Count
Let’s suppose we intend to add 100K users to our test within 10 minutes and run a one-minute process. Instead of setting ramp-up time as 10 minutes per 100K users, we can add 10K users in the system for 1 minute and repeat the process 10 times in total for each user. Loop Count is the total number of entries for each test user in the system.
JMeter Interface and Basic Usage
The image above is the first screen of JMeter.
We can easily add a test with Sampler. (Add->Sampler->HTTP Request)
When we add a test name, we must fill the server name or IP to which we forward our request, and the path we request from the webserver.
Once the test’s query content is added, it can check whether the tests are working correctly and make corrections to the tests as follows;