fix(测试跟踪): 测试计划执行后没有更新自动化功能用例的最后一次执行状态
--bug=1027495 --user=陈建星 【测试跟踪】github#25306,功能用例在测试计划中执行完成后,执行结果未自动回写至用例列表中,需修复 https://www.tapd.cn/55049933/s/1392487
This commit is contained in:
parent
4ce718eb9e
commit
a2b31afee7
|
@ -73,9 +73,10 @@ public interface ExtTestPlanTestCaseMapper {
|
|||
List<String> getCaseIdsByIds(@Param("ids") List<String> ids);
|
||||
|
||||
int updateDiffExecResultByTestPlanCaseIdList(@Param("ids") List<String> testPlanCaseIdList, @Param("execResult") String execResult);
|
||||
|
||||
int updateTestCaseLastResultByIds(@Param("caseIds") List<String> caseIds, @Param("execResult") String execResult);
|
||||
//修改
|
||||
int updateDiffExecResultByTestCaseIdAndTestPlanId(@Param("testCaseId") String testCaseId, @Param("testPlanId") String testPlanId, @Param("execResult") String execResult);
|
||||
int updateTestCaseLastResult(@Param("testCaseId") String testCaseId, @Param("execResult") String execResult);
|
||||
|
||||
List<TestPlanTestCase> selectByAutomationCaseIdAndTestPlanId(@Param("automationCaseId") String automationCaseId, @Param("test_plan_id") String testPlanId);
|
||||
|
||||
|
|
|
@ -682,10 +682,23 @@
|
|||
AND status != #{execResult}
|
||||
</update>
|
||||
|
||||
<update id="updateTestCaseLastResultByIds">
|
||||
UPDATE test_case SET last_execute_result = #{execResult}
|
||||
WHERE id IN
|
||||
<foreach collection="caseIds" item="value" separator="," open="(" close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
AND (last_execute_result != #{execResult} or last_execute_result is null)
|
||||
</update>
|
||||
|
||||
<update id="updateDiffExecResultByTestCaseIdAndTestPlanId">
|
||||
UPDATE test_plan_test_case SET status = #{execResult}
|
||||
WHERE case_id = #{testCaseId} AND plan_id = #{testPlanId} AND status != #{execResult}
|
||||
</update>
|
||||
<update id="updateTestCaseLastResult">
|
||||
UPDATE test_case SET last_execute_result = #{execResult}
|
||||
WHERE id = #{testCaseId} AND (last_execute_result != #{execResult} or last_execute_result is null)
|
||||
</update>
|
||||
<select id="findFailureCaseInTestPlanByProjectIDAndExecuteTimeAndLimitNumber"
|
||||
resultType="io.metersphere.dto.ExecutedCaseInfoResult">
|
||||
SELECT *
|
||||
|
|
|
@ -106,14 +106,17 @@ public class TestCaseSyncStatusService {
|
|||
if (MapUtils.isNotEmpty(successCaseMap)) {
|
||||
extTestPlanTestCaseMapper.updateDiffExecResultByTestPlanCaseIdList(new ArrayList<>(successCaseMap.keySet()), FunctionCaseExecResult.SUCCESS.toString());
|
||||
functionCaseExecutionInfoService.insertExecutionInfoByIdList(new ArrayList<>(successCaseMap.keySet()), FunctionCaseExecResult.SUCCESS.toString());
|
||||
updateTestCaseLastResultByIds(successCaseMap, FunctionCaseExecResult.SUCCESS.toString());
|
||||
}
|
||||
if (MapUtils.isNotEmpty(errorCaseMap)) {
|
||||
extTestPlanTestCaseMapper.updateDiffExecResultByTestPlanCaseIdList(new ArrayList<>(errorCaseMap.keySet()), FunctionCaseExecResult.ERROR.toString());
|
||||
functionCaseExecutionInfoService.insertExecutionInfoByIdList(new ArrayList<>(errorCaseMap.keySet()), FunctionCaseExecResult.ERROR.toString());
|
||||
updateTestCaseLastResultByIds(errorCaseMap, FunctionCaseExecResult.ERROR.toString());
|
||||
}
|
||||
if (MapUtils.isNotEmpty(blockingCaseMap)) {
|
||||
int updateDataCount = extTestPlanTestCaseMapper.updateDiffExecResultByTestPlanCaseIdList(new ArrayList<>(blockingCaseMap.keySet()), FunctionCaseExecResult.BLOCKING.toString());
|
||||
functionCaseExecutionInfoService.insertExecutionInfoByIdList(new ArrayList<>(blockingCaseMap.keySet()), FunctionCaseExecResult.BLOCKING.toString());
|
||||
updateTestCaseLastResultByIds(blockingCaseMap, FunctionCaseExecResult.BLOCKING.toString());
|
||||
if (updateDataCount > 0) {
|
||||
this.addTestCaseComment(operator, testPlanName, blockingCaseMap, FunctionCaseExecResult.BLOCKING.toString());
|
||||
}
|
||||
|
@ -121,6 +124,15 @@ public class TestCaseSyncStatusService {
|
|||
}
|
||||
}
|
||||
|
||||
private void updateTestCaseLastResultByIds(Map<String, CaseExecResult> caseMap, String status) {
|
||||
try {
|
||||
List<String> caseIds = caseMap.values().stream().map(CaseExecResult::getTestCaseId).distinct().toList();
|
||||
extTestPlanTestCaseMapper.updateTestCaseLastResultByIds(caseIds, status);
|
||||
} catch (Exception e) {
|
||||
LoggerUtil.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Async
|
||||
public void updateFunctionCaseStatusByAutomationCaseId(String automationCaseId, String testPlanId, String triggerCaseRunResult) {
|
||||
|
@ -161,6 +173,8 @@ public class TestCaseSyncStatusService {
|
|||
|
||||
//通过 triggerCaseRunResult(触发操作的用例的执行结果) 进行判断,会不会直接影响最终结果。如果是,在改变功能用例状态时也要增加一条评论。
|
||||
int updateDataCount = extTestPlanTestCaseMapper.updateDiffExecResultByTestCaseIdAndTestPlanId(entry.getKey(), testPlanId, priorityResult.getExecResult());
|
||||
// 更新用例的最后一次执行结果
|
||||
extTestPlanTestCaseMapper.updateTestCaseLastResult(entry.getKey(), priorityResult.getExecResult());
|
||||
//记录功能用例执行信息
|
||||
functionCaseExecutionInfoService.insertExecutionInfoByCaseIdAndPlanId(entry.getKey(), testPlanId, priorityResult.getExecResult());
|
||||
if (updateDataCount > 0 && StringUtils.equalsIgnoreCase(automationCaseResult, ApiReportStatus.FAKE_ERROR.name())) {
|
||||
|
|
Loading…
Reference in New Issue