一、准备接口数据(对比字段,即json数据中须要提取的key对应的值进行对比)shell
二、配置获取EXCEL数据json
三、新建线程,并建两个http请求,分别用于请求新旧接口spa
四、提取须要对比的内容线程
五、赋值变量,用于对比请求时取值进行对比code
六、新建beanshell取样器blog
七、新建beanshell断言接口
String resultV1 = vars.get("oldResult"); String resultV2 = vars.get("newResult"); String[] v1 = resultV1.split("\\{|\\}|,"); String[] v2 = resultV2.split("\\{|\\}|,"); String result = ""; int j = 0; for (i=0; i<v1.length; i++) { if (!v1[i].equals(v2[i])){ j ++; if(result != ""){ result += "\r\n第" + j + "处不一样:\r\n" + " 旧:" + v1[i] +"\r\n"+" 新:" + v2[i] + "\r\n"; } else{ result = "\r\n第" + j + "处不一样:\r\n" + " 旧:" + v1[i] +"\r\n"+" 新:" + v2[i] + "\r\n"; } } } if(result !=""){ Failure = true; FailureMessage = result; } else{ FailureMessage = "\r两个版本返回结果相同"; }