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){

}


 


 


 


posted @ 2019-12-23 19:19  M兔  阅读(279)  评论(0)    收藏  举报