fix(接口测试): 改进接口测试首页的接口用例统计方法
--bug=1021930 --user=宋天阳 【接口测试】接口首页 - 接口用例数量统计 - 未通过用例数统计不对 https://www.tapd.cn/55049933/s/1327734
This commit is contained in:
parent
22f7f58e30
commit
cf4287d690
|
@ -467,19 +467,19 @@
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
<if test="request.redirectFilter == 'unexecuteCount' ">
|
<if test="request.redirectFilter == 'unexecuteCount' ">
|
||||||
and (t1.status IS NULL or t1.status NOT IN ('SUCCESS','ERROR','FAKE_ERROR') )
|
and (t3.status IS NULL or t3.status NOT IN ('SUCCESS','ERROR','FAKE_ERROR') )
|
||||||
</if>
|
</if>
|
||||||
<if test="request.redirectFilter == 'executionPassCount' ">
|
<if test="request.redirectFilter == 'executionPassCount' ">
|
||||||
and t1.status = 'SUCCESS'
|
and t3.status = 'SUCCESS'
|
||||||
</if>
|
</if>
|
||||||
<if test="request.redirectFilter == 'executionFailedCount' ">
|
<if test="request.redirectFilter == 'executionFailedCount' ">
|
||||||
and t1.status = 'ERROR'
|
and t3.status = 'ERROR'
|
||||||
</if>
|
</if>
|
||||||
<if test="request.redirectFilter == 'fakeErrorCount' ">
|
<if test="request.redirectFilter == 'fakeErrorCount' ">
|
||||||
and t1.status = 'FAKE_ERROR'
|
and t3.status = 'FAKE_ERROR'
|
||||||
</if>
|
</if>
|
||||||
<if test="request.redirectFilter == 'executedCount' ">
|
<if test="request.redirectFilter == 'executedCount' ">
|
||||||
and t1.status IN ('SUCCESS','ERROR','FAKE_ERROR')
|
and t3.status IN ('SUCCESS','ERROR','FAKE_ERROR')
|
||||||
</if>
|
</if>
|
||||||
<if test="request.filters != null and request.filters.size() > 0">
|
<if test="request.filters != null and request.filters.size() > 0">
|
||||||
<foreach collection="request.filters.entrySet()" index="key" item="values">
|
<foreach collection="request.filters.entrySet()" index="key" item="values">
|
||||||
|
@ -1022,23 +1022,29 @@
|
||||||
from api_test_case
|
from api_test_case
|
||||||
where id = #{0}
|
where id = #{0}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectExecuteResultByProjectId"
|
<select id="selectExecuteResultByProjectId"
|
||||||
resultType="io.metersphere.api.dto.datacount.response.ExecuteResultCountDTO">
|
resultType="io.metersphere.api.dto.datacount.response.ExecuteResultCountDTO">
|
||||||
|
SELECT
|
||||||
|
execResult.`status` AS execResult,
|
||||||
|
count(testCase.id) AS `count`
|
||||||
|
FROM
|
||||||
|
api_test_case testCase
|
||||||
|
LEFT JOIN api_definition_exec_result execResult ON execResult.id = testCase.last_result_id
|
||||||
|
WHERE
|
||||||
|
( testCase.`status` IS NULL OR testCase.`status` != 'Trash' )
|
||||||
|
AND testCase.api_definition_id IN (
|
||||||
|
SELECT id FROM api_definition
|
||||||
|
WHERE project_id = #{projectId}
|
||||||
|
<if test="versionId != null">
|
||||||
|
AND version_id = #{versionId}
|
||||||
|
</if>
|
||||||
|
<if test="versionId == null">
|
||||||
|
AND latest IS TRUE
|
||||||
|
</if>
|
||||||
|
)
|
||||||
|
GROUP BY
|
||||||
|
execResult.`status`;
|
||||||
|
|
||||||
SELECT `status` AS execResult,count(id) AS count
|
|
||||||
FROM api_test_case
|
|
||||||
WHERE `status` != 'Trash' AND api_definition_id IN
|
|
||||||
(SELECT id FROM api_definition
|
|
||||||
WHERE project_id = #{projectId}
|
|
||||||
<if test="versionId != null">
|
|
||||||
AND version_id = #{versionId}
|
|
||||||
</if>
|
|
||||||
<if test="versionId == null">
|
|
||||||
AND latest IS TRUE
|
|
||||||
</if>
|
|
||||||
)
|
|
||||||
GROUP BY `status`
|
|
||||||
</select>
|
</select>
|
||||||
<select id="caseList" resultType="io.metersphere.base.domain.ApiTestCaseWithBLOBs">
|
<select id="caseList" resultType="io.metersphere.base.domain.ApiTestCaseWithBLOBs">
|
||||||
SELECT
|
SELECT
|
||||||
|
|
|
@ -58,9 +58,7 @@ public class ApiHomeController {
|
||||||
|
|
||||||
@GetMapping("/api/count/{projectId}/{versionId}")
|
@GetMapping("/api/count/{projectId}/{versionId}")
|
||||||
public ApiDataCountDTO apiCount(@PathVariable String projectId, @PathVariable String versionId) {
|
public ApiDataCountDTO apiCount(@PathVariable String projectId, @PathVariable String versionId) {
|
||||||
if (StringUtils.equalsIgnoreCase(versionId, "default")) {
|
versionId = this.initializationVersionId(versionId);
|
||||||
versionId = null;
|
|
||||||
}
|
|
||||||
ApiDataCountDTO apiCountResult = new ApiDataCountDTO();
|
ApiDataCountDTO apiCountResult = new ApiDataCountDTO();
|
||||||
List<ApiDataCountResult> countResultByProtocolList = apiDefinitionService.countProtocolByProjectID(projectId, versionId);
|
List<ApiDataCountResult> countResultByProtocolList = apiDefinitionService.countProtocolByProjectID(projectId, versionId);
|
||||||
apiCountResult.countProtocol(countResultByProtocolList);
|
apiCountResult.countProtocol(countResultByProtocolList);
|
||||||
|
@ -103,9 +101,7 @@ public class ApiHomeController {
|
||||||
|
|
||||||
@GetMapping("/api/case/count/{projectId}/{versionId}")
|
@GetMapping("/api/case/count/{projectId}/{versionId}")
|
||||||
public ApiDataCountDTO apiCaseCount(@PathVariable String projectId, @PathVariable String versionId) {
|
public ApiDataCountDTO apiCaseCount(@PathVariable String projectId, @PathVariable String versionId) {
|
||||||
if (StringUtils.equalsIgnoreCase(versionId, "default")) {
|
versionId = this.initializationVersionId(versionId);
|
||||||
versionId = null;
|
|
||||||
}
|
|
||||||
ApiDataCountDTO apiCountResult = new ApiDataCountDTO();
|
ApiDataCountDTO apiCountResult = new ApiDataCountDTO();
|
||||||
List<ApiDataCountResult> countResultList = apiTestCaseService.countProtocolByProjectID(projectId, versionId);
|
List<ApiDataCountResult> countResultList = apiTestCaseService.countProtocolByProjectID(projectId, versionId);
|
||||||
apiCountResult.countProtocol(countResultList);
|
apiCountResult.countProtocol(countResultList);
|
||||||
|
@ -146,9 +142,7 @@ public class ApiHomeController {
|
||||||
|
|
||||||
@GetMapping("/scenario/count/{projectId}/{versionId}")
|
@GetMapping("/scenario/count/{projectId}/{versionId}")
|
||||||
public ApiDataCountDTO scenarioCount(@PathVariable String projectId, @PathVariable String versionId) {
|
public ApiDataCountDTO scenarioCount(@PathVariable String projectId, @PathVariable String versionId) {
|
||||||
if (StringUtils.equalsIgnoreCase(versionId, "default")) {
|
versionId = this.initializationVersionId(versionId);
|
||||||
versionId = null;
|
|
||||||
}
|
|
||||||
ApiDataCountDTO apiCountResult = new ApiDataCountDTO();
|
ApiDataCountDTO apiCountResult = new ApiDataCountDTO();
|
||||||
long scenarioCountNumber = apiAutomationService.countScenarioByProjectID(projectId, versionId);
|
long scenarioCountNumber = apiAutomationService.countScenarioByProjectID(projectId, versionId);
|
||||||
apiCountResult.setTotal(scenarioCountNumber);
|
apiCountResult.setTotal(scenarioCountNumber);
|
||||||
|
@ -190,11 +184,8 @@ public class ApiHomeController {
|
||||||
|
|
||||||
@GetMapping("/schedule/task/count/{projectId}/{versionId}")
|
@GetMapping("/schedule/task/count/{projectId}/{versionId}")
|
||||||
public ApiDataCountDTO scheduleTaskCount(@PathVariable String projectId, @PathVariable String versionId) {
|
public ApiDataCountDTO scheduleTaskCount(@PathVariable String projectId, @PathVariable String versionId) {
|
||||||
if (StringUtils.equalsIgnoreCase(versionId, "default")) {
|
versionId = this.initializationVersionId(versionId);
|
||||||
versionId = null;
|
|
||||||
}
|
|
||||||
List<Schedule> allScenarioScheduleList = baseScheduleService.selectScenarioTaskByProjectId(projectId, versionId);
|
List<Schedule> allScenarioScheduleList = baseScheduleService.selectScenarioTaskByProjectId(projectId, versionId);
|
||||||
|
|
||||||
ApiDataCountDTO apiCountResult = new ApiDataCountDTO();
|
ApiDataCountDTO apiCountResult = new ApiDataCountDTO();
|
||||||
long allTaskCount = allScenarioScheduleList.size();
|
long allTaskCount = allScenarioScheduleList.size();
|
||||||
apiCountResult.setTotal(allTaskCount);
|
apiCountResult.setTotal(allTaskCount);
|
||||||
|
@ -246,9 +237,7 @@ public class ApiHomeController {
|
||||||
@PostMapping("/runningTask/{projectId}/{versionId}/{goPage}/{pageSize}")
|
@PostMapping("/runningTask/{projectId}/{versionId}/{goPage}/{pageSize}")
|
||||||
public Pager<List<TaskInfoResult>> runningTask(@PathVariable String projectId, @PathVariable String versionId, @PathVariable int goPage, @PathVariable int pageSize) {
|
public Pager<List<TaskInfoResult>> runningTask(@PathVariable String projectId, @PathVariable String versionId, @PathVariable int goPage, @PathVariable int pageSize) {
|
||||||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||||
if (StringUtils.equalsIgnoreCase(versionId, "default")) {
|
versionId = this.initializationVersionId(versionId);
|
||||||
versionId = null;
|
|
||||||
}
|
|
||||||
List<TaskInfoResult> resultList = taskService.findScenarioAndSwaggerRunningTaskInfoByProjectID(projectId, versionId);
|
List<TaskInfoResult> resultList = taskService.findScenarioAndSwaggerRunningTaskInfoByProjectID(projectId, versionId);
|
||||||
int dataIndex = 1;
|
int dataIndex = 1;
|
||||||
for (TaskInfoResult taskInfo :
|
for (TaskInfoResult taskInfo :
|
||||||
|
@ -266,9 +255,7 @@ public class ApiHomeController {
|
||||||
@GetMapping("/failure/case/about/plan/{projectId}/{versionId}/{selectFunctionCase}/{limitNumber}/{goPage}/{pageSize}")
|
@GetMapping("/failure/case/about/plan/{projectId}/{versionId}/{selectFunctionCase}/{limitNumber}/{goPage}/{pageSize}")
|
||||||
public Pager<List<ExecutedCaseInfoDTO>> failureCaseAboutTestPlan(@PathVariable String projectId, @PathVariable String versionId, @PathVariable boolean selectFunctionCase,
|
public Pager<List<ExecutedCaseInfoDTO>> failureCaseAboutTestPlan(@PathVariable String projectId, @PathVariable String versionId, @PathVariable boolean selectFunctionCase,
|
||||||
@PathVariable int limitNumber, @PathVariable int goPage, @PathVariable int pageSize) {
|
@PathVariable int limitNumber, @PathVariable int goPage, @PathVariable int pageSize) {
|
||||||
if (StringUtils.equalsIgnoreCase(versionId, "default")) {
|
versionId = this.initializationVersionId(versionId);
|
||||||
versionId = null;
|
|
||||||
}
|
|
||||||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||||
List<ExecutedCaseInfoResult> selectDataList = apiDefinitionExecResultService.findFailureCaseInfoByProjectIDAndLimitNumberInSevenDays(projectId, versionId, selectFunctionCase, limitNumber);
|
List<ExecutedCaseInfoResult> selectDataList = apiDefinitionExecResultService.findFailureCaseInfoByProjectIDAndLimitNumberInSevenDays(projectId, versionId, selectFunctionCase, limitNumber);
|
||||||
List<ExecutedCaseInfoDTO> returnList = new ArrayList<>(selectDataList.size());
|
List<ExecutedCaseInfoDTO> returnList = new ArrayList<>(selectDataList.size());
|
||||||
|
@ -288,4 +275,13 @@ public class ApiHomeController {
|
||||||
}
|
}
|
||||||
return PageUtils.setPageInfo(page, returnList);
|
return PageUtils.setPageInfo(page, returnList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//初始化版本ID
|
||||||
|
private String initializationVersionId(String versionId) {
|
||||||
|
if (StringUtils.equalsIgnoreCase(versionId, "default")) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return versionId;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -32,7 +32,7 @@
|
||||||
:disabled="isReadOnly"
|
:disabled="isReadOnly"
|
||||||
v-model="scope.row.type"
|
v-model="scope.row.type"
|
||||||
size="mini"
|
size="mini"
|
||||||
@change="typeChange(item)">
|
@change="typeChange(scope.row)">
|
||||||
<el-option value="text" />
|
<el-option value="text" />
|
||||||
<el-option value="file" />
|
<el-option value="file" />
|
||||||
<el-option value="json" />
|
<el-option value="json" />
|
||||||
|
@ -437,7 +437,7 @@ export default {
|
||||||
urlEncode: this.urlEncode,
|
urlEncode: this.urlEncode,
|
||||||
uuid: this.uuid(),
|
uuid: this.uuid(),
|
||||||
valid: false,
|
valid: false,
|
||||||
value: null
|
value: null,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -488,11 +488,11 @@ export default {
|
||||||
},
|
},
|
||||||
typeChange(item) {
|
typeChange(item) {
|
||||||
if (item.type === 'file') {
|
if (item.type === 'file') {
|
||||||
item.contentType = 'application/octet-stream';
|
this.$set(item, 'contentType', 'application/octet-stream');
|
||||||
} else if (item.type === 'text') {
|
} else if (item.type === 'text') {
|
||||||
item.contentType = 'text/plain';
|
this.$set(item, 'contentType', 'text/plain');
|
||||||
} else {
|
} else {
|
||||||
item.contentType = 'application/json';
|
this.$set(item, 'contentType', 'application/json');
|
||||||
}
|
}
|
||||||
this.reload();
|
this.reload();
|
||||||
},
|
},
|
||||||
|
@ -540,7 +540,7 @@ export default {
|
||||||
urlEncode: this.urlEncode,
|
urlEncode: this.urlEncode,
|
||||||
uuid: this.uuid(),
|
uuid: this.uuid(),
|
||||||
valid: false,
|
valid: false,
|
||||||
value: null
|
value: null,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue