Everyone can use the jmeter listener, but my trick can make you leave work an hour earlier!

Those who have used jmeter should use listeners. In each listener, there will be a function of "writing all data to a file". How should this function be used? Today, we will talk about the use of this function.

picture

If you want to learn automated testing, here I recommend a set of videos for you. This video can be said to be the first interface automation testing tutorial on the entire network at station B. At the same time, the number of online users has reached 1,000, and there are notes to collect and various Lu Dashen Technical Exchange: 798478386      

[Updated] The most detailed collection of practical tutorials for automated testing of Python interfaces taught by station B (the latest version of actual combat)_哔哩哔哩_bilibili [Updated] The most detailed collection of practical tutorials for automated testing of Python interfaces taught by station B (actual combat) The latest version) has a total of 200 videos, including: 1. Why should interface automation be done in interface automation, 2. The overall view of request in interface automation, 3. Interface combat in interface automation, etc. UP hosts more exciting videos, please pay attention to UP account . https://www.bilibili.com/video/BV17p4y1B77x/?spm_id_from=333.337&vd_source=488d25e59e6c5b111f7a1a1a16ecbe9a  Almost all listeners have such a function.

So how to use the functions that this listener has?

Click the "Browse" button, the system file selection window will pop up

picture

We can see from the file types in the pop-up window that there are three supported file types: XML, jtl, and CSV.

In fact, jmeter also supports one: .db, but this type is rarely used.

That said, we have three options for the type of file we choose to write. Among them, CSV is the default in the current version of jmeter. Can be found in the jmeter.properties file

The value of the "jmeter.save.saveservice.output_format=" parameter.

Choose a path by yourself, you can choose an existing file, or you can create an empty file yourself, but it is recommended to use an empty file, because, when configuring the default parameters of jmeter,

"resultcollector.action_if_file_exists=ASK", if the file already exists, a pop-up window will prompt.

picture

Of course, you can also modify it to "APPEND" to automatically append to the end of the file, and "DELETE" to automatically delete the original file and create a new file.

By default, for CSV files, the saved fields have (same for jtl files)

timeStamp   elapsed label   responseCode    responseMessage threadName  dataType    success failureMessage  bytes   sentBytes   grpThreads  allThreads  URL Latency IdleTime    Connect
field information
timeStamp Timestamp such as: 1634187509448
elapsed Time-consuming, unit: ms milliseconds
label Sampler name such as: HTTP request
responseCode Response code such as: 200
responseMessage Response message such as: OK
threadName Thread name such as: thread group 1-1
dataType Data type such as: text
success Success or not such as: true
failureMessage failure message
bytes the number of bytes in the sample
lateBytes number of bytes to send samples
grpThreads The number of active threads in this thread group
allThreads The number of active threads in all thread groups
URL Sampler request address
Latency Delay time consuming
IdleTime

Idle time unit: ms milliseconds

Connect time to establish connection

Careful students should be able to find from this chart that there is no request-body and response-body in this CSV, that is to say, some data of the request and response are not written into the file. These data are mainly used for performance analysis and chart generation.

So how to use it?

  • If you are using the graphical interface jmeter, you can click "Browse" in any listener in jmeter to select your CSV or jtl file, if you use the "View Result Tree" component

picture

Or use the "Aggregate Report" element:

picture

You can see the results of the operation and the statistical analysis report.

Is this usage very simple, have you 'learned out'?

However, because it is a CSV file or a jtl file, there are still some deficiencies. First of all, the CSV file does not save the data related to the request body and the response result. Therefore, when using the "View Result Tree" component to view, there is no data in the request body, request headers, response body, and response headers. Then, that is, if the CSV file or jtl file is tens of M or hundreds of M larger, it may cause jmeter to become unresponsive when viewed using the "View Result Tree" component.

Starting from jmeter5.1.1 version, if you use the graphical interface, you can also put CSV files or jtl files to generate HTML reports.

picture

Click the first "Browse" to select a CSV file or jtl file, click the second "Browse" to select the jmeter.properties or user.properties file in the jmeterbin folder, click the third "Browse" to select an empty file Folder, and then click the "Gererate report" button at the bottom, you can generate HTML to the empty folder you choose.

picture

  • If you are using jmeter without a graphical interface, you can use jmeter -g xxxx.jtl -e -o xxxempty_dict "xxxx.jtl" can be your CSV file or jtl file, "xxxempty_dict" is where you put the generated HTML empty folder name for . 

The default CSV or jtl file does not save the request body and response related data, so is there any way to solve it?

  • We can do this in two ways: 

  • Select an empty XML file, and then click the "Configure" button. In the pop-up window, select the three check boxes "Save As XML", "Save Response Data(XML)" and "Save Sampler Data(XML)", and then, Click "Finish"

picture

In this way, the request body and response related data are all saved in the XML file.

Notice:

1. To save the request body and response related data, the file must be in XML format, and Save As XML must be conceived

2. Save Sampler Data (XML) will save the requested cookie, request method, and request body

  • You can also select an empty XML file, then click the "Configure" button, in the pop-up window, select "Save As XML", click "Finish", and then click "Functional Test Mode" in "Test Plan"

picture

The XML files generated by these two methods contain the request body and response related data. In the jmeter graphical interface, select "View Result Tree", click to select the browse to write the file, and open the XML file. At this time, we View details of requests and responses.

picture

Notice:

XML files cannot generate HTML reports like CSV and jtl files. To generate reports, they need to be integrated with ant.

Earlier, we all talked about writing data into files in the jmeter graphical interface, and we can also generate CSV or jtl files by using CLI commands without a graphical interface.

jmeter -n -t xx.jmx -l xxx.jtl -e -o xxxxempty_dict

xx.jmx is the jmeter script, xxx.jtl or xxx.csv is the generated file, and xxxxempty_dict is the HTML file the result is converted to.

Well, for the jmeter generated file, have you learned it yet?

 

Guess you like

Origin blog.csdn.net/m0_73409141/article/details/132365142