Jmeter_BeanShell Assertion自定义断言
添加组件路径
写入代码如下
String response = new String(ResponseData); log.info("==========================================================="); log.info(response); // 断言请求状态是否为200 if(!ResponseCode.equals("200")){ Failure = true; FailureMessage="接口请求失败,*********返回码:" + ResponseCode + "\n"; return; } // 断言响应内容是否包含预期值("code":"Success" ) String response = new String(ResponseData); Failure = !(response.contains("\"code\":\"Success\"")); if (Failure) { Failure = true; FailureMessage="接口响应未发现 \"code\":\"Success\" " + "*********当前响应为:" + response + "\n"; }