feat(接口测试): 计数器支持变量参数
--story=1010670 --user=赵勇 【接口测试】场景变量-计数器支持参数化(环境&接口测试) https://www.tapd.cn/55049933/s/1309282
This commit is contained in:
parent
470945e9d7
commit
a15b425206
|
@ -189,7 +189,7 @@ public class ElementUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addCounter(HashTree tree, List<ScenarioVariable> variables, boolean isInternal) {
|
public static void addCounter(HashTree tree, List<ScenarioVariable> variables) {
|
||||||
if (CollectionUtils.isNotEmpty(variables)) {
|
if (CollectionUtils.isNotEmpty(variables)) {
|
||||||
List<ScenarioVariable> list = variables.stream().filter(ScenarioVariable::isCounterValid).filter(ScenarioVariable::isEnable).collect(Collectors.toList());
|
List<ScenarioVariable> list = variables.stream().filter(ScenarioVariable::isCounterValid).filter(ScenarioVariable::isEnable).collect(Collectors.toList());
|
||||||
if (CollectionUtils.isNotEmpty(list)) {
|
if (CollectionUtils.isNotEmpty(list)) {
|
||||||
|
@ -199,11 +199,7 @@ public class ElementUtil {
|
||||||
counterConfig.setProperty(TestElement.TEST_CLASS, CounterConfig.class.getName());
|
counterConfig.setProperty(TestElement.TEST_CLASS, CounterConfig.class.getName());
|
||||||
counterConfig.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("CounterConfigGui"));
|
counterConfig.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("CounterConfigGui"));
|
||||||
counterConfig.setName(item.getName());
|
counterConfig.setName(item.getName());
|
||||||
if (isInternal) {
|
counterConfig.setStart(item.getStartNumber());
|
||||||
counterConfig.setStart((item.getStartNumber() + 1));
|
|
||||||
} else {
|
|
||||||
counterConfig.setStart(item.getStartNumber());
|
|
||||||
}
|
|
||||||
counterConfig.setEnd(item.getEndNumber());
|
counterConfig.setEnd(item.getEndNumber());
|
||||||
counterConfig.setVarName(item.getName());
|
counterConfig.setVarName(item.getName());
|
||||||
counterConfig.setIncrement(item.getIncrement());
|
counterConfig.setIncrement(item.getIncrement());
|
||||||
|
@ -814,7 +810,7 @@ public class ElementUtil {
|
||||||
config.getConfig().get(projectId).getCommonConfig().getVariables(),
|
config.getConfig().get(projectId).getCommonConfig().getVariables(),
|
||||||
config, "shareMode.group");
|
config, "shareMode.group");
|
||||||
ElementUtil.addCounter(httpSamplerTree,
|
ElementUtil.addCounter(httpSamplerTree,
|
||||||
config.getConfig().get(projectId).getCommonConfig().getVariables(), false);
|
config.getConfig().get(projectId).getCommonConfig().getVariables());
|
||||||
ElementUtil.addRandom(httpSamplerTree,
|
ElementUtil.addRandom(httpSamplerTree,
|
||||||
config.getConfig().get(projectId).getCommonConfig().getVariables());
|
config.getConfig().get(projectId).getCommonConfig().getVariables());
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,7 @@ public class MsScenario extends MsTestElement {
|
||||||
}
|
}
|
||||||
if (this.variableEnable == null || this.variableEnable) {
|
if (this.variableEnable == null || this.variableEnable) {
|
||||||
ElementUtil.addCsvDataSet(scenarioTree, variables, this.isEnvironmentEnable() ? newConfig : config, "shareMode.group");
|
ElementUtil.addCsvDataSet(scenarioTree, variables, this.isEnvironmentEnable() ? newConfig : config, "shareMode.group");
|
||||||
ElementUtil.addCounter(scenarioTree, variables, false);
|
ElementUtil.addCounter(scenarioTree, variables);
|
||||||
ElementUtil.addRandom(scenarioTree, variables);
|
ElementUtil.addRandom(scenarioTree, variables);
|
||||||
if (CollectionUtils.isNotEmpty(this.headers)) {
|
if (CollectionUtils.isNotEmpty(this.headers)) {
|
||||||
if (this.isEnvironmentEnable()) {
|
if (this.isEnvironmentEnable()) {
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class MsLoopController extends MsTestElement {
|
||||||
// 自身场景
|
// 自身场景
|
||||||
if (CollectionUtils.isNotEmpty(config.getVariables())) {
|
if (CollectionUtils.isNotEmpty(config.getVariables())) {
|
||||||
ElementUtil.addCsvDataSet(groupTree, config.getVariables(), config, "shareMode.thread");
|
ElementUtil.addCsvDataSet(groupTree, config.getVariables(), config, "shareMode.thread");
|
||||||
ElementUtil.addCounter(groupTree, config.getVariables(), true);
|
ElementUtil.addCounter(groupTree, config.getVariables());
|
||||||
ElementUtil.addRandom(groupTree, config.getVariables());
|
ElementUtil.addRandom(groupTree, config.getVariables());
|
||||||
}
|
}
|
||||||
// 当前引用场景
|
// 当前引用场景
|
||||||
|
@ -73,7 +73,7 @@ public class MsLoopController extends MsTestElement {
|
||||||
|
|
||||||
if (CollectionUtils.isNotEmpty(variables)) {
|
if (CollectionUtils.isNotEmpty(variables)) {
|
||||||
ElementUtil.addCsvDataSet(groupTree, variables, config, "shareMode.thread");
|
ElementUtil.addCsvDataSet(groupTree, variables, config, "shareMode.thread");
|
||||||
ElementUtil.addCounter(groupTree, variables, true);
|
ElementUtil.addCounter(groupTree, variables);
|
||||||
ElementUtil.addRandom(groupTree, variables);
|
ElementUtil.addRandom(groupTree, variables);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,9 +32,9 @@ public class ScenarioVariable {
|
||||||
/**
|
/**
|
||||||
* counter
|
* counter
|
||||||
*/
|
*/
|
||||||
private int startNumber;
|
private String startNumber;
|
||||||
private int endNumber;
|
private String endNumber;
|
||||||
private int increment;
|
private String increment;
|
||||||
/**
|
/**
|
||||||
* random
|
* random
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -16,34 +16,13 @@
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item :label="$t('variables.start')" prop="startNumber">
|
<el-form-item :label="$t('variables.start')" prop="startNumber">
|
||||||
<el-input-number
|
<el-input :disabled="disabled" size="small" v-model="editData.startNumber" placeholder="0" style="width: 100%" />
|
||||||
:disabled="disabled"
|
|
||||||
size="small"
|
|
||||||
v-model="editData.startNumber"
|
|
||||||
placeholder="0"
|
|
||||||
style="width: 100%"
|
|
||||||
:max="1000 * 10000000"
|
|
||||||
:min="0" />
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="$t('variables.end')" prop="endNumber">
|
<el-form-item :label="$t('variables.end')" prop="endNumber">
|
||||||
<el-input-number
|
<el-input :disabled="disabled" size="small" v-model="editData.endNumber" placeholder="10" style="width: 100%" />
|
||||||
:disabled="disabled"
|
|
||||||
size="small"
|
|
||||||
v-model="editData.endNumber"
|
|
||||||
placeholder="10"
|
|
||||||
style="width: 100%"
|
|
||||||
:max="1000 * 10000000"
|
|
||||||
:min="0" />
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="$t('variables.increment')" prop="increment">
|
<el-form-item :label="$t('variables.increment')" prop="increment">
|
||||||
<el-input-number
|
<el-input :disabled="disabled" size="small" v-model="editData.increment" placeholder="1" style="width: 100%" />
|
||||||
:disabled="disabled"
|
|
||||||
size="small"
|
|
||||||
v-model="editData.increment"
|
|
||||||
placeholder="1"
|
|
||||||
style="width: 100%"
|
|
||||||
:max="1000 * 10000000"
|
|
||||||
:min="0" />
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="$t('variables.format')" prop="value">
|
<el-form-item :label="$t('variables.format')" prop="value">
|
||||||
<el-input :disabled="disabled" v-model="editData.value" :placeholder="$t('variables.counter_info')"></el-input>
|
<el-input :disabled="disabled" v-model="editData.value" :placeholder="$t('variables.counter_info')"></el-input>
|
||||||
|
|
|
@ -1,28 +1,64 @@
|
||||||
<template>
|
<template>
|
||||||
<el-form :model="editData" label-position="right" label-width="80px" size="small" ref="form2" :rules="rules">
|
<el-form
|
||||||
|
:model="editData"
|
||||||
|
label-position="right"
|
||||||
|
label-width="80px"
|
||||||
|
size="small"
|
||||||
|
ref="form2"
|
||||||
|
:rules="rules"
|
||||||
|
>
|
||||||
<el-form-item :label="$t('api_test.variable_name')" prop="name">
|
<el-form-item :label="$t('api_test.variable_name')" prop="name">
|
||||||
<el-input v-model="editData.name" :placeholder="$t('api_test.variable_name')"></el-input>
|
<el-input
|
||||||
|
v-model="editData.name"
|
||||||
|
:placeholder="$t('api_test.variable_name')"
|
||||||
|
></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item :label="$t('commons.description')" prop="description">
|
<el-form-item :label="$t('commons.description')" prop="description">
|
||||||
<el-input class="ms-http-textarea"
|
<el-input
|
||||||
v-model="editData.description"
|
class="ms-http-textarea"
|
||||||
type="textarea"
|
v-model="editData.description"
|
||||||
:autosize="{ minRows: 2, maxRows: 10}"
|
type="textarea"
|
||||||
:rows="2" size="small" :disabled="disabled"/>
|
:autosize="{ minRows: 2, maxRows: 10 }"
|
||||||
|
:rows="2"
|
||||||
|
size="small"
|
||||||
|
:disabled="disabled"
|
||||||
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item :label="$t('variables.start')" prop="startNumber">
|
<el-form-item :label="$t('variables.start')" prop="startNumber">
|
||||||
<el-input-number :disabled="disabled" size="small" v-model="editData.startNumber" placeholder="0" style="width: 100%" :max="1000*10000000" :min="0"/>
|
<el-input
|
||||||
|
:disabled="disabled"
|
||||||
|
size="small"
|
||||||
|
v-model="editData.startNumber"
|
||||||
|
placeholder="0"
|
||||||
|
style="width: 100%"
|
||||||
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="$t('variables.end')" prop="endNumber">
|
<el-form-item :label="$t('variables.end')" prop="endNumber">
|
||||||
<el-input-number :disabled="disabled" size="small" v-model="editData.endNumber" placeholder="10" style="width: 100%" :max="1000*10000000" :min="0"/>
|
<el-input
|
||||||
|
:disabled="disabled"
|
||||||
|
size="small"
|
||||||
|
v-model="editData.endNumber"
|
||||||
|
placeholder="10"
|
||||||
|
style="width: 100%"
|
||||||
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="$t('variables.increment')" prop="increment">
|
<el-form-item :label="$t('variables.increment')" prop="increment">
|
||||||
<el-input-number :disabled="disabled" size="small" v-model="editData.increment" placeholder="1" style="width: 100%" :max="1000*10000000" :min="0"/>
|
<el-input
|
||||||
|
:disabled="disabled"
|
||||||
|
size="small"
|
||||||
|
v-model="editData.increment"
|
||||||
|
placeholder="1"
|
||||||
|
style="width: 100%"
|
||||||
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="$t('variables.format')" prop="value">
|
<el-form-item :label="$t('variables.format')" prop="value">
|
||||||
<el-input :disabled="disabled" v-model="editData.value" :placeholder="$t('variables.counter_info')"></el-input>
|
<el-input
|
||||||
|
:disabled="disabled"
|
||||||
|
v-model="editData.value"
|
||||||
|
:placeholder="$t('variables.counter_info')"
|
||||||
|
></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</template>
|
</template>
|
||||||
|
@ -37,20 +73,22 @@ export default {
|
||||||
computed: {
|
computed: {
|
||||||
disabled() {
|
disabled() {
|
||||||
return !(this.editData.name && this.editData.name !== "");
|
return !(this.editData.name && this.editData.name !== "");
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
rules: {
|
rules: {
|
||||||
name: [
|
name: [
|
||||||
{required: true, message: this.$t('test_track.case.input_name'), trigger: 'blur'},
|
{
|
||||||
|
required: true,
|
||||||
|
message: this.$t("test_track.case.input_name"),
|
||||||
|
trigger: "blur",
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
}
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped></style>
|
||||||
|
|
||||||
</style>
|
|
||||||
|
|
|
@ -32,9 +32,9 @@ public class ScenarioVariable {
|
||||||
/**
|
/**
|
||||||
* counter
|
* counter
|
||||||
*/
|
*/
|
||||||
private int startNumber;
|
private String startNumber;
|
||||||
private int endNumber;
|
private String endNumber;
|
||||||
private int increment;
|
private String increment;
|
||||||
/**
|
/**
|
||||||
* random
|
* random
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue