fix(接口测试): 修复接口测试首页按照版本查询时的公式计算以及覆盖率统计错误的问题

--bug=1020896 --user=宋天阳
【接口测试】首页接口数量统计,覆盖率显示错误
https://www.tapd.cn/55049933/s/1316075
This commit is contained in:
song-tianyang 2022-12-15 21:20:38 +08:00 committed by 建国
parent 0b06de4232
commit d60b25dab1
5 changed files with 18 additions and 8 deletions

View File

@ -103,7 +103,7 @@ public class MockApiUtils {
} else if (StringUtils.equalsIgnoreCase(type, "XML")) {
if (bodyObj.has("raw")) {
String xmlStr = bodyObj.optString("raw");
xmlStr = xmlStr.replaceAll("\r","").replaceAll("\n","");
xmlStr = xmlStr.replaceAll("\r", "").replaceAll("\n", "");
JSONObject matchObj = XMLUtil.xmlStringToJSONObject(xmlStr);
returnJson = matchObj;
}
@ -360,7 +360,10 @@ public class MockApiUtils {
bodyParams = new JSONArray();
bodyParams.put(paramJson);
} else {
bodyParams.put(((JSONObject) paramJson));
JSONArray oldArray = returnParams.getBodyParams();
if (!JsonStructUtils.checkJsonArrayCompliance(oldArray, ((JSONObject) paramJson))) {
bodyParams.put(((JSONObject) paramJson));
}
}
returnParams.setBodyParams(bodyParams);
}

View File

@ -79,7 +79,7 @@ public class ApiHomeController {
long effectiveApiCount = apiDefinitionService.countEffectiveByProjectId(projectId, versionId);
long apiHasCase = apiDefinitionService.countApiByProjectIdAndHasCase(projectId, versionId);
List<ApiDefinition> apiNoCaseList = apiDefinitionService.selectEffectiveIdByProjectIdAndHaveNotCase(projectId, versionId);
Map<String, Map<String, String>> scenarioUrlList = apiAutomationService.selectScenarioUseUrlByProjectId(projectId, versionId);
Map<String, Map<String, String>> scenarioUrlList = apiAutomationService.selectScenarioUseUrlByProjectId(projectId, null);
int apiInScenario = apiAutomationService.getApiIdInScenario(projectId, scenarioUrlList, apiNoCaseList).size();
if (effectiveApiCount == 0) {
@ -185,7 +185,6 @@ public class ApiHomeController {
apiCountResult.setCoveredCount(coveredDTO.covered);
apiCountResult.setNotCoveredCount(coveredDTO.notCovered);
apiCountResult.setApiCoveredRate(coveredDTO.rateOfCovered);
return apiCountResult;
}

View File

@ -1669,9 +1669,11 @@ public class ApiDefinitionService {
} else {
ApiDefinitionExample example = new ApiDefinitionExample();
ApiDefinitionExample.Criteria criteria = example.createCriteria();
criteria.andProjectIdEqualTo(projectId).andStatusNotEqualTo("Trash").andLatestEqualTo(true);
criteria.andProjectIdEqualTo(projectId).andStatusNotEqualTo("Trash");
if (StringUtils.isNotBlank(versionId)) {
criteria.andVersionIdEqualTo(versionId);
} else {
criteria.andLatestEqualTo(true);
}
return apiDefinitionMapper.countByExample(example);
}

View File

@ -123,6 +123,7 @@ export default {
tableData: [],
currentPage: 1,
pageSize: 5,
versionId: '',
total: 0,
condition: {
filters: {},
@ -143,10 +144,13 @@ export default {
}
},
search(versionId) {
if (versionId) {
this.versionId = versionId;
}
let projectId = getCurrentProjectID();
this.loading = true;
this.loadError = false;
this.result = getRunningTask(projectId, versionId, this.currentPage, this.pageSize)
this.result = getRunningTask(projectId, this.versionId, this.currentPage, this.pageSize)
.then((response) => {
this.total = response.data.itemCount;
this.tableData = response.data.listObject;

View File

@ -156,12 +156,14 @@ export default {
}
},
search(versionId) {
this.versionId = versionId;
if (versionId) {
this.versionId = versionId;
}
let projectId = getCurrentProjectID();
this.loading = true;
this.loadError = false;
this.result = definitionWeekList(projectId, versionId, this.currentPage, this.pageSize)
this.result = definitionWeekList(projectId, this.versionId, this.currentPage, this.pageSize)
.then((response) => {
this.total = response.data.itemCount;
this.tableData = response.data.listObject;