Jmeter.log日志打印断言失败时的请求和响应报文
原创
©著作权归作者所有:来自51CTO博客作者wx630ecab199b5d的原创作品,请联系作者获取转载授权,否则将追究法律责任
String responseXML = prev.getResponseDataAsString();
def rootNode = new XmlParser().parseText(responseXML);
//String RspType=rootNode.order_content.order_resp.InterBOSS.Response.RspType.text();
String RspDesc=rootNode.order_content.order_resp.InterBOSS.Response.RspDesc.text();
String RspCode=rootNode.order_content.order_resp.InterBOSS.Response.RspCode.text();
String resp_code=rootNode.order_content.resp_code.text();
String resp_desc=rootNode.order_content.resp_desc.text();
//if(RspType=='0' && RspDesc=='Success' && RspCode == '0000')
if(RspCode == '0000')
{
AssertionResult.setFailure(false);
}
else
{
AssertionResult.setFailure(true);
AssertionResult.setFailureMessage("接口响应失败,resp_code:"+ resp_code +" resp_desc:"+resp_desc + " RspCode:"+RspCode+" RspDesc:"+RspDesc);
log.info("请求报文为::"+sampler.getArguments());
log.info("响应报文为:"+responseXML);
}