fix(测试跟踪): 修复选择环境组执行报错问题
--bug=1021801 --user=赵勇 【测试跟踪】测试计划使用环境组执行报错了 https://www.tapd.cn/55049933/s/1325597
This commit is contained in:
parent
50af087264
commit
27f34b3e18
|
@ -115,8 +115,7 @@ public class MsScenario extends MsTestElement {
|
||||||
scenarioTree = MsCriticalSectionController.createHashTree(tree, this.getName(), this.isEnable());
|
scenarioTree = MsCriticalSectionController.createHashTree(tree, this.getName(), this.isEnable());
|
||||||
}
|
}
|
||||||
// 启用当前场景变量优先选择
|
// 启用当前场景变量优先选择
|
||||||
if ((mixEnable == null || BooleanUtils.isTrue(mixEnable))
|
if (isMixEnable() || isAllEnable()) {
|
||||||
&& (this.variableEnable == null || BooleanUtils.isFalse(this.variableEnable))) {
|
|
||||||
config.margeVariables(this.variables, config.getTransferVariables());
|
config.margeVariables(this.variables, config.getTransferVariables());
|
||||||
}
|
}
|
||||||
// 环境变量
|
// 环境变量
|
||||||
|
@ -165,6 +164,11 @@ public class MsScenario extends MsTestElement {
|
||||||
this.setGlobProcessor(this.isEnvironmentEnable() ? newConfig : config, scenarioTree, false);
|
this.setGlobProcessor(this.isEnvironmentEnable() ? newConfig : config, scenarioTree, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isMixEnable() {
|
||||||
|
return (mixEnable == null || BooleanUtils.isTrue(mixEnable))
|
||||||
|
&& (this.variableEnable == null || BooleanUtils.isFalse(this.variableEnable));
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isAllEnable() {
|
private boolean isAllEnable() {
|
||||||
return (this.variableEnable == null || BooleanUtils.isFalse(this.variableEnable))
|
return (this.variableEnable == null || BooleanUtils.isFalse(this.variableEnable))
|
||||||
&& (this.mixEnable == null || BooleanUtils.isFalse(this.mixEnable));
|
&& (this.mixEnable == null || BooleanUtils.isFalse(this.mixEnable));
|
||||||
|
|
|
@ -12,6 +12,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -51,7 +52,9 @@ public class BaseEnvGroupProjectService {
|
||||||
|
|
||||||
public Map<String, String> getEnvMap(String groupId) {
|
public Map<String, String> getEnvMap(String groupId) {
|
||||||
List<EnvironmentGroupProjectDTO> list = baseEnvGroupProjectMapper.getList(groupId);
|
List<EnvironmentGroupProjectDTO> list = baseEnvGroupProjectMapper.getList(groupId);
|
||||||
Map<String, String> map = list.stream().collect(Collectors.toMap(EnvironmentGroupProject::getProjectId, EnvironmentGroupProject::getEnvironmentId));
|
if (!CollectionUtils.isEmpty(list)) {
|
||||||
return map;
|
return list.stream().collect(Collectors.toMap(EnvironmentGroupProject::getProjectId, EnvironmentGroupProject::getEnvironmentId));
|
||||||
|
}
|
||||||
|
return new HashMap<>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -263,11 +263,14 @@ public class TestPlanReportService {
|
||||||
List<TestPlanApiScenarioInfoDTO> scenarios) {
|
List<TestPlanApiScenarioInfoDTO> scenarios) {
|
||||||
|
|
||||||
TestPlanReportRunInfoDTO runInfoDTO = new TestPlanReportRunInfoDTO();
|
TestPlanReportRunInfoDTO runInfoDTO = new TestPlanReportRunInfoDTO();
|
||||||
final Map<String, String> runEnvMap = config.getEnvMap();
|
final Map<String, String> runEnvMap = MapUtils.isNotEmpty(config.getEnvMap()) ? config.getEnvMap() : new HashMap<>();
|
||||||
runInfoDTO.setRunMode(config.getMode());
|
runInfoDTO.setRunMode(config.getMode());
|
||||||
|
|
||||||
if (StringUtils.equals(GROUP, config.getEnvironmentType()) && StringUtils.isNotEmpty(config.getEnvironmentGroupId())) {
|
if (StringUtils.equals(GROUP, config.getEnvironmentType()) && StringUtils.isNotEmpty(config.getEnvironmentGroupId())) {
|
||||||
runEnvMap.putAll(baseEnvGroupProjectService.getEnvMap(config.getEnvironmentGroupId()));
|
Map<String, String> groupMap = baseEnvGroupProjectService.getEnvMap(config.getEnvironmentGroupId());
|
||||||
|
if (MapUtils.isNotEmpty(groupMap)) {
|
||||||
|
runEnvMap.putAll(groupMap);
|
||||||
|
}
|
||||||
runInfoDTO.setEnvGroupId(config.getEnvironmentGroupId());
|
runInfoDTO.setEnvGroupId(config.getEnvironmentGroupId());
|
||||||
}
|
}
|
||||||
// 场景环境处理
|
// 场景环境处理
|
||||||
|
|
Loading…
Reference in New Issue