preface

If you have used JMeter, you will probably use a listener. In each listener, there is a “write all data to one file” function. How to use this function? Today, we will talk about the use of this function.

Almost all listeners have such a feature.

So how do you use all the functions that come with this listener?

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

As you can see from the file types popup, there are three supported file types: XML, JTL, and CSV.

Jmeter also supports.db, but this type is rarely used.

That is, we have three options for the type of file we choose to write to. CSV is the default for the current version of JMeter. In the jmeter properties file, find the jmeter. Save. Saveservice. Output_format = “the value of the parameter.

You can either select an existing file or create an empty file, but empty files are recommended because when jMeter defaults are configured,

“Resultcollector. action_if_file_exists=ASK”, if the file already exists, a pop-up message will be displayed.

Of course, you can also modify “APPEND” to automatically APPEND to the end of the file, “DELETE” to automatically DELETE the original file to create a new file.

By default, CSV files have fields (same for JTL files)

timeStamp   elapsed label   responseCode    responseMessage threadName  dataType    success failureMessage  bytes   sentBytes   grpThreads  allThreads  URL Latency IdleTime    Connect
Copy the code
field information
timeStamp Time stamp: 1634187509448
elapsed Time, in ms milliseconds
label The sampler name is HTTP Request
responseCode The response code is 200
responseMessage The response message is OK
threadName The thread name is as follows: Thread group 1-1
dataType The data type is text
success Success or failure: true
bytes Number of bytes in the sample
sentBytes The number of bytes to send the sample
grpThreads Number of active threads in this thread group
allThreads Number of active threads in all thread groups
URL The sampler requests an address
Latency Delay time
IdleTime Idle time unit: ms ms
Connect The time the connection was established

If you are careful, you can see from this diagram that request-body and Response-body are not included in this CSV. In other words, some data of the request and response is not written to the file. These data are mainly used when performing performance analysis and generating charts.

So how does that work?

If you are using the graphical interface JMeter, you can select your CSV or JTL file from any listener in JMeter by clicking browse, as if you were using the View Result Tree widget

Or use the “aggregate Report” component:

You can see the results of the run as well as the statistical analysis report.

However, because it is a CSV file or A JTL file, there are still some shortcomings. First of all, CSV files do not store data related to the request body and response results, so when using the “View Result Tree” widget to view, Request body, Request Headers, Response body, response Headers all have no data. Then, if the CSV file or JTL file is tens or hundreds of meters large, jMeter may not respond when viewed using the view Result Tree widget.

Starting with jmeter version 5.1.1, if you use a graphical interface, you can also put CSV files or JTL files to generate HTML reports.

Click the first ‘Browse’, select the CSV file or JTL file, click the second ‘Browse’, select the jmeter.properties or user.properties file in the Jmeterbin folder, click the third ‘Browse’, To generate HTML to the empty folder of your choice, select an empty folder and click the “Gererate Report” button at the bottom.

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 the name of the empty folder where you put the generated HTML.

The default CSV or JTL file does not hold the request body and response data. Is there any solution?

We can do this in the following two ways:

Select an empty XML file, and then click the “Configure” button. In the popup window, select the three checkboxes of “Save As XML”, “Save Response Data(XML)” and “Save Sampler Data(XML)”, and then click “Finish”.

In this way, the request body and response-related data are stored in an XML file.

Note:

1. To Save the request body and response data, the file must be in XML format, and you must imagine Save As XML

2, Save Sampler Data (XML) will Save the request cookie, request method, request body

Alternatively, select an empty XML file and click configure. In the popover, select Save As XML and click Finish. Then, click Function Test Mode in Test Plan.

XML files generated by these two methods both contain the request body and response data. In jMeter graphical interface, select “View result tree” and click browse to select write file to open the XML file. At this time, we can view the detailed information of the request and response.XML files generated by these two methods both contain the request body and response data. In jMeter graphical interface, select “View result tree” and click browse to select write file to open the XML file. At this time, we can view the detailed information of the request and response.Note:

XML files cannot generate HTML reports like CSV or JTL files. To generate reports, they need to be integrated with Ant.

Previously, we talked about writing data to files in the JMeter graphical interface. We can also generate CSV or JTL files by using CLI commands without graphical interface.

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

Xx.jmx is the Jmeter script, xxx.jtl or XXX.csv is the generated file, and XXXXempty_dict is the HTML file converted from the result.

The complete file

About the above knowledge is definitely need to spend more time and energy, these learning materials and learning tutorials you can click to join learning, touch fish skirt directly access, but also a lot of recorded video tutorials, the big man’s explanation is very detailed, can help you quickly understand and master.

💙 Good article recommendation

Recommended 👍 : “A test engineer of a big factory with a monthly salary of 30,000 yuan quit naked for 3 months, and the real feeling behind delivering food for a living”

Recommended 👍 : “10 minutes to learn how to automate interface building with Jmeter+ Ant + Jenkins”

Recommended 👍 : “This is not hang, 2021 Bytedance test development post is also too good to enter?