How JMeter and Charles interface testing

  What is interface testing and how to carry out interface testing, I believe that any software tester will have such questions.

Here I will explain the login interface of the interface test automation platform.

1. What is interface testing?

  Interface testing is a type of testing that tests the interface between system components. Interface testing is mainly used to detect the interaction points between the external system and the system and between the various internal subsystems.

The focus of the test is to check the data exchange, transfer and control management process, as well as the mutual logical dependencies between systems. ---------> Excerpted from Baidu Encyclopedia

  In layman's terms, it is to detect the person after peeling the skin, you can intuitively see whether the heart is beating or not, instead of relying on listening or pulse to judge whether the heart is or not.

beating. Corresponding to the program, there is no need to click on the UI to guess whether the data can be adjusted or not. You can directly return to the interface to intuitively see whether the data is

No tune up.

The benefits of interface testing

  2.1. The front-end and back-end bugs are separated, and the problem can be better assigned to the corresponding developer

  2.1. Shorten the project cycle. The interface test can be tested after the corresponding interface is developed. In theory, after an interface is developed, one can be tested.

Interface, reduce the time of joint debugging, and only need to correspond to front-end developers when performing functional testing later.

3. How to carry out interface testing

  3.1. Excellent interface documentation

  3.2. Interface testing tools

The interface testing tool I use here is JMeter

  First explain what a good interface document is: a good interface document must have two characteristics, readability and executable. For the interface document, we must

In it, you can see the definition of the interface (including: input parameters, output parameters, request method, calling address, and the business relationship of the interface). If there is no interface document, the company requires us to

Do interface automation, then what should I do at this time?

  Therefore , echoing Charles  in the question , to capture the packet to analyze the interface, and then maintain it in JMeter

4. How to use JMeter

  4.1. Download jmeter compressed package, download address: https://jmeter.apache.org/download_jmeter.cgi

  4.2. Unzip, and click jmeter.bat in the directory to open jmeter, as shown in the following figure

The opened jmeter interface is:

 

  4.3, jmeter needs to rely on the java environment, we need to install jdk, here I installed jdk1.8, as for the jdk environment variable configuration, please Baidu

  4.4, Charles packet capture analysis interface

  4.4.1. Install Charles, follow the prompts to check the installation step by step

  4.4.2. Open Charles, and open the interface as shown below:

  4.4.3. Enter the project path you need in the browser and perform the operation. You will find that the request in your operation will be intercepted by Charles, as shown in the following figure:

For the intercepted data, we have four important places, such as the place circled by the red box in the figure above, the leftmost is the total request of the interface, and the three red boxes are side by side on the upper right side, which are the interface call address, interface

Input parameters, interface output parameters, if we perform functional testing on the interface, we need to keep the calling address, input parameters and output parameters consistent with the interface documentation.

     4.4.3.1. Let's analyze the overview content in the above figure first. The parts we need are shown in the following figure:

These three we need to maintain it in JMeter

    4.4.3.2. Analyze the Request part, that is, the interface request part, as shown in the following figure:

 

    4.4.3.3. Analyze Response, that is, the return part of the interface, as shown in the following figure:

So far, we have analyzed the captured data, so how to maintain it in JMeter?

4.5. Open jmeter and add a thread group to the test plan, as shown in the following figure:

Add the http header manager to the test plan as shown below:

  4.5.1. In the http header manager, add the information in the request header mentioned in the previous packet capture data, as shown in the following figure:

  4.5.2. Add an http request under the thread group, as shown in the following figure:

  4.5.3. How to write the calling address and input parameters in the interface into jmeter, as shown in the following figure:

The graffiti part is the actual username and password

Reminder: The data in this interface is used in combination with the data in the packet capture

   4.5.4. Add the view result tree to the thread group, as shown in the following figure:

  4.5.5. Execute the JMeter script and view the execution result, as shown in the following figure:

 

So far: JMeter and Charles have completed the interface test. If there is any unclear place, you can leave a message, or add QQ group 775129837 to communicate

 

 

 

 

 

  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324979479&siteId=291194637