fix(接口测试): 修复tcp协议批量执行环境选择错误问题

--bug=1013593 --user=赵勇 【接口测试】TCP请求CASE,批量执行,没有带上环境信息 https://www.tapd.cn/55049933/s/1170150
This commit is contained in:
fit2-zhao 2022-05-31 16:19:39 +08:00 committed by f2c-ci-robot[bot]
parent cda010f76f
commit d9773faeed
2 changed files with 8 additions and 3 deletions

View File

@ -159,7 +159,9 @@ public class MsTCPSampler extends MsTestElement {
}
if (config.getConfig() == null) {
// 单独接口执行
if(StringUtils.isNotEmpty(config.getProjectId())) {
this.setProjectId(config.getProjectId());
}
config.setConfig(ElementUtil.getEnvironmentConfig(StringUtils.isNotEmpty(this.getEnvironmentId()) ? this.getEnvironmentId() : useEnvironment, this.getProjectId(), this.isMockEnvironment()));
}
EnvironmentConfig envConfig = null;

View File

@ -215,7 +215,7 @@ public class ApiScenarioSerialService {
group.setName(runRequest.getReportId());
group.setProjectId(caseWithBLOBs.getProjectId());
MsTestElement testElement = parse(data, testId, envId);
MsTestElement testElement = parse(data, testId, envId, caseWithBLOBs.getProjectId());
group.setHashTree(new LinkedList<>());
group.getHashTree().add(testElement);
testPlan.getHashTree().add(group);
@ -235,7 +235,7 @@ public class ApiScenarioSerialService {
return null;
}
private MsTestElement parse(String api, String planId, String envId) {
private MsTestElement parse(String api, String planId, String envId, String projectId) {
try {
JSONObject element = JSON.parseObject(api, Feature.DisableSpecialKeyDetect);
ElementUtil.dataFormatting(element);
@ -258,6 +258,9 @@ public class ApiScenarioSerialService {
}
if (element.getString("type").equals("TCPSampler")) {
MsTCPSampler msTCPSampler = JSON.parseObject(api, MsTCPSampler.class, Feature.DisableSpecialKeyDetect);
if (StringUtils.isEmpty(msTCPSampler.getProjectId())) {
msTCPSampler.setProjectId(projectId);
}
if (StringUtils.isNotEmpty(envId)) {
msTCPSampler.setUseEnvironment(envId);
}