@Test
public void TestapiVar() {
List<ApiCaseBean> list = apiCaseService.CheckMustVar(1);
System.out.println(list);
System.out.println(list.size());
int max = 0;
String body = null;
for (int i = 0; i < list.size(); i++) {
String var = list.get(i).getVal();
var = "请求中未传入" + var + "验证返回" + var + "~~更多断言";
System.out.println(var);
StringBuffer sb = new StringBuffer();
body = "{ \n";
for (int j = 0; j < list.size(); j++) {
if (list.get(i).getVal() != list.get(j).getVal()) {
Random random = new Random();
max = list.get(j).getInputLenght();
sb = new StringBuffer("");
for (int k = 0; k < max; k++) {
sb.append(ALLCHAR.charAt(random.nextInt(ALLCHAR.length())));
}
body = body + "\"" + list.get(j).getVal() + "\",\"" + sb + "\"; \n";
}
}
body = body + "\n }";
System.out.println(body);
}
}

原文:https://www.cnblogs.com/qianjinyan/p/10478639.html