fix(接口自动化): 修复脚本断言推荐模版兼容性问题。

This commit is contained in:
fit2-zhao 2021-06-01 11:19:07 +08:00 committed by fit2-zhao
parent a89d22ceeb
commit d1d7cb7c72
1 changed files with 8 additions and 3 deletions

View File

@ -153,6 +153,7 @@
let operator = this.assertion.operator;
let value = this.assertion.value || "";
let desc = "${" + variable + "} " + operator + " '" + value + "'";
let msgScript = "\" + value + \" " + operator + " '" + value + "'";
let script = "value = vars.get(\"" + variable + "\");\n"
switch (this.assertion.operator) {
case "==":
@ -169,24 +170,28 @@
break;
case ">":
desc = "${" + variable + "} " + operator + " " + value;
msgScript = "\" + value + \" " + operator + " " + value;
script += "number = Integer.parseInt(value);\n" +
"result = number > " + value + ";\n";
break;
case "<":
desc = "${" + variable + "} " + operator + " " + value;
msgScript = "\" + value + \" " + operator + " " + value;
script += "number = Integer.parseInt(value);\n" +
"result = number < " + value + ";\n";
break;
case "is empty":
desc = "${" + variable + "} " + operator
desc = "${" + variable + "} " + operator;
msgScript = "\" + value + \" " + operator;
script += "result = value == void || value.length() == 0;\n";
break;
case "is not empty":
desc = "${" + variable + "} " + operator
desc = "${" + variable + "} " + operator;
msgScript = "\" + value + \" " + operator;
script += "result = value != void && value.length() > 0;\n";
break;
}
let msg = (operator != "is empty" && operator != "is not empty") ? "assertion [" + desc + "]: false;" : "value " + operator
let msg = (operator !== "is empty" && operator !== "is not empty") ? "assertion [" + msgScript + "]: false;" : "value " + operator
script += "if (!result){\n" +
"\tmsg = \"" + msg + "\";\n" +
"\tAssertionResult.setFailureMessage(msg);\n" +