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,96 +1,97 @@
|
||||||
<template>
|
<template>
|
||||||
|
<div>
|
||||||
|
<ms-run :debug="true" :environment="currentEnvironmentId" :reportId="reportId" :run-data="debugData"
|
||||||
|
@runRefresh="runRefresh" ref="runTest"/>
|
||||||
|
<api-base-component
|
||||||
|
@copy="copyRow"
|
||||||
|
@remove="remove"
|
||||||
|
:data="controller"
|
||||||
|
:draggable="true"
|
||||||
|
color="#02A7F0"
|
||||||
|
background-color="#F4F4F5"
|
||||||
|
:title="$t('api_test.automation.loop_controller')" v-loading="loading">
|
||||||
|
|
||||||
<api-base-component
|
<template v-slot:headerLeft>
|
||||||
@copy="copyRow"
|
<i class="icon el-icon-arrow-right" :class="{'is-active': controller.active}" @click="active(controller)" style="margin-right: 10px"/>
|
||||||
@remove="remove"
|
<el-radio @change="changeRadio" class="ms-radio" v-model="controller.loopType" label="LOOP_COUNT">{{$t('loop.loops_title')}}</el-radio>
|
||||||
:data="controller"
|
<el-radio @change="changeRadio" class="ms-radio" v-model="controller.loopType" label="FOREACH">{{$t('loop.foreach')}}</el-radio>
|
||||||
:draggable="true"
|
<el-radio @change="changeRadio" class="ms-radio" v-model="controller.loopType" label="WHILE">{{$t('loop.while')}}</el-radio>
|
||||||
color="#02A7F0"
|
</template>
|
||||||
background-color="#F4F4F5"
|
|
||||||
:title="$t('api_test.automation.loop_controller')" v-loading="loading">
|
|
||||||
|
|
||||||
<template v-slot:headerLeft>
|
<template v-slot:message>
|
||||||
<i class="icon el-icon-arrow-right" :class="{'is-active': controller.active}" @click="active(controller)" style="margin-right: 10px"/>
|
|
||||||
<el-radio @change="changeRadio" class="ms-radio" v-model="controller.loopType" label="LOOP_COUNT">{{$t('loop.loops_title')}}</el-radio>
|
|
||||||
<el-radio @change="changeRadio" class="ms-radio" v-model="controller.loopType" label="FOREACH">{{$t('loop.foreach')}}</el-radio>
|
|
||||||
<el-radio @change="changeRadio" class="ms-radio" v-model="controller.loopType" label="WHILE">{{$t('loop.while')}}</el-radio>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template v-slot:message>
|
|
||||||
<span v-if="requestResult && requestResult.scenarios && requestResult.scenarios.length > 0 " style="color: #8c939d;margin-right: 10px">
|
<span v-if="requestResult && requestResult.scenarios && requestResult.scenarios.length > 0 " style="color: #8c939d;margin-right: 10px">
|
||||||
循环{{requestResult.scenarios.length}}次 成功{{success}}次 失败{{error}}次
|
循环{{requestResult.scenarios.length}}次 成功{{success}}次 失败{{error}}次
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-slot:button>
|
<template v-slot:button>
|
||||||
<el-button @click="runDebug" :tip="$t('api_test.run')" icon="el-icon-video-play" style="background-color: #409EFF;color: white;" size="mini" circle/>
|
<el-button @click="runDebug" :tip="$t('api_test.run')" icon="el-icon-video-play" style="background-color: #409EFF;color: white;" size="mini" circle/>
|
||||||
</template>
|
</template>
|
||||||
<div v-if="controller.loopType==='LOOP_COUNT'" draggable>
|
<div v-if="controller.loopType==='LOOP_COUNT'" draggable>
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<span class="ms-span ms-radio">{{$t('loop.loops')}}</span>
|
<span class="ms-span ms-radio">{{$t('loop.loops')}}</span>
|
||||||
<el-input-number size="small" v-model="controller.countController.loops" :placeholder="$t('commons.millisecond')" :max="1000*10000000" :min="0"/>
|
<el-input-number size="small" v-model="controller.countController.loops" :placeholder="$t('commons.millisecond')" :max="1000*10000000" :min="0"/>
|
||||||
<span class="ms-span ms-radio">次</span>
|
<span class="ms-span ms-radio">次</span>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<span class="ms-span ms-radio">{{$t('loop.interval')}}</span>
|
<span class="ms-span ms-radio">{{$t('loop.interval')}}</span>
|
||||||
<el-input-number size="small" v-model="controller.countController.interval" :placeholder="$t('commons.millisecond')" :max="1000*10000000" :min="0" :step="1000"/>
|
<el-input-number size="small" v-model="controller.countController.interval" :placeholder="$t('commons.millisecond')" :max="1000*10000000" :min="0" :step="1000"/>
|
||||||
<span class="ms-span ms-radio">ms</span>
|
<span class="ms-span ms-radio">ms</span>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<span class="ms-span ms-radio">{{$t('loop.proceed')}}</span>
|
<span class="ms-span ms-radio">{{$t('loop.proceed')}}</span>
|
||||||
<el-tooltip class="item" effect="dark" content="默认为开启,当循环下只有一个请求时,可以开启/关闭;当循环下超过一个请求时,则只能开启。" placement="top">>
|
<el-tooltip class="item" effect="dark" content="默认为开启,当循环下只有一个请求时,可以开启/关闭;当循环下超过一个请求时,则只能开启。" placement="top">>
|
||||||
<el-switch v-model="controller.countController.proceed" @change="switchChange"/>
|
<el-switch v-model="controller.countController.proceed" @change="switchChange"/>
|
||||||
|
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<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>
|
||||||
<el-input-number size="small" v-model="controller.forEachController.interval" :placeholder="$t('commons.millisecond')" :max="1000*10000000" :min="0" :step="1000"/>
|
<el-input-number size="small" v-model="controller.forEachController.interval" :placeholder="$t('commons.millisecond')" :max="1000*10000000" :min="0" :step="1000"/>
|
||||||
<span class="ms-span ms-radio">ms</span>
|
<span class="ms-span ms-radio">ms</span>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
</div>
|
</div>
|
||||||
<div v-else draggable>
|
<div v-else draggable>
|
||||||
<el-input size="small" v-model="controller.whileController.variable" style="width: 20%" :placeholder="$t('api_test.request.condition_variable')"/>
|
<el-input size="small" v-model="controller.whileController.variable" style="width: 20%" :placeholder="$t('api_test.request.condition_variable')"/>
|
||||||
|
|
||||||
<el-select v-model="controller.whileController.operator" :placeholder="$t('commons.please_select')" size="small"
|
<el-select v-model="controller.whileController.operator" :placeholder="$t('commons.please_select')" size="small"
|
||||||
@change="change" style="width: 10%;margin-left: 10px">
|
@change="change" style="width: 10%;margin-left: 10px">
|
||||||
<el-option v-for="o in operators" :key="o.value" :label="$t(o.label)" :value="o.value"/>
|
<el-option v-for="o in operators" :key="o.value" :label="$t(o.label)" :value="o.value"/>
|
||||||
</el-select>
|
</el-select>
|
||||||
<el-input size="small" v-model="controller.whileController.value" :placeholder="$t('api_test.value')" v-if="!hasEmptyOperator" style="width: 20%;margin-left: 20px"/>
|
<el-input size="small" v-model="controller.whileController.value" :placeholder="$t('api_test.value')" v-if="!hasEmptyOperator" style="width: 20%;margin-left: 20px"/>
|
||||||
<span class="ms-span ms-radio">{{$t('loop.timeout')}}</span>
|
<span class="ms-span ms-radio">{{$t('loop.timeout')}}</span>
|
||||||
<el-input-number size="small" v-model="controller.whileController.timeout" :placeholder="$t('commons.millisecond')" :max="1000*10000000" :min="1" :step="1000"/>
|
<el-input-number size="small" v-model="controller.whileController.timeout" :placeholder="$t('commons.millisecond')" :max="1000*10000000" :min="1" :step="1000"/>
|
||||||
<span class="ms-span ms-radio">ms</span>
|
<span class="ms-span ms-radio">ms</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p class="tip">{{$t('api_test.definition.request.res_param')}} </p>
|
<p class="tip">{{$t('api_test.definition.request.res_param')}} </p>
|
||||||
<el-tabs v-model="activeName">
|
<el-tabs v-model="activeName">
|
||||||
<el-tab-pane :label="item.name" :name="item.name" v-for="(item,index) in requestResult.scenarios" :key="index">
|
<el-tab-pane :label="item.name" :name="item.name" v-for="(item,index) in requestResult.scenarios" :key="index">
|
||||||
<div v-for="(result,i) in item.requestResults" :key="i" style="margin-bottom: 5px">
|
<div v-for="(result,i) in item.requestResults" :key="i" style="margin-bottom: 5px">
|
||||||
<api-response-component :result="result"/>
|
<api-response-component :result="result"/>
|
||||||
</div>
|
</div>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
|
|
||||||
<ms-run :debug="true" :environment="currentEnvironmentId" :reportId="reportId" :run-data="debugData"
|
</api-base-component>
|
||||||
@runRefresh="runRefresh" ref="runTest"/>
|
|
||||||
|
|
||||||
</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