How to test import interface/export interface using JMeter

As soon as I got to work today, I was asked a question by the developer: Why is the JMeter debugging interface and the file import interface always unavailable? There is also an interface for exporting files. I don’t know where the files are imported to?

I heard that this is not what JMeter often encounters when doing interface testing, but the dictation is not clear for a while, so let's make a brief summary of this article.

JMeter test import interface

1. Fill in the import interface information

2. Set the import file name and parameters

The specific values ​​in the above file upload can be obtained through packet capture analysis, as shown in the figure:

3. Execute the import interface and check the response data: status: 200, message: Success, data: true, indicating that the data has been successfully imported through the interface.

JMeter test export interface

1. Fill in the export interface information

2. BeanShell needs to add a post-processor to receive the exported file.

import java.io.*;

// 获取请求返回的数据,通过prev方法获取上个请求的返回
byte[] result = prev.getResponseData();

// 设置文件导出存放路径及保存的文件名
String file_name = "D:/importdd.xls";

File file = new File(file_name);
FileOutputStream out = new FileOutputStream(file);
out.write(result);
out.close();

as the picture shows:

3. After executing the script, we go to the D disk to check whether the file is exported.

So far, the testing of the import interface and export interface through JMeter has been completed.

Finally: In order to give back to the die-hard fans, I have compiled a complete software testing video learning tutorial for you. If you need it, you can get it for free【保证100%免费】

Software Testing Interview Documentation

We must study to find a high-paying job. The following interview questions are the latest interview materials from first-tier Internet companies such as Ali, Tencent, and Byte, and some Byte bosses have given authoritative answers. Finish this set The interview materials believe that everyone can find a satisfactory job.

Guess you like

Origin blog.csdn.net/IT_LanTian/article/details/131516687