beanShell断言 ,性能压测获取失败的请求
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import java.util.Date;
try{
String reponseDataAsString = Response.getResponseDataAsString();
JSONObject jsonObject = JSONObject.parseObject(reponseDataAsString);
String retCode= jsonObject.getString("retCode");
if (StringUtils.equals(ResponseCode,"200")){
if (!StringUtils.equals(retCode,"00000")){
Failure=true;
JSONObject failedRequest = new JSONObject();
long time = System.currentTimeMillis();
String timestamp = String.valueOf(time);
failedRequest.put("timestamp",timestamp);
failedRequest.put("labelName",SampleLabel);
failedRequest.put("requestInfo",SamplerData);
failedRequest.put("responseInfo",reponseDataAsString);
log.error("failedRequest================"+ failedRequest.toJSONString());
}
}
}
catch (Exception e){
}