fix(测试跟踪): 修改测试跟踪的执行逻辑,如果存在无法执行的场景不再影响其余正常数据的运行
--bug=1025736 --user=宋天阳 【测试跟踪】测试计划-功能用例关联默认无运行环境场景-执行测试计划-导致有默认环境的场景也pending https://www.tapd.cn/55049933/s/1365892
This commit is contained in:
parent
e0c8a59be7
commit
82fe23a984
|
@ -327,25 +327,27 @@ public class ApiScenarioEnvService {
|
|||
return projectEnvMap;
|
||||
}
|
||||
|
||||
//检查测试计划场景的环境,没有环境的场景从执行队列中移除
|
||||
public void checkPlanScenarioEnv(RunScenarioRequest request) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
if (request.getProcessVO() != null &&
|
||||
MapUtils.isNotEmpty(request.getProcessVO().getTestPlanScenarioMap())
|
||||
&& MapUtils.isNotEmpty(request.getProcessVO().getTestPlanScenarioMap())) {
|
||||
List<String> noEnvScenarioIds = new ArrayList<>();
|
||||
for (String key : request.getProcessVO().getTestPlanScenarioMap().keySet()) {
|
||||
try {
|
||||
TestPlanApiScenarioInfoDTO dto = request.getProcessVO().getTestPlanScenarioMap().get(key);
|
||||
ApiScenarioWithBLOBs apiScenarioWithBLOBs = request.getProcessVO().getScenarioMap().get(dto.getApiScenarioId());
|
||||
boolean haveEnv = this.verifyPlanScenarioEnv(apiScenarioWithBLOBs, dto);
|
||||
if (!haveEnv) {
|
||||
builder.append(apiScenarioWithBLOBs.getName()).append("; ");
|
||||
noEnvScenarioIds.add(key);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
MSException.throwException("场景:" + builder + "运行环境未配置,请检查!");
|
||||
LogUtil.error("解析测试计划场景环境出错!", e);
|
||||
noEnvScenarioIds.add(key);
|
||||
}
|
||||
}
|
||||
if (builder.length() > 0) {
|
||||
MSException.throwException("场景:" + builder + "运行环境未配置,请检查!");
|
||||
if (CollectionUtils.isNotEmpty(noEnvScenarioIds)) {
|
||||
noEnvScenarioIds.forEach(id -> request.getProcessVO().getTestPlanScenarioMap().remove(id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -192,7 +192,7 @@ public class MockScriptEngineUtils {
|
|||
if (StringUtils.isNotEmpty(requestMockParams.getTcpParam())) {
|
||||
String value = requestMockParams.getTcpParam();
|
||||
value = StringUtils.replace(value, "\\", "\\\\").replace("\"", "\\\"");
|
||||
preScriptBuffer.append("vars[\"bodyRaw\"]=\"").append(value).append("\";\n");
|
||||
preScriptBuffer.append("vars[\"tcpParam\"]=\"").append(value).append("\";\n");
|
||||
}
|
||||
//写入body参数
|
||||
if (requestMockParams.isPost()) {
|
||||
|
|
|
@ -47,7 +47,6 @@ import org.apache.ibatis.session.SqlSession;
|
|||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.mybatis.spring.SqlSessionUtils;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
@ -571,12 +570,6 @@ public class TestPlanReportService {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Async
|
||||
void syncFinishTestPlanExecute(String planReportId) {
|
||||
this.testPlanExecuteOver(planReportId, TestPlanReportStatus.COMPLETED.name());
|
||||
}
|
||||
|
||||
public void testPlanExecuteOver(String testPlanReportId, String finishStatus) {
|
||||
TestPlanReport testPlanReport = this.getTestPlanReport(testPlanReportId);
|
||||
if (this.isTestPlanCountOver(testPlanReport)) {
|
||||
|
|
|
@ -512,21 +512,18 @@ public class TestPlanService {
|
|||
}
|
||||
|
||||
public List<TestPlanDTOWithMetric> selectTestPlanMetricById(List<String> idList) {
|
||||
|
||||
List<TestPlanDTOWithMetric> testPlanMetricList = this.calcTestPlanRateByIdList(idList);
|
||||
|
||||
Map<String, ParamsDTO> planTestCaseCountMap = extTestPlanMapper.testPlanTestCaseCount(idList);
|
||||
Map<String, ParamsDTO> planApiCaseMap = extTestPlanMapper.testPlanApiCaseCount(idList);
|
||||
Map<String, ParamsDTO> planApiScenarioMap = extTestPlanMapper.testPlanApiScenarioCount(idList);
|
||||
Map<String, ParamsDTO> planUiScenarioMap = extTestPlanMapper.testPlanUiScenarioCount(idList);
|
||||
Map<String, ParamsDTO> planLoadCaseMap = extTestPlanMapper.testPlanLoadCaseCount(idList);
|
||||
for (TestPlanDTOWithMetric testPlanMetric : testPlanMetricList) {
|
||||
Map<String, ParamsDTO> planTestCaseCountMap = extTestPlanMapper.testPlanTestCaseCount(idList);
|
||||
Map<String, ParamsDTO> planApiCaseMap = extTestPlanMapper.testPlanApiCaseCount(idList);
|
||||
Map<String, ParamsDTO> planApiScenarioMap = extTestPlanMapper.testPlanApiScenarioCount(idList);
|
||||
Map<String, ParamsDTO> planUiScenarioMap = extTestPlanMapper.testPlanUiScenarioCount(idList);
|
||||
Map<String, ParamsDTO> planLoadCaseMap = extTestPlanMapper.testPlanLoadCaseCount(idList);
|
||||
testPlanMetric.setTestPlanTestCaseCount(planTestCaseCountMap.get(testPlanMetric.getId()) == null ? 0 : Integer.parseInt(planTestCaseCountMap.get(testPlanMetric.getId()).getValue() == null ? "0" : planTestCaseCountMap.get(testPlanMetric.getId()).getValue()));
|
||||
testPlanMetric.setTestPlanApiCaseCount(planApiCaseMap.get(testPlanMetric.getId()) == null ? 0 : Integer.parseInt(planApiCaseMap.get(testPlanMetric.getId()).getValue() == null ? "0" : planApiCaseMap.get(testPlanMetric.getId()).getValue()));
|
||||
testPlanMetric.setTestPlanApiScenarioCount(planApiScenarioMap.get(testPlanMetric.getId()) == null ? 0 : Integer.parseInt(planApiScenarioMap.get(testPlanMetric.getId()).getValue() == null ? "0" : planApiScenarioMap.get(testPlanMetric.getId()).getValue()));
|
||||
testPlanMetric.setTestPlanUiScenarioCount(planUiScenarioMap.get(testPlanMetric.getId()) == null ? 0 : Integer.parseInt(planUiScenarioMap.get(testPlanMetric.getId()).getValue() == null ? "0" : planUiScenarioMap.get(testPlanMetric.getId()).getValue()));
|
||||
testPlanMetric.setTestPlanLoadCaseCount(planLoadCaseMap.get(testPlanMetric.getId()) == null ? 0 : Integer.parseInt(planLoadCaseMap.get(testPlanMetric.getId()).getValue() == null ? "0" : planLoadCaseMap.get(testPlanMetric.getId()).getValue()));
|
||||
|
||||
List<User> followUsers = this.getPlanFollow(testPlanMetric.getId());
|
||||
testPlanMetric.setFollowUsers(followUsers);
|
||||
}
|
||||
|
@ -1015,8 +1012,16 @@ public class TestPlanService {
|
|||
Map<String, String> scenarioReportMap = this.executeScenarioCase(planReportId, testPlanId, projectId, runModeConfig, triggerMode, userId, reportInfoDTO.getPlanScenarioIdMap());
|
||||
if (MapUtils.isNotEmpty(scenarioReportMap)) {
|
||||
haveScenarioCaseExec = true;
|
||||
List<TestPlanScenarioDTO> removeDTO = new ArrayList<>();
|
||||
for (TestPlanScenarioDTO dto : scenarioCases) {
|
||||
dto.setReportId(scenarioReportMap.get(dto.getId()));
|
||||
if (scenarioReportMap.containsKey(dto.getId())) {
|
||||
dto.setReportId(scenarioReportMap.get(dto.getId()));
|
||||
} else {
|
||||
removeDTO.add(dto);
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(removeDTO)) {
|
||||
scenarioCases.removeAll(removeDTO);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -1058,10 +1063,8 @@ public class TestPlanService {
|
|||
LoggerUtil.info("开始生成测试计划报告内容 " + planReportId);
|
||||
testPlanReportService.createTestPlanReportContentReportIds(planReportId, apiTestCases, scenarioCases, uiScenarios, loadCaseReportMap);
|
||||
if (!haveApiCaseExec && !haveScenarioCaseExec && !haveLoadCaseExec && !haveUICaseExec) {
|
||||
// 如果没有执行自动化用例,结束测试计划的执行。
|
||||
// 使用异步操作的方式是为了更早的将执行信息回馈给前台。
|
||||
// 不为前台直接返回【无法执行】的报错,是考虑到测试计划内会有功能用例、issue等信息可以进行统计。
|
||||
testPlanReportService.syncFinishTestPlanExecute(planReportId);
|
||||
//如果没有执行的自动化用例,调用结束测试计划的方法。 因为方法中包含着测试计划执行队列的处理逻辑。
|
||||
testPlanReportService.testPlanExecuteOver(planReportId, TestPlanReportStatus.COMPLETED.name());
|
||||
}
|
||||
return planReportId;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue