fix(接口自动化): 修复场景变量问题

This commit is contained in:
fit2-zhao 2020-12-24 17:51:53 +08:00
parent ea5ff734b6
commit 997be02950
1 changed files with 8 additions and 3 deletions

View File

@ -84,7 +84,7 @@ public class MsScenario extends MsTestElement {
}
// 场景变量
if (CollectionUtils.isNotEmpty(this.getVariables())) {
tree.add(arguments());
tree.add(arguments(config));
}
if (CollectionUtils.isNotEmpty(hashTree)) {
@ -95,7 +95,7 @@ public class MsScenario extends MsTestElement {
}
private Arguments arguments() {
private Arguments arguments(ParameterConfig config) {
Arguments arguments = new Arguments();
arguments.setEnabled(true);
arguments.setName(name + "Variables");
@ -104,7 +104,12 @@ public class MsScenario extends MsTestElement {
variables.stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).forEach(keyValue ->
arguments.addArgument(keyValue.getName(), keyValue.getValue(), "=")
);
if (config != null && config.getConfig() != null && config.getConfig().getCommonConfig() != null
&& CollectionUtils.isNotEmpty(config.getConfig().getCommonConfig().getVariables())) {
config.getConfig().getCommonConfig().getVariables().stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).forEach(keyValue ->
arguments.addArgument(keyValue.getName(), keyValue.getValue(), "=")
);
}
return arguments;
}
}