fix(接口测试): 脚本断言示例没有根据语言适配
--bug=1040346 --user=陈建星 【接口测试】场景-断言-脚本断言-JavaScript断言-断言结果错误 https://www.tapd.cn/55049933/s/1519185
This commit is contained in:
parent
f05d18d5ed
commit
8aeba915c3
|
@ -608,16 +608,65 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const scriptEx = ref(`// 这里可以输入脚本注释
|
const beanShellJsr233 = ref(`// 这里可以输入脚本注释
|
||||||
value = vars.get("variable_name");
|
value = vars.get("variable_name");
|
||||||
result = "variable_name".equals(value);
|
expectedValue = "expected_value";
|
||||||
|
result = expectedValue.equals(value);
|
||||||
if (!result){
|
if (!result){
|
||||||
msg = "assertion [" + value + " == 'variable_name']: false;";
|
msg = "assertion [" + value + " == " + expectedValue + "]: false;";
|
||||||
AssertionResult.setFailureMessage(msg);
|
AssertionResult.setFailureMessage(msg);
|
||||||
AssertionResult.setFailure(true);
|
AssertionResult.setFailure(true);
|
||||||
}`);
|
}`);
|
||||||
|
|
||||||
|
const beanshell = ref(`// 这里可以输入脚本注释
|
||||||
|
value = vars.get("variable_name");
|
||||||
|
expectedValue = "expected_value";
|
||||||
|
result = expectedValue.equals(value);
|
||||||
|
if (!result){
|
||||||
|
msg = "assertion [" + value + " == " + expectedValue + "]: false;";
|
||||||
|
FailureMessage = msg;
|
||||||
|
Failure = true;
|
||||||
|
}`);
|
||||||
|
|
||||||
|
const python3 = ref(`# 这里可以输入脚本注释
|
||||||
|
value = vars.get("variable_name");
|
||||||
|
expectedValue = "expected_value";
|
||||||
|
result = expectedValue == value;
|
||||||
|
if not result :
|
||||||
|
msg = "assertion [" + value + " == " + expectedValue + "]: false;";
|
||||||
|
AssertionResult.setFailureMessage(msg);
|
||||||
|
AssertionResult.setFailure(True);`);
|
||||||
|
|
||||||
|
const javaScript = ref(`// 这里可以输入脚本注释
|
||||||
|
value = vars.get("variable_name");
|
||||||
|
expectedValue = "expected_value"
|
||||||
|
result = expectedValue === value;
|
||||||
|
if (!result){
|
||||||
|
msg = "assertion [" + value + " == " + expectedValue + "]: false;";
|
||||||
|
AssertionResult.setFailureMessage(msg);
|
||||||
|
AssertionResult.setFailure(true);
|
||||||
|
}`);
|
||||||
|
|
||||||
|
let scriptEx = beanShellJsr233;
|
||||||
|
|
||||||
const { copy, isSupported } = useClipboard({ legacy: true });
|
const { copy, isSupported } = useClipboard({ legacy: true });
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => condition.value.scriptLanguage,
|
||||||
|
(scriptLanguage) => {
|
||||||
|
if (scriptLanguage === LanguageEnum.BEANSHELL) {
|
||||||
|
scriptEx = beanshell;
|
||||||
|
} else if (scriptLanguage === LanguageEnum.PYTHON) {
|
||||||
|
scriptEx = python3;
|
||||||
|
} else if (scriptLanguage === LanguageEnum.JAVASCRIPT) {
|
||||||
|
scriptEx = javaScript;
|
||||||
|
} else {
|
||||||
|
scriptEx = beanShellJsr233;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ deep: true, immediate: true }
|
||||||
|
);
|
||||||
|
|
||||||
function copyScriptEx() {
|
function copyScriptEx() {
|
||||||
if (isSupported) {
|
if (isSupported) {
|
||||||
copy(scriptEx.value);
|
copy(scriptEx.value);
|
||||||
|
@ -1027,6 +1076,7 @@ if (!result){
|
||||||
},
|
},
|
||||||
{ deep: true, immediate: true }
|
{ deep: true, immediate: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
const hasPreAndPost = computed(() => {
|
const hasPreAndPost = computed(() => {
|
||||||
if (props.showPrePostRequest) {
|
if (props.showPrePostRequest) {
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Reference in New Issue