Students who have used jmeter should be able to use listeners. In each listener, there will be a function of "writing all data to one file". How should this function be used? Today, let's talk about the use of this function.
Almost all listeners have such a function.
How to use the functions of this listener?
Click Browse to open the file selection window of the system
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 type:. db, but this type is rarely used.
That is, there are three types of files we choose to write. CSV is the default in the current version of JMeter. You can find the value of the "jmeter.save.saveservice.output_format =" parameter in the jmeter.properties file.
Select a path by yourself. You can select an existing file or create an empty file by yourself. However, it is recommended to use an empty file, because in jmeter default parameter configuration, "resultcollector.action_if_file_exists=ASK". If the file already exists, a pop-up prompt will pop up.
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, the fields saved in CSV file are (the same as jtl file)
timeStamp elapsed label responseCode responseMessage threadName dataType success failureMessage bytes sentBytes grpThreads allThreads URL Latency IdleTime Connect field information timeStamp Time stamp, e.g.: 1634187509448 elapsed Time, unit: ms millisecond label Name of sampler, such as: HTTP request responseCode Response code: 200 responseMessage The response message is as follows: OK threadName Thread name, such as thread group 1-1 dataType Data type, such as: text success Success or failure, such as: true failureMessage Failure message bytes Number of bytes in the sample sentBytes Number of bytes to send sample grpThreads Number of active threads in this thread group allThreads Number of active threads in all thread groups URL Sampler request address Latency Delay time IdleTime Idle time unit: ms millisecond Connect Time the connection was established Careful students should find this from this chart CSV There is no request-body and response-body In other words, some data of the request and response is not written to the file. These data are mainly used for performance analysis and chart generation. How does that work? If you use a graphical interface jmeter，You can jmeter In any listener, click "Browse" and select your CSV or jtl File, if you use the view results tree component picture Or use the aggregate report component: picture You can see the running results and statistical analysis reports. Is this usage very simple, you 'Learning is useless' Are you? But because he is CSV File or jtl Documents, there are still some deficiencies. first, CSV File does not save the data related to the request body and response results. Therefore, when viewing with the "view result tree" component, request body, request headers,response body, response headers There is no data in. And then, if CSV File or jtl There are dozens of files M Or hundreds M，When viewing using the view results tree component, it may cause jmeter No response. stay jmeter5.1.1 Version start, if you use the graphical interface, you can also put CSV File or jtl Files, generating HTML report picture Click the first "Browse" and select CSV File or jtl File, click the second "Browse" and select jmeterbin In folder jmeter.properties or user.properties File, click the third "Browse", select an empty folder, and then click the bottom“ Gererate report" Button to generate HTML To an empty folder of your choice. picture If you are using a non graphical interface jmeter，have access to jmeter -g xxxx.jtl -e -o xxxempty_dict "xxxx.jtl" It can be yours CSV Files can also be jtl Documents, "xxxempty_dict" Is that you generate HTML The name of the empty folder to be placed. default CSV or jtl The file does not save the data related to the request body and response. Is there any way to solve it? We can use the following two methods: Select an empty XML File, and then click the "configuration" button. In the pop-up window, select“ Save As XML" "Save Response Data(XML)" "Save Sampler Data(XML)" Three check boxes, and then click finish“ picture In this way, the data related to the request body and response are saved to XML File. be careful: 1,To save data related to the request body and response, the file must be XML Format must be conceived Save As XML 2,Save Sampler Data(XML)The request will be saved cookie,Request method and request body You can also select an empty XML File, and then click the "configuration" button. In the pop-up window, select“ Save As XML" ，Click finish, and then click function test mode in the test plan“ picture Generated by these two methods XML The file contains the request body and response related data jmeter In the graphical interface, select "view result tree" and click Browse to select write file to open XML File. At this time, we can view the details of the request and response. picture be careful: XML Files cannot be like CSV,jtl Generate as file HTML Report. To generate a report, it needs to work with ant integrate. Earlier, we all talked about jmeter In the graphical interface, we can also write data to files by using the method without graphical interface CLI Command to generate CSV or jtl File. jmeter -n -t xx.jmx -l xxx.jtl -e -o xxxxempty_dict xx.jmx yes jmeter script, xxx.jtl or xxx.csv Is the generated file, xxxxempty_dict Is the result converted to HTML File. Well, for jmeter Have you learned how to generate files?
Careful students, you can find from this chart that there are no request body and response body in this CSV, that is, some data of request and response are not written to the file. These data are mainly used when generating charts for performance analysis.
How does that work?
- If you are using the graphical interface jmeter, you can click "Browse" in any listener in jmeter and select your CSV or jtl file. For example, you can use the "view result tree" component
Or use the aggregate report component:
You can see the running results and statistical analysis reports.
Is this usage very simple? Did you 'learn to waste'?
However, because it is a CSV file or jtl file, it still has some shortcomings. First, the CSV file will not save the data related to the request body and response result. Therefore, the view result tree is used There is no data in request body, request headers, response body and response headers when viewing components. Then, if the CSV file or jtl file is tens of M or hundreds of m large, jmeter may not respond when viewing using the view result tree component.
Starting with JMeter version 5.1.1, if you use the graphical interface, you can also put CSV files or jtl files to generate HTML reports.
Click the first "Browse", select CSV file or jtl file, click the second "Browse", select jmeter.properties or user.properties file in jmeterbin folder, click the third "Browse", select an empty folder, and then click the "generate report" button at the bottom to generate HTML into the empty folder you select.
- If you are using jmeter without graphical interface, you can use jmeter -g xxxx.jtl -e -o xxxempty_dict "XXXX. JTL" can be your CSV file or JTL file, and "xxxempty_dict" is the name of the empty folder where you put the generated HTML.
The default CSV or jtl file does not save the request body and response related data. Is there any solution?
We can use the following two methods:
Select an empty XML file, and then click Configure. In the pop-up window, select the three check boxes 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 saved to the XML file.
1. To save the data related to the request body and response, the file must be in XML format and Save As XML must be envisaged
2. Save Sampler Data (XML) will save the requested cookie, request method and request body
You can also select an empty XML file, click Configure, select Save As XML in the pop-up window, click finish, and then click function test mode in the test plan“
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 Browse to select the write file, and open the XML file. At this time, we can view the detailed information of the request and response.
XML files cannot generate HTML reports like CSV and jtl files. To generate reports, they need to be integrated with ant.
Earlier, we talked about writing data to files in 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
xx.jmx is the jmeter script, xxx.jtl or xxx.csv is the generated file, and xx xxxxempty_dict is the HTML file converted from the result.
Well, have you learned about jmeter generation files?
Finally, a software testing learning resource is also prepared for you:
- A complete set of videos for the latest version of software testing in September 2021
- 500 sets of software test interview questions + interview explanation video
- 10 sets of ultra-high value software test papers of Collection Edition
- 300 sets of resume templates for software testing projects
- Collection of 80 sets of design templates for various soft test cases
Friends in need can pay attention to my official account: programmers two black, get directly!
The last sentence is for everyone: opportunities only favor those who are prepared. This is a society that depends on ability. Sometimes, the reason why you don't develop well is not because you don't have opportunities, but because you are not ready, which leads to opportunities passing you by. If you want to learn, it's never too late to start, rather than looking ahead and backward. You just have to try your best and leave the rest to you Time!
If you don't want to experience the feeling of giving up after a few days because you can't find materials and no one answers questions during self-study, you can join our group: 642830685, which has various software testing resources and technical discussions.
Come on, tester! The road is at your feet and success is tomorrow!
Ali p8, the new comer of the company, read the APP and interface test I did and gave me this document
Tencent two sides: web testing problems were abused and cried until the senior gave me these knowledge points
Interview didi technology, was pressed on the ground and rubbed. Who knows what I've experienced?