Jmeter stress test, non-gui adds monitoring and output logs, Beanshell obtains response data

Due to the use of intranet pressure testing, a liunx server was opened
to output logs and result reports, and many methods were thought of, but because the gui mode occupies about 10% to 20% of resources, which affects the test results, non-GUI is used

1. Obtain the log output of the response assertion to a file

Go directly to the code:

import org.json.*;   //导入org.json包
String Response = prev.getResponseDataAsString();    //获取响应数据Response
log.info("响应体数据:" + Response);
JSONObject responseJson = new JSONObject(Response);  //整个Response作为JSON对象
success = responseJson.get("success");        //通过对象的get("字段")方法获取字段内容
log.info("响应code字段:" + success);
amount= responseJson.get("message");
log.info("响应message字段:" + amount.toString());

2. Start the jmeter command mode
, connect to the server → enter the jmetet/bin directory to run

./jmeter.sh -n -t <.jvm file> -l <.jtl file> -j <log log>
jvm file: jmeter local debugging is completed, you need to upload the jvm script to the server, here is the path of the
file.jtl File: The aggregated report output by jmeter in non-gui mode, here is the custom path and name.
Log log: output the log of the test process, path customization
can also write a shell for the convenience of testing, put the command in, and then each time Just run the sh file:insert image description here

insert image description here

Guess you like

Origin blog.csdn.net/qq_34004131/article/details/131131187