Follow the wechat official account: CodingTechWork, learn and progress together.

The introduction

After the programmer develops the code, we need to test ourselves first. For restful code, we often need to call the interface API to test, usually we call the interface request directly from the browser or use the toolPostmanTesting of service interface apis, but none of these can do some concurrent or edge testing.

For some circular call requests, we can use the Runner in the Postman mold to test. However, in real development, there will inevitably be a lot of multi-threaded operations, and concurrency is a performance and stress test. At this point, we need to use other tools to assist our developers or testers in service testing. This article introduces the use of a JMeter tool.

JMeter

JMeter is introduced

The Apache JMeter application is a 100% Pure Java application with open source software for load testing functionality and measuring performance, originally designed to test Web applications and then expanded to other features. JMeter can be used to test static and dynamic resources and web dynamic applications. It can also be used to simulate heavy load testing of servers, server groups, networks, or objects, to test strength under different load types or to analyze overall performance.

JMeter function

JMeter can load and performance test many different application/server/protocol types

  • Web-http, HTTPS (Java, NodeJS, PHP, ASP.NET,…)
  • SOAP / REST Webservices
  • FTP
  • Database via JDBC
  • LDAP
  • Message-oriented middleware (MOM) via JMS
  • Mail – SMTP(S), POP3(S) and IMAP(S)
  • Native commands or shell scripts
  • TCP
  • Java Objects

JMeter download and install

JMeter download

Through the websiteJmeter.apache.org/ enter ‘Downloa…Releases’ download the latest version of JMeter.

JMeter install

You need to install the JDK environment on the local PC and configure the environment variable JAVA_HOME. (1) Decompress the package to the local directory(2) Environment variable configuration

A) increaseJMETER_HOME System variable, the value is the JMeter decompression path.B) inPath system variableAppend environment variables to:%JMETER_HOME%\bin

Use JMeter

Open the interface

Go to the JMeter installation directory and enterbinIn the directoryOpen thejmeter.shorjmeter.batStart jmeter. Pay attention to:

When opened, there are two Windows, the command window of JMeter and the image operation interface of JMeter. You cannot close the command window. If you close the command window, the interface will be closed.

Operation process

  1. Order plan

2. Add a thread group3. Configure a thread group4. Add an HTTP request5. Enter the request information6. Add listeners7. Start

  1. Viewing Listening Results

There are many listeners, and we can look at the result display of a common HTTP request: listener – view the result tree.9. Disable concurrent requests from multiple thread pools. If you only need to test concurrent requests from one thread group, you can disable concurrent requests from other thread groups.

conclusion

At this point, we have simply learned how to use the JMeter tool to test concurrent requests. If you use advanced features such as assertions, logic control, etc., you can learn more about the power of this tool.

See the JMeter website