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