fix(接口测试): 修复断言相关bug

This commit is contained in:
wxg0103 2024-03-28 21:27:18 +08:00 committed by Craftsman
parent c4bcc25c5a
commit a20b54d570
8 changed files with 11 additions and 7 deletions

View File

@ -62,7 +62,7 @@ public class VariableAssertionConverter extends AssertionConverter<MsVariableAss
} }
public boolean isValid(MsVariableAssertion.VariableAssertionItem variableAssertionItem) { public boolean isValid(MsVariableAssertion.VariableAssertionItem variableAssertionItem) {
return StringUtils.isNotBlank(variableAssertionItem.getVariableName()) && StringUtils.isNotBlank(variableAssertionItem.getExpectedValue()) return StringUtils.isNotBlank(variableAssertionItem.getVariableName())
&& StringUtils.isNotBlank(variableAssertionItem.getCondition()); && StringUtils.isNotBlank(variableAssertionItem.getCondition());
} }

View File

@ -35,6 +35,7 @@ public class JSONPathAssertionConverter extends ResponseBodyTypeAssertionConvert
String expression = msAssertion.getExpression(); String expression = msAssertion.getExpression();
String expectedValue = msAssertion.getExpectedValue(); String expectedValue = msAssertion.getExpectedValue();
assertion.setName(String.format("Response data JSONPath expect %s %s %s", expression, condition.toLowerCase().replace("_", ""), expectedValue)); assertion.setName(String.format("Response data JSONPath expect %s %s %s", expression, condition.toLowerCase().replace("_", ""), expectedValue));
assertion.setEnabled(msAssertion.getEnable());
if (BooleanUtils.isFalse(globalEnable)) { if (BooleanUtils.isFalse(globalEnable)) {
// 如果整体禁用则禁用 // 如果整体禁用则禁用
assertion.setEnabled(false); assertion.setEnabled(false);

View File

@ -35,6 +35,7 @@ public class RegexAssertionConverter extends ResponseBodyTypeAssertionConverter<
assertion.setName("Response data expect regex " + msAssertion.getExpression()); assertion.setName("Response data expect regex " + msAssertion.getExpression());
assertion.addTestString(msAssertion.getExpression()); assertion.addTestString(msAssertion.getExpression());
assertion.setTestFieldResponseData(); assertion.setTestFieldResponseData();
assertion.setEnabled(msAssertion.getEnable());
if (BooleanUtils.isFalse(globalEnable)) { if (BooleanUtils.isFalse(globalEnable)) {
// 如果整体禁用则禁用 // 如果整体禁用则禁用
assertion.setEnabled(false); assertion.setEnabled(false);

View File

@ -51,6 +51,7 @@ public class XPathAssertionConverter extends ResponseBodyTypeAssertionConverter<
assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass(XPATH_ASSERTION_GUI)); assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass(XPATH_ASSERTION_GUI));
assertion.setXPathString(msAssertion.getExpression()); assertion.setXPathString(msAssertion.getExpression());
assertion.setNegated(false); assertion.setNegated(false);
assertion.setEnabled(msAssertion.getEnable());
if (BooleanUtils.isFalse(globalEnable)) { if (BooleanUtils.isFalse(globalEnable)) {
// 如果整体禁用则禁用 // 如果整体禁用则禁用
assertion.setEnabled(false); assertion.setEnabled(false);
@ -66,6 +67,7 @@ public class XPathAssertionConverter extends ResponseBodyTypeAssertionConverter<
assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass(X_PATH_2_ASSERTION_GUI)); assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass(X_PATH_2_ASSERTION_GUI));
assertion.setXPathString(msAssertion.getExpression()); assertion.setXPathString(msAssertion.getExpression());
assertion.setNegated(false); assertion.setNegated(false);
assertion.setEnabled(msAssertion.getEnable());
if (BooleanUtils.isFalse(globalEnable)) { if (BooleanUtils.isFalse(globalEnable)) {
// 如果整体禁用则禁用 // 如果整体禁用则禁用
assertion.setEnabled(false); assertion.setEnabled(false);

View File

@ -30,7 +30,7 @@ public class MsJSONPathAssertionItem extends MsBodyAssertionItem {
private String expectedValue; private String expectedValue;
public boolean isValid() { public boolean isValid() {
return StringUtils.isNotBlank(expression) && StringUtils.isNotBlank(condition) && StringUtils.isNotBlank(expectedValue); return StringUtils.isNotBlank(expression) && StringUtils.isNotBlank(condition);
} }
} }

View File

@ -13,7 +13,7 @@
ref="extractParamsTableRef" ref="extractParamsTableRef"
v-model:params="condition.jsonPathAssertion.assertions" v-model:params="condition.jsonPathAssertion.assertions"
:disabled-except-param="props.disabled" :disabled-except-param="props.disabled"
:selectable="false" :selectable="true"
:columns="jsonPathColumns" :columns="jsonPathColumns"
:scroll="{ minWidth: '700px' }" :scroll="{ minWidth: '700px' }"
:default-param-item="jsonPathDefaultParamItem" :default-param-item="jsonPathDefaultParamItem"
@ -107,7 +107,7 @@
ref="extractParamsTableRef" ref="extractParamsTableRef"
v-model:params="condition.xpathAssertion.assertions" v-model:params="condition.xpathAssertion.assertions"
:disabled-except-param="props.disabled" :disabled-except-param="props.disabled"
:selectable="false" :selectable="true"
:columns="xPathColumns" :columns="xPathColumns"
:scroll="{ minWidth: '700px' }" :scroll="{ minWidth: '700px' }"
:default-param-item="xPathDefaultParamItem" :default-param-item="xPathDefaultParamItem"
@ -254,7 +254,7 @@
<paramsTable <paramsTable
ref="extractParamsTableRef" ref="extractParamsTableRef"
v-model:params="condition.regexAssertion.assertions" v-model:params="condition.regexAssertion.assertions"
:selectable="false" :selectable="true"
:disabled-except-param="props.disabled" :disabled-except-param="props.disabled"
:columns="xPathColumns" :columns="xPathColumns"
:scroll="{ minWidth: '700px' }" :scroll="{ minWidth: '700px' }"

View File

@ -1,7 +1,7 @@
<template> <template>
<paramsTable <paramsTable
v-model:params="condition.variableAssertionItems" v-model:params="condition.variableAssertionItems"
:selectable="false" :selectable="true"
:columns="columns" :columns="columns"
:scroll="{ minWidth: '700px' }" :scroll="{ minWidth: '700px' }"
:default-param-item="defaultParamItem" :default-param-item="defaultParamItem"

View File

@ -784,7 +784,7 @@
(paramsData.value[rowIndex].key || (paramsData.value[rowIndex].key ||
paramsData.value[rowIndex].projectId || paramsData.value[rowIndex].projectId ||
paramsData.value[rowIndex].header || paramsData.value[rowIndex].header ||
paramsData.value[rowIndex].header || paramsData.value[rowIndex].variableName ||
paramsData.value[rowIndex].expression) paramsData.value[rowIndex].expression)
) { ) {
// //