fix(测试计划): 优化自动更新功能用例状态时发送评论的方法。如果功能用例状态未改变,则不发送评论

--bug=1024500 --user=宋天阳
【尝试跟踪】测试计划-功能用例关联2个接口用例-先执行返回误报接口用例-再执行返回成功接口-功能用例未自动生成阻塞状态评论
https://www.tapd.cn/55049933/s/1351112; --bug=1024509 --user=宋天阳
【测试跟踪】功能用例关联接口/场景用例-功能用例返回阻塞结果-再次执行接口/场景用例-功能用例会再次生成一条阻塞评论
https://www.tapd.cn/55049933/s/1351113
This commit is contained in:
song-tianyang 2023-03-16 10:31:42 +08:00 committed by 建国
parent 479d3274ee
commit eb08efb909
3 changed files with 15 additions and 12 deletions

View File

@ -72,9 +72,10 @@ public interface ExtTestPlanTestCaseMapper {
List<String> getCaseIdsByIds(@Param("ids") List<String> ids);
void updateExecResultByTestPlanCaseIdList(@Param("ids") List<String> testPlanCaseIdList, @Param("execResult") String execResult);
int updateDiffExecResultByTestPlanCaseIdList(@Param("ids") List<String> testPlanCaseIdList, @Param("execResult") String execResult);
void updateExecResultByTestCaseIdAndTestPlanId(@Param("testCaseId") String testCaseId, @Param("testPlanId") String testPlanId, @Param("execResult") String execResult);
//修改
int updateDiffExecResultByTestCaseIdAndTestPlanId(@Param("testCaseId") String testCaseId, @Param("testPlanId") String testPlanId, @Param("execResult") String execResult);
List<TestPlanTestCase> selectByAutomationCaseIdAndTestPlanId(@Param("automationCaseId") String automationCaseId, @Param("test_plan_id") String testPlanId);

View File

@ -654,17 +654,18 @@
);
</select>
<update id="updateExecResultByTestPlanCaseIdList">
<update id="updateDiffExecResultByTestPlanCaseIdList">
UPDATE test_plan_test_case SET status = #{execResult}
WHERE id IN
<foreach collection="ids" item="value" separator="," open="(" close=")">
#{value}
</foreach>
AND status != #{execResult}
</update>
<update id="updateExecResultByTestCaseIdAndTestPlanId">
<update id="updateDiffExecResultByTestCaseIdAndTestPlanId">
UPDATE test_plan_test_case SET status = #{execResult}
WHERE case_id = #{testCaseId} AND plan_id = #{testPlanId}
WHERE case_id = #{testCaseId} AND plan_id = #{testPlanId} AND status != #{execResult}
</update>
<select id="findFailureCaseInTestPlanByProjectIDAndExecuteTimeAndLimitNumber"
resultType="io.metersphere.dto.ExecutedCaseInfoResult">

View File

@ -104,17 +104,19 @@ public class TestCaseSyncStatusService {
}
}
if (MapUtils.isNotEmpty(successCaseMap)) {
extTestPlanTestCaseMapper.updateExecResultByTestPlanCaseIdList(new ArrayList<>(successCaseMap.keySet()), FunctionCaseExecResult.SUCCESS.toString());
extTestPlanTestCaseMapper.updateDiffExecResultByTestPlanCaseIdList(new ArrayList<>(successCaseMap.keySet()), FunctionCaseExecResult.SUCCESS.toString());
functionCaseExecutionInfoService.insertExecutionInfoByIdList(new ArrayList<>(successCaseMap.keySet()), FunctionCaseExecResult.SUCCESS.toString());
}
if (MapUtils.isNotEmpty(errorCaseMap)) {
extTestPlanTestCaseMapper.updateExecResultByTestPlanCaseIdList(new ArrayList<>(errorCaseMap.keySet()), FunctionCaseExecResult.ERROR.toString());
extTestPlanTestCaseMapper.updateDiffExecResultByTestPlanCaseIdList(new ArrayList<>(errorCaseMap.keySet()), FunctionCaseExecResult.ERROR.toString());
functionCaseExecutionInfoService.insertExecutionInfoByIdList(new ArrayList<>(errorCaseMap.keySet()), FunctionCaseExecResult.ERROR.toString());
}
if (MapUtils.isNotEmpty(blockingCaseMap)) {
extTestPlanTestCaseMapper.updateExecResultByTestPlanCaseIdList(new ArrayList<>(blockingCaseMap.keySet()), FunctionCaseExecResult.BLOCKING.toString());
int updateDataCount = extTestPlanTestCaseMapper.updateDiffExecResultByTestPlanCaseIdList(new ArrayList<>(blockingCaseMap.keySet()), FunctionCaseExecResult.BLOCKING.toString());
functionCaseExecutionInfoService.insertExecutionInfoByIdList(new ArrayList<>(blockingCaseMap.keySet()), FunctionCaseExecResult.BLOCKING.toString());
this.addTestCaseComment(operator, testPlanName, blockingCaseMap, FunctionCaseExecResult.BLOCKING.toString());
if (updateDataCount > 0) {
this.addTestCaseComment(operator, testPlanName, blockingCaseMap, FunctionCaseExecResult.BLOCKING.toString());
}
}
}
}
@ -148,7 +150,6 @@ public class TestCaseSyncStatusService {
String automationCaseResult = null;
if (priorityResult != null && StringUtils.isNotEmpty(priorityResult.getExecResult())) {
if (StringUtils.equalsIgnoreCase(ApiReportStatus.ERROR.name(), priorityResult.getExecResult())) {
automationCaseResult = ApiReportStatus.ERROR.name();
priorityResult.setExecResult(FunctionCaseExecResult.ERROR.toString());
} else if (StringUtils.equalsIgnoreCase(ApiReportStatus.FAKE_ERROR.name(), priorityResult.getExecResult())) {
automationCaseResult = ApiReportStatus.FAKE_ERROR.name();
@ -159,10 +160,10 @@ public class TestCaseSyncStatusService {
}
//通过 triggerCaseRunResult(触发操作的用例的执行结果) 进行判断会不会直接影响最终结果如果是在改变功能用例状态时也要增加一条评论
extTestPlanTestCaseMapper.updateExecResultByTestCaseIdAndTestPlanId(entry.getKey(), testPlanId, priorityResult.getExecResult());
int updateDataCount = extTestPlanTestCaseMapper.updateDiffExecResultByTestCaseIdAndTestPlanId(entry.getKey(), testPlanId, priorityResult.getExecResult());
//记录功能用例执行信息
functionCaseExecutionInfoService.insertExecutionInfoByCaseIdAndPlanId(entry.getKey(), testPlanId, priorityResult.getExecResult());
if (StringUtils.equalsIgnoreCase(triggerCaseRunResult, automationCaseResult) && !StringUtils.equalsIgnoreCase(triggerCaseRunResult, ApiReportStatus.SUCCESS.name())) {
if (updateDataCount > 0 && StringUtils.equalsIgnoreCase(automationCaseResult, ApiReportStatus.FAKE_ERROR.name())) {
this.addTestCaseComment(testPlan.getCreator(), testPlan.getName(), entry.getKey(), priorityResult.getCaseName(), FunctionCaseExecResult.BLOCKING.toString());
}
}