Introduction to the

This article is written by Xmeter for those who want to know more about performance testing and JMeter. If you are already familiar with JMeter, please take a detour. -) We will explain how to use JMeter, how to install and run JMeter, and how to start a very simple test.

Are you still hanging around JMeter’s door? Don’t hesitate to follow this article and you’ll be ready to start your JMeter journey.

JMeter is a performance testing tool under the Apache Foundation that tests the performance of applications deployed on the server side. More recently, JMeter has also been used by the community as an interface testing tool…… because of its ease of use What? What is performance testing and why is there an interface test?

Well, xmeter, for example, you opened an online store and excitedly prepared to do a big thing on Singles’ Day. You didn’t think that when a large number of users visited your online store during the event, your online store went down. What would you do? The idea is to test the system to make sure it can handle that many users before actually running the event. Of course, we don’t need to use that many real users to test the event, otherwise it will cost a lot of money. JMeter is a software that helps simulate a large number of users visiting your site.

Yeah, and it’s open source and doesn’t cost anything! The interface test, it is possible to understand here, is to verify your shop application logic there is no problem, such as when you do discount activities, when the amount of settlement do not make mistakes, or customers looking for you trouble is not?

JMeter download and install

JMeter can be downloaded from JMeter’s official website, as shown below. At the time of writing (2016/11), the latest version available is 3.0.

JMeter download

Download it and unzip it to any directory on your system. Let’s call it %JMETER_HOME%. Then run the %JMETER_HOME%\bin\jmeter.bat file. Well! ? Wait, I think I got an error.

Java is not installed. JMeter is written in Java and needs Java…… to run No, xmeter, I can already see the JMeter interface – of course, congratulations, this is because you already installed Java, so skip the next step.

Java not installed error

Install the Java

Download the installation package before installing:

www.oracle.com/java/techno…

When you open the page, click on the links shown below in sequence. At the time of writing, the latest version of Java is 8.

After entering the next page, click on the following file in order to start the download. Of course, the downloaded file should be corresponding to your system. If you are using Linux, please download the relevant Linux version.

After downloading, run the exe file and install Java as prompted. Run %JMETER_HOME%\bin\jmeter.bat again. If everything is installed correctly, the JMeter interface should appear.

Initial experience with JMeter

Now that JMeter is installed, let’s do a simple experiment. Of course, performance testing has a test objective, which is what the system is being tested. Xmeter uses baidu as an example to describe the process of constructing a simple performance test. Xmeter ensures that you can complete a test experience in less than 5 minutes.

Add a virtual user group

As shown below, right click Test Plan > Add >Threads (Users) >Thread Group. Xmeter needs to explain what “thread group” means: JMeter is implemented in Java and uses a Java Thread to simulate a user, so a Thread Group is a Group of users. In other words, a Thread Group is a Group of virtual users who simulate access to the system under test.

Creating a Thread Group

Next, Xmeter takes a look at some of the common Settings used in thread groups.

1) Number of threads: here refers to the number of virtual users. The default input is “1”, which indicates that a virtual user is simulated to access the system under test. If you want to simulate 100 users, enter 100 here.

2) Ramp-up Period (in seconds): specifies the virtual user growth Period. For example, if you are testing an attendance system, the actual user logging into the system does not have to yell 1, 2, 3 – to get up and log in together. The actual usage scenario may be 9 o ‘clock, so from 8:30, the attendance system will be continuously logged in until about 9:10, so if the user’s usage scenario is completely followed, the design of the test should enter 40 (minutes) * 60 (seconds) = 2400.

However, this ramp-up time is usually not set for real tests. Why do you wait 40 minutes to log in to a test? In general, you can estimate the maximum login frequency. For example, if the number of logins is from 8:55 to 9:00, set it to 300 seconds. If the number of threads is 100, it means that 100 users log in within 5 minutes.

3) Cycle times: set the number of tests performed by a virtual user. The default value is 1, which means that a virtual user stops running after it has done something. If “always” is selected, it means that once the test is running, it won’t stop at all unless you force it to click.

Thread group Settings

Add the page under test

The next step is to add the actual page under test, right-click “Thread Groups” > “Add” > “Sampler” > “HTTP Request”.

Adding “HTTP Request”

Next you need to set the properties of the “HTTP Request” Sampler as follows:

1) Name: Enter “Baidu”, which is the descriptive text of the tested web page

2) Server name or IP address: indicates the website name or IP address of the server under test. The remaining properties can be configured as required by the properties of the system under test and can now be null.

Sets the properties of the HTTP request

Now that the test script is ready to run, click the first step shown below: Click the Save script button; Then click the second step as shown: click the Run Test button.

Save and run tests

Wait, Xmeter, why did I run my test without any reaction? Well, the test is done. You can go to Options > Log Viewer to see the run Log. If you still can’t see the log, you can expand or collapse the log view by clicking the triangular arrow shown below. You can see the start and end times for Thread Group 1-1 in the log view, indicating that the test has run.

Test log view

Isn’t JMeter too intuitive to run? So if there’s something wrong with my test, how do I know? Don’t worry, JMeter provides “listeners” for users to observe test results.

Add a result listener

Right-click Thread Groups > Listeners > View Result Tree to view request and response information during the performance test, as shown in the following figure. After adding, save the test script and run it again.

After running the test, click “View Result tree” > “Baidu”, and click 3 in the image below. You can see some useful information during the test, such as the information about sent requests and response data. Next, try changing the number of threads in the “thread group” to 10 to simulate 10 user accesses. Don’t change it too big, otherwise baidu will seal your IP address 🙂

So far, you’ve learned to write a simple JMeter performance test case. How about that? Easy enough!

Finally: you can receive a free 216-page software test engineer interview guide by clicking on the blue font. And the corresponding video learning tutorial free to share! . It includes basic knowledge, Linux prerequisites, Shell, Principles of Internet programs, Mysql database, special topics of package capture tools, interface testing tools, advanced Python programming, Web automated testing, APP automated testing, interface automated testing, advanced continuous integration of testing, test framework development and test framework, and performance testing , safety test, etc.

If my blog is helpful to you, if you like my blog content, please “like” “comment” “favorites” one key three even oh!