fix(接口测试): 修复接口测试覆盖率跳转数据计算错误的问题
This commit is contained in:
parent
270af8ace5
commit
aa6c9da438
|
@ -11,7 +11,6 @@ import io.metersphere.api.dto.request.ApiEditPosRequest;
|
||||||
import io.metersphere.api.dto.request.ApiTransferRequest;
|
import io.metersphere.api.dto.request.ApiTransferRequest;
|
||||||
import io.metersphere.api.dto.request.ImportRequest;
|
import io.metersphere.api.dto.request.ImportRequest;
|
||||||
import io.metersphere.api.dto.scenario.ApiFileCopyRequest;
|
import io.metersphere.api.dto.scenario.ApiFileCopyRequest;
|
||||||
import io.metersphere.api.dto.scenario.ApiScenarioStepFileCopyRequest;
|
|
||||||
import io.metersphere.api.dto.schema.JsonSchemaItem;
|
import io.metersphere.api.dto.schema.JsonSchemaItem;
|
||||||
import io.metersphere.api.mapper.ExtApiDefinitionMapper;
|
import io.metersphere.api.mapper.ExtApiDefinitionMapper;
|
||||||
import io.metersphere.api.mapper.ExtApiScenarioStepMapper;
|
import io.metersphere.api.mapper.ExtApiScenarioStepMapper;
|
||||||
|
@ -109,8 +108,8 @@ public class ApiDefinitionController {
|
||||||
|
|
||||||
// 获取 API 定义、测试用例 ID 和场景步骤中的 API ID
|
// 获取 API 定义、测试用例 ID 和场景步骤中的 API ID
|
||||||
List<String> apiDefinitionIdFromCase = extApiTestCaseMapper.selectApiId(projectId);
|
List<String> apiDefinitionIdFromCase = extApiTestCaseMapper.selectApiId(projectId);
|
||||||
List<String> apiInScenarioStep = new ArrayList<>(extApiScenarioStepMapper.selectResourceId(projectId, ApiScenarioStepType.API.name(), null));
|
List<String> apiInScenarioStep = new ArrayList<>(extApiScenarioStepMapper.selectResourceId(projectId, ApiScenarioStepType.API.name()));
|
||||||
List<String> apiCaseIdInStep = extApiScenarioStepMapper.selectResourceId(projectId, ApiScenarioStepType.API_CASE.name(), null);
|
List<String> apiCaseIdInStep = extApiScenarioStepMapper.selectResourceId(projectId, ApiScenarioStepType.API_CASE.name());
|
||||||
|
|
||||||
// 如果有场景步骤中的 API 用例 ID,追加相关 API ID
|
// 如果有场景步骤中的 API 用例 ID,追加相关 API ID
|
||||||
if (CollectionUtils.isNotEmpty(apiCaseIdInStep)) {
|
if (CollectionUtils.isNotEmpty(apiCaseIdInStep)) {
|
||||||
|
|
|
@ -26,7 +26,11 @@ public interface ExtApiScenarioStepMapper {
|
||||||
*/
|
*/
|
||||||
List<String> getHasBlobRequestStepIds(@Param("scenarioId") String scenarioId);
|
List<String> getHasBlobRequestStepIds(@Param("scenarioId") String scenarioId);
|
||||||
|
|
||||||
List<String> selectResourceId(@Param("projectId") String projectId, @Param("stepType") String stepType, @Param("protocols") List<String> apiProtocols);
|
List<String> selectResourceId(@Param("projectId") String projectId, @Param("stepType") String stepType);
|
||||||
|
|
||||||
|
List<String> selectApiResourceId(@Param("projectId") String projectId, @Param("stepType") String stepType, List<String> protocols);
|
||||||
|
|
||||||
|
List<String> selectApiCaseResourceId(@Param("projectId") String projectId, @Param("stepType") String stepType, List<String> protocols);
|
||||||
|
|
||||||
List<String> selectCustomRequestConfigByProjectId(String projectId);
|
List<String> selectCustomRequestConfigByProjectId(String projectId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,35 @@
|
||||||
where step.step_type = #{stepType}
|
where step.step_type = #{stepType}
|
||||||
AND scenario.project_id = #{projectId}
|
AND scenario.project_id = #{projectId}
|
||||||
AND scenario.deleted IS FALSE
|
AND scenario.deleted IS FALSE
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectApiResourceId" resultType="java.lang.String">
|
||||||
|
select DISTINCT step.resource_id
|
||||||
|
from api_scenario_step step
|
||||||
|
INNER JOIN api_scenario scenario
|
||||||
|
ON step.scenario_id = scenario.id
|
||||||
|
where step.step_type = #{stepType}
|
||||||
|
AND scenario.project_id = #{projectId}
|
||||||
|
AND scenario.deleted IS FALSE
|
||||||
|
<if test="protocols!= null and protocols.size > 0">
|
||||||
|
AND step.resource_id IN (
|
||||||
|
select distinct api.id FROM api_definition api
|
||||||
|
WHERE api.project_id = #{projectId} AND api.deleted IS FALSE and api.deleted IS FALSE AND api.protocol IN
|
||||||
|
<foreach collection="protocols" item="protocol" open="(" separator="," close=")">
|
||||||
|
#{protocol}
|
||||||
|
</foreach>
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectApiCaseResourceId" resultType="java.lang.String">
|
||||||
|
select DISTINCT step.resource_id
|
||||||
|
from api_scenario_step step
|
||||||
|
INNER JOIN api_scenario scenario
|
||||||
|
ON step.scenario_id = scenario.id
|
||||||
|
where step.step_type = #{stepType}
|
||||||
|
AND scenario.project_id = #{projectId}
|
||||||
|
AND scenario.deleted IS FALSE
|
||||||
<if test="protocols!= null and protocols.size > 0">
|
<if test="protocols!= null and protocols.size > 0">
|
||||||
AND step.resource_id IN (
|
AND step.resource_id IN (
|
||||||
select distinct apiCase.id FROM api_definition api
|
select distinct apiCase.id FROM api_definition api
|
||||||
|
@ -54,7 +83,7 @@
|
||||||
ON step.scenario_id = scenario.id
|
ON step.scenario_id = scenario.id
|
||||||
where scenario.project_id = #{0}
|
where scenario.project_id = #{0}
|
||||||
AND scenario.deleted IS FALSE
|
AND scenario.deleted IS FALSE
|
||||||
AND step.step_type IN ('API', 'API_CASE', 'CUSTOM_REQUEST')
|
AND step.step_type IN ('CUSTOM_REQUEST')
|
||||||
AND JSON_UNQUOTE(JSON_EXTRACT(LOWER(step.config), '$.protocol')) = 'http'
|
AND JSON_UNQUOTE(JSON_EXTRACT(LOWER(step.config), '$.protocol')) = 'http'
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
|
@ -201,8 +201,8 @@ public class ApiDefinitionService extends MoveNodeService {
|
||||||
|
|
||||||
private List<String> selectApiIdInScenarioStep(String projectId, List<String> protocols, List<String> ignoreApiIds) {
|
private List<String> selectApiIdInScenarioStep(String projectId, List<String> protocols, List<String> ignoreApiIds) {
|
||||||
|
|
||||||
List<String> apiInScenarioStep = new ArrayList<>(extApiScenarioStepMapper.selectResourceId(projectId, ApiScenarioStepType.API.name(), protocols));
|
List<String> apiInScenarioStep = extApiScenarioStepMapper.selectApiResourceId(projectId, ApiScenarioStepType.API.name(), protocols);
|
||||||
List<String> apiCaseIdInStep = extApiScenarioStepMapper.selectResourceId(projectId, ApiScenarioStepType.API_CASE.name(), protocols);
|
List<String> apiCaseIdInStep = extApiScenarioStepMapper.selectApiCaseResourceId(projectId, ApiScenarioStepType.API_CASE.name(), protocols);
|
||||||
// 如果有场景步骤中的 API 用例 ID,追加相关 API ID
|
// 如果有场景步骤中的 API 用例 ID,追加相关 API ID
|
||||||
if (CollectionUtils.isNotEmpty(apiCaseIdInStep)) {
|
if (CollectionUtils.isNotEmpty(apiCaseIdInStep)) {
|
||||||
List<String> apiCaseIdInScenarioStep = extApiTestCaseMapper.selectApiIdByCaseId(apiCaseIdInStep, protocols, ignoreApiIds);
|
List<String> apiCaseIdInScenarioStep = extApiTestCaseMapper.selectApiIdByCaseId(apiCaseIdInStep, protocols, ignoreApiIds);
|
||||||
|
|
Loading…
Reference in New Issue