fix(接口自动化): 列表参数问题修复
This commit is contained in:
parent
a104e94c4f
commit
57967ab6b0
|
@ -121,6 +121,14 @@ public class MsScenario extends MsTestElement {
|
||||||
variables.stream().filter(ScenarioVariable::isConstantValid).forEach(keyValue ->
|
variables.stream().filter(ScenarioVariable::isConstantValid).forEach(keyValue ->
|
||||||
arguments.addArgument(keyValue.getName(), keyValue.getValue(), "=")
|
arguments.addArgument(keyValue.getName(), keyValue.getValue(), "=")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
List<ScenarioVariable> variableList = variables.stream().filter(ScenarioVariable::isListValid).collect(Collectors.toList());
|
||||||
|
variableList.forEach(item -> {
|
||||||
|
String[] arrays = item.getValue().split(",");
|
||||||
|
for (int i = 0; i < arrays.length; i++) {
|
||||||
|
arguments.addArgument(item.getName() + "_" + (i + 1), arrays[i], "=");
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (config != null && config.getConfig() != null && config.getConfig().getCommonConfig() != null
|
if (config != null && config.getConfig() != null && config.getConfig().getCommonConfig() != null
|
||||||
&& CollectionUtils.isNotEmpty(config.getConfig().getCommonConfig().getVariables())) {
|
&& CollectionUtils.isNotEmpty(config.getConfig().getCommonConfig().getVariables())) {
|
||||||
|
|
|
@ -41,8 +41,7 @@ public class ScenarioVariable {
|
||||||
private String maxNumber;
|
private String maxNumber;
|
||||||
|
|
||||||
public boolean isConstantValid() {
|
public boolean isConstantValid() {
|
||||||
if ((StringUtils.equals(this.type, VariableTypeConstants.CONSTANT.name())
|
if (StringUtils.equals(this.type, VariableTypeConstants.CONSTANT.name()) && StringUtils.isNotEmpty(name) && StringUtils.isNotEmpty(value)) {
|
||||||
|| StringUtils.equals(this.type, VariableTypeConstants.LIST.name())) && StringUtils.isNotEmpty(name) && StringUtils.isNotEmpty(value)) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -55,6 +54,13 @@ public class ScenarioVariable {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isListValid() {
|
||||||
|
if (StringUtils.equals(this.type, VariableTypeConstants.LIST.name()) && StringUtils.isNotEmpty(name) && StringUtils.isNotEmpty(value) && value.indexOf(",") != -1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isCounterValid() {
|
public boolean isCounterValid() {
|
||||||
if (StringUtils.equals(this.type, VariableTypeConstants.COUNTER.name()) && StringUtils.isNotEmpty(name)) {
|
if (StringUtils.equals(this.type, VariableTypeConstants.COUNTER.name()) && StringUtils.isNotEmpty(name)) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
|
<div>
|
||||||
|
<ms-run :debug="true" :environment="currentEnvironmentId" :reportId="reportId" :run-data="debugData"
|
||||||
|
@runRefresh="runRefresh" ref="runTest"/>
|
||||||
<api-base-component
|
<api-base-component
|
||||||
@copy="copyRow"
|
@copy="copyRow"
|
||||||
@remove="remove"
|
@remove="remove"
|
||||||
|
@ -50,13 +52,13 @@
|
||||||
<div v-else-if="controller.loopType==='FOREACH'" draggable>
|
<div v-else-if="controller.loopType==='FOREACH'" draggable>
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<el-input :placeholder="$t('api_test.request.condition_variable')" v-model="controller.forEachController.inputVal" size="small"/>
|
<el-input placeholder="输出变量名称" v-model="controller.forEachController.returnVal" size="small"/>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1" style="margin-top: 6px">
|
<el-col :span="1" style="margin-top: 6px">
|
||||||
<span style="margin:10px 10px 10px">in</span>
|
<span style="margin:10px 10px 10px">in</span>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<el-input :placeholder="$t('api_test.request.condition_variable')" v-model="controller.forEachController.returnVal" size="small"/>
|
<el-input placeholder="输入变量前缀" v-model="controller.forEachController.inputVal" size="small"/>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="7">
|
<el-col :span="7">
|
||||||
<span class="ms-span ms-radio">{{$t('loop.interval')}}</span>
|
<span class="ms-span ms-radio">{{$t('loop.interval')}}</span>
|
||||||
|
@ -87,10 +89,9 @@
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
|
|
||||||
<ms-run :debug="true" :environment="currentEnvironmentId" :reportId="reportId" :run-data="debugData"
|
|
||||||
@runRefresh="runRefresh" ref="runTest"/>
|
|
||||||
|
|
||||||
</api-base-component>
|
</api-base-component>
|
||||||
|
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -199,8 +200,8 @@
|
||||||
this.$warning("当前循环下没有请求,不能执行")
|
this.$warning("当前循环下没有请求,不能执行")
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.controller.active = true;
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
|
|
||||||
this.debugData = {
|
this.debugData = {
|
||||||
id: this.currentScenario.id, name: this.currentScenario.name, type: "scenario",
|
id: this.currentScenario.id, name: this.currentScenario.name, type: "scenario",
|
||||||
variables: this.currentScenario.variables, referenced: 'Created', enableCookieShare: this.enableCookieShare,
|
variables: this.currentScenario.variables, referenced: 'Created', enableCookieShare: this.enableCookieShare,
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="metric-container">
|
<div class="metric-container">
|
||||||
<el-row type="flex">
|
<el-row type="flex">
|
||||||
<el-col>
|
|
||||||
<div style="font-size: 14px;color: #AAAAAA;float: left">请求名称 :</div>
|
|
||||||
<div style="font-size: 14px;color:#61C550;margin-top:2px;margin-left:10px;float: left">{{response.name}}</div>
|
|
||||||
</el-col>
|
|
||||||
<el-col>
|
<el-col>
|
||||||
<div style="font-size: 14px;color: #AAAAAA;float: left">{{$t('api_report.response_code')}} :</div>
|
<div style="font-size: 14px;color: #AAAAAA;float: left">{{$t('api_report.response_code')}} :</div>
|
||||||
<div style="font-size: 14px;color:#61C550;margin-top:2px;margin-left:10px;float: left">{{response.responseResult.responseCode ? response.responseResult.responseCode :'0'}}</div>
|
<div style="font-size: 14px;color:#61C550;margin-top:2px;margin-left:10px;float: left">{{response.responseResult.responseCode ? response.responseResult.responseCode :'0'}}</div>
|
||||||
|
|
Loading…
Reference in New Issue