fix(测试跟踪): 修复失败用例top10场景用例在不同测试计划内时没有分开统计的问题
--bug=1015301 --user=宋天阳 【测试跟踪】首页-测试计划失败用例top10,一个场景被多个测试计划关联,失败次数应该分别显示 https://www.tapd.cn/55049933/s/1210153
This commit is contained in:
parent
828b2d1e7d
commit
bfd6db75a3
|
@ -308,9 +308,6 @@ public class ApiScenarioReportService {
|
|||
testPlanApiScenario.setUpdateTime(System.currentTimeMillis());
|
||||
testPlanApiScenarioMapper.updateByPrimaryKeySelective(testPlanApiScenario);
|
||||
|
||||
//增加场景的运行记录
|
||||
scenarioExecutionInfoService.insertExecutionInfo(testPlanApiScenario.getId(), status, report.getTriggerMode());
|
||||
|
||||
// 更新场景状态
|
||||
ApiScenario scenario = apiScenarioMapper.selectByPrimaryKey(testPlanApiScenario.getApiScenarioId());
|
||||
if (scenario != null) {
|
||||
|
|
|
@ -187,7 +187,11 @@ public class TestResultService {
|
|||
} else {
|
||||
ApiScenarioWithBLOBs apiScenario = apiScenarioMapper.selectByPrimaryKey(scenarioReport.getScenarioId());
|
||||
if (apiScenario != null) {
|
||||
if (StringUtils.equalsAnyIgnoreCase(dto.getRunMode(), ApiRunMode.SCENARIO_PLAN.name(), ApiRunMode.SCHEDULE_SCENARIO_PLAN.name(), ApiRunMode.JENKINS_SCENARIO_PLAN.name())) {
|
||||
scenarioExecutionInfoService.insertExecutionInfo(dto.getTestId(), scenarioReport.getStatus(), scenarioReport.getTriggerMode());
|
||||
} else {
|
||||
scenarioExecutionInfoService.insertExecutionInfo(scenarioReport.getScenarioId(), scenarioReport.getStatus(), scenarioReport.getTriggerMode());
|
||||
}
|
||||
environment = apiScenarioReportService.getEnvironment(apiScenario);
|
||||
userName = apiAutomationService.getUser(apiScenario.getUserId());
|
||||
principal = apiAutomationService.getUser(apiScenario.getPrincipal());
|
||||
|
|
|
@ -28,8 +28,6 @@ public interface ExtApiDefinitionExecResultMapper {
|
|||
|
||||
long countByTestCaseIDInProject(String projectId);
|
||||
|
||||
List<ExecutedCaseInfoResult> findFaliureCaseInfoByProjectIDAndExecuteTimeAndLimitNumber(@Param("projectId") String projectId, @Param("startTimestamp") long startTimestamp);
|
||||
|
||||
List<ExecutedCaseInfoResult> findFaliureCaseInTestPlanByProjectIDAndExecuteTimeAndLimitNumber(@Param("projectId") String projectId, @Param("selectFunctionCase") boolean selectFunctionCase, @Param("startTimestamp") long startTimestamp);
|
||||
|
||||
String selectExecResult(String resourceId);
|
||||
|
|
|
@ -110,8 +110,8 @@
|
|||
testPlan.`name` AS testPlanName
|
||||
FROM test_plan_api_scenario testPlanScenario
|
||||
INNER JOIN test_plan testPlan ON testPlan.id = testPlanScenario.test_plan_id) apiScene
|
||||
ON apiScene.api_scenario_id = executionInfo.source_id
|
||||
INNER JOIN api_scenario scene ON scene.id = executionInfo.source_id
|
||||
ON apiScene.id = executionInfo.source_id
|
||||
INNER JOIN api_scenario scene ON scene.id = apiScene.api_scenario_id
|
||||
|
||||
WHERE scene.project_id = #{projectId}
|
||||
AND scene.`status` != 'Trash'
|
||||
|
@ -153,78 +153,6 @@
|
|||
) showTable
|
||||
ORDER BY showTable.failureTimes DESC
|
||||
</select>
|
||||
<select id="findFaliureCaseInfoByProjectIDAndExecuteTimeAndLimitNumber"
|
||||
resultType="io.metersphere.api.dto.datacount.ExecutedCaseInfoResult">
|
||||
SELECT *
|
||||
FROM (
|
||||
-- api_test_case 只查找测试计划执行的结果
|
||||
SELECT testCase.testCaseID AS testCaseID,
|
||||
testCase.id AS id,
|
||||
testCase.testCaseName AS caseName,
|
||||
testCase.testPlanName AS testPlan,
|
||||
caseErrorCountData.dataCountNumber AS failureTimes,
|
||||
'apiCase' AS caseType
|
||||
FROM (SELECT testPlanCase.id AS testPlanCaseID,
|
||||
testPlanCase.api_case_id as testCaseID,
|
||||
apiCase.id AS id,
|
||||
apiCase.`name` AS testCaseName,
|
||||
testPlan.`name` AS testPlanName,
|
||||
testPlanCase.update_time as updateTime
|
||||
FROM api_test_case apiCase
|
||||
inner join api_definition on api_definition.id = apiCase.api_definition_id
|
||||
INNER JOIN test_plan_api_case testPlanCase ON testPlanCase.api_case_id = apiCase.id
|
||||
INNER JOIN test_plan testPlan ON testPlan.id = testPlanCase.test_plan_id
|
||||
and api_definition.status != 'Trash'
|
||||
ORDER BY apiCase.create_time DESC) testCase
|
||||
INNER JOIN (SELECT resource_id AS testPlanCaseID,
|
||||
COUNT(id) AS dataCountNumber,
|
||||
start_time AS executeTime
|
||||
FROM api_definition_exec_result
|
||||
WHERE resource_id IN (SELECT t2.id
|
||||
FROM api_test_case t1
|
||||
INNER JOIN test_plan_api_case t2 ON t1.id = t2.api_case_id
|
||||
WHERE t1.project_id = #{projectId})
|
||||
and `status` = 'error'
|
||||
GROUP BY resource_id) caseErrorCountData
|
||||
ON caseErrorCountData.testPlanCaseID = testCase.testPlanCaseID
|
||||
WHERE testCase.updateTime >= #{startTimestamp}
|
||||
UNION
|
||||
SELECT ltr.test_id as testCaseID,
|
||||
ltr.id AS id,
|
||||
ltr.name as caseName,
|
||||
tplt.testPlanName AS testPlan,
|
||||
count(ltr.id) as failureTimes,
|
||||
'load' as caseType
|
||||
FROM load_test_report ltr
|
||||
join load_test on load_test.id = ltr.test_id
|
||||
JOIN (select tplc.load_case_id, group_concat(tp.`name`) AS testPlanName, tp.project_id
|
||||
from test_plan_load_case tplc
|
||||
join test_plan tp on tp.id = tplc.test_plan_id
|
||||
GROUP BY tplc.load_case_id) tplt on tplt.load_case_id = ltr.test_id
|
||||
WHERE load_test.project_id = #{projectId}
|
||||
AND ltr.STATUS = 'Error'
|
||||
and ltr.trigger_mode = 'TEST_PLAN_SCHEDULE'
|
||||
AND ltr.create_time >= #{startTimestamp}
|
||||
GROUP BY load_test.id
|
||||
UNION
|
||||
SELECT scene.id AS testCaseID,
|
||||
scene.id AS id,
|
||||
scene.`name` AS caseName,
|
||||
apiScene.testPlanName AS testPlan,
|
||||
count(report.id) AS failureTimes,
|
||||
'scenario' AS caseType
|
||||
FROM api_scenario_report report
|
||||
INNER JOIN api_scenario scene ON report.scenario_id = scene.id
|
||||
INNER JOIN(SELECT apiScene.api_scenario_id, group_concat(testPlan.`name`) AS testPlanName
|
||||
FROM test_plan_api_scenario apiScene
|
||||
INNER JOIN test_plan testPlan ON testPlan.id = apiScene.test_plan_id
|
||||
GROUP BY apiScene.api_scenario_id) apiScene ON apiScene.api_scenario_id = scene.id
|
||||
WHERE report.project_id = #{projectId}
|
||||
AND scene.`status` != 'Trash'
|
||||
AND ( report.STATUS = 'Error' OR report.STATUS = 'Fail' ) AND report.create_time >= #{startTimestamp}
|
||||
GROUP BY scene.id) showTable
|
||||
ORDER BY showTable.failureTimes DESC
|
||||
</select>
|
||||
<select id="selectExecResult" resultType="java.lang.String">
|
||||
select ader.status
|
||||
from api_definition_exec_result ader
|
||||
|
@ -482,7 +410,9 @@
|
|||
INNER JOIN api_test_case c ON r.resource_id = c.id
|
||||
AND c.`status` != 'Trash'
|
||||
WHERE
|
||||
r.status not in ('success','errorReportResult','errorReport')
|
||||
r.status not in ('success'
|
||||
, 'errorReportResult'
|
||||
, 'errorReport')
|
||||
AND r.integrated_report_id = #{reportId}
|
||||
ORDER BY
|
||||
r.create_time ASC
|
||||
|
@ -495,7 +425,9 @@
|
|||
</select>
|
||||
|
||||
<update id="updateAllStatus">
|
||||
update api_definition_exec_result set status="STOP" where status in ('Rerunning','Running','Waiting')
|
||||
update api_definition_exec_result
|
||||
set status="STOP"
|
||||
where status in ('Rerunning', 'Running', 'Waiting')
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
|
|
@ -352,11 +352,20 @@
|
|||
SELECT count(id) AS countNumber
|
||||
FROM scenario_execution_info
|
||||
WHERE create_time BETWEEN #{firstDayTimestamp} AND #{lastDayTimestamp}
|
||||
AND source_id in (
|
||||
AND (
|
||||
source_id in (
|
||||
SELECT id
|
||||
FROM api_scenario
|
||||
WHERE project_id = #{projectId}
|
||||
);
|
||||
) or
|
||||
source_id in (
|
||||
select id
|
||||
FROM test_plan_api_scenario
|
||||
WHERE api_scenario_id in (SELECT id
|
||||
FROM api_scenario
|
||||
WHERE project_id = #{projectId})
|
||||
)
|
||||
)
|
||||
</select>
|
||||
|
||||
<select id="countByProjectIdAndCreateAndByScheduleInThisWeek" resultType="java.lang.Long">
|
||||
|
@ -471,7 +480,9 @@
|
|||
</select>
|
||||
|
||||
<update id="updateAllStatus">
|
||||
update api_scenario_report set status="STOP" where status in ('Rerunning','Running','Waiting')
|
||||
update api_scenario_report
|
||||
set status="STOP"
|
||||
where status in ('Rerunning', 'Running', 'Waiting')
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue