fix(测试计划): #1005967 #1006056 测试计划,执行场景用例有一个用例总是不在任务中心显示 【github#5497】测试跟踪-测试计划-定时任务仅执行第一次关联的测试场景用例 (#5694)

【测试计划,执行场景用例有一个用例总是不在任务中心显示】https://www.tapd.cn/55049933/bugtrace/bugs/view?bug_id=1155049933001005967;--bug=1006056
--user=宋天阳 【github#5497】测试跟踪-测试计划-定时任务仅执行第一次关联的测试场景用例
https://www.tapd.cn/55049933/s/1040247;

Co-authored-by: song-tianyang <tianyang.song@fit2cloud.com>
This commit is contained in:
metersphere-bot 2021-08-25 22:07:31 +08:00 committed by GitHub
parent e807bb5635
commit 6015fce556
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 32 additions and 9 deletions

View File

@ -1026,13 +1026,17 @@ public class ApiAutomationService {
planEnvMap = JSON.parseObject(environment, Map.class);
}
}
String projectId = testPlanScenarioCaseService.getProjectIdById(testPlanScenarioId);
if(StringUtils.isEmpty(projectId)){
projectId = item.getProjectId();
}
if (request.isTestPlanScheduleJob()) {
String savedScenarioId = testPlanScenarioId + ":" + request.getTestPlanReportId();
report = createScenarioReport(reportId, savedScenarioId, item.getName(), request.getTriggerMode(),
request.getExecuteType(), item.getProjectId(), request.getReportUserID(), request.getConfig(),item.getId());
request.getExecuteType(), projectId, request.getReportUserID(), request.getConfig(),item.getId());
} else {
report = createScenarioReport(reportId, testPlanScenarioId, item.getName(), request.getTriggerMode(),
request.getExecuteType(), item.getProjectId(), request.getReportUserID(), request.getConfig(),item.getId());
request.getExecuteType(), projectId, request.getReportUserID(), request.getConfig(),item.getId());
}
} else {
report = createScenarioReport(reportId, ExecuteType.Marge.name().equals(request.getExecuteType()) ? serialReportId : item.getId(), item.getName(), request.getTriggerMode(),
@ -1251,13 +1255,19 @@ public class ApiAutomationService {
scenario.setEnvironmentMap(JSON.parseObject(environment, Map.class));
}
}
String projectId = testPlanScenarioCaseService.getProjectIdById(testPlanScenarioId);
if(StringUtils.isEmpty(projectId)){
projectId = item.getProjectId();
}
if (request.isTestPlanScheduleJob()) {
String savedScenarioId = testPlanScenarioId + ":" + request.getTestPlanReportId();
report = createScenarioReport(group.getName(), savedScenarioId, item.getName(), request.getTriggerMode(),
request.getExecuteType(), item.getProjectId(), request.getReportUserID(), request.getConfig(),item.getId());
request.getExecuteType(), projectId, request.getReportUserID(), request.getConfig(),item.getId());
} else {
report = createScenarioReport(group.getName(), testPlanScenarioId, item.getName(), request.getTriggerMode() == null ? ReportTriggerMode.MANUAL.name() : request.getTriggerMode(),
request.getExecuteType(), item.getProjectId(), request.getReportUserID(), request.getConfig(),item.getId());
request.getExecuteType(), projectId, request.getReportUserID(), request.getConfig(),item.getId());
}
} else {
report = createScenarioReport(group.getName(), item.getId(), item.getName(), request.getTriggerMode() == null ? ReportTriggerMode.MANUAL.name() : request.getTriggerMode(),

View File

@ -34,4 +34,6 @@ public interface ExtTestPlanScenarioCaseMapper {
List<TestPlanFailureScenarioDTO> getFailureListByIds(@Param("ids") Collection<String> ids, @Param("planId") String planId, @Param("status") String status);
List<Integer> getUnderwaySteps(@Param("ids") List<String> underwayIds);
String getProjectIdById(String testPlanScenarioId);
}

View File

@ -247,4 +247,10 @@
</foreach>
</select>
<select id="getProjectIdById" resultType="java.lang.String">
SELECT project_id FROM test_plan WHERE id in (
SELECT test_plan_id FROM test_plan_api_scenario WHERE id = #{0}
)
</select>
</mapper>

View File

@ -685,9 +685,9 @@ public class TestPlanReportService {
status = TestPlanReportStatus.SUCCESS.name();
try {
if (CollectionUtils.isNotEmpty(reportDTO.getFunctionFailureCases())
&& CollectionUtils.isNotEmpty(reportDTO.getApiFailureCases())
&& CollectionUtils.isNotEmpty(reportDTO.getScenarioFailureCases())
&& CollectionUtils.isNotEmpty(reportDTO.getLoadFailureCases())) {
|| CollectionUtils.isNotEmpty(reportDTO.getApiFailureCases())
|| CollectionUtils.isNotEmpty(reportDTO.getScenarioFailureCases())
|| CollectionUtils.isNotEmpty(reportDTO.getLoadFailureCases())) {
status = TestPlanReportStatus.FAILED.name();
return status;
}
@ -751,7 +751,7 @@ public class TestPlanReportService {
//更新TestPlan状态为完成
TestPlanWithBLOBs testPlan = testPlanMapper.selectByPrimaryKey(report.getTestPlanId());
if (testPlan != null) {
testPlan.setStatus(TestPlanStatus.Completed.name());
// testPlan.setStatus(TestPlanStatus.Completed.name());
testPlanMapper.updateByPrimaryKeySelective(testPlan);
}
if (StringUtils.equalsAny(report.getTriggerMode(), ReportTriggerMode.API.name(), ReportTriggerMode.SCHEDULE.name())) {
@ -813,7 +813,7 @@ public class TestPlanReportService {
}
NoticeModel noticeModel = NoticeModel.builder()
.operator(SessionUtils.getUserId())
.operator("MeterSphere")
.successContext(successContext)
.successMailTemplate(successfulMailTemplate)
.failedContext(failedContext)

View File

@ -468,4 +468,8 @@ public class TestPlanScenarioCaseService {
}
return null;
}
public String getProjectIdById(String testPlanScenarioId) {
return extTestPlanScenarioCaseMapper.getProjectIdById(testPlanScenarioId);
}
}

View File

@ -990,6 +990,7 @@ public class TestPlanService {
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public String run(String testPlanID, String projectID, String userId, String triggerMode, String apiRunConfig) {
triggerMode = ReportTriggerMode.SCHEDULE.name();
//创建测试报告然后返回的ID重新赋值为resourceID作为后续的参数
TestPlanScheduleReportInfoDTO reportInfoDTO = testPlanReportService.genTestPlanReportBySchedule(projectID, testPlanID, userId, triggerMode);