fix(接口测试): 修复接口测试首页的场景数量统计问题
--bug=1015147 --user=宋天阳 【接口测试】首页-场景用例数量统计,没有场景的时候,接口数量显示了0 https://www.tapd.cn/55049933/s/1206997
This commit is contained in:
parent
a66e773adf
commit
539220bb9c
|
@ -313,7 +313,10 @@ public class APITestController {
|
||||||
long effectiveApiCount = apiDefinitionService.countEffectiveByProjectId(projectId);
|
long effectiveApiCount = apiDefinitionService.countEffectiveByProjectId(projectId);
|
||||||
long sourceIdCount = apiDefinitionService.countQuotedApiByProjectId(projectId);
|
long sourceIdCount = apiDefinitionService.countQuotedApiByProjectId(projectId);
|
||||||
try {
|
try {
|
||||||
if (sourceIdCount != 0) {
|
if (effectiveApiCount == 0) {
|
||||||
|
coverage.setCoverate(0);
|
||||||
|
coverage.setNotCoverate(0);
|
||||||
|
} else {
|
||||||
coverage.setCoverate(sourceIdCount);
|
coverage.setCoverate(sourceIdCount);
|
||||||
coverage.setNotCoverate(effectiveApiCount - sourceIdCount);
|
coverage.setNotCoverate(effectiveApiCount - sourceIdCount);
|
||||||
float coverageRageNumber = (float) sourceIdCount * 100 / effectiveApiCount;
|
float coverageRageNumber = (float) sourceIdCount * 100 / effectiveApiCount;
|
||||||
|
|
|
@ -1773,48 +1773,46 @@ public class ApiAutomationService {
|
||||||
*/
|
*/
|
||||||
public CoverageDTO countInterfaceCoverage(String projectId, Map<String, Map<String, String>> scenarioUrlMap, List<ApiDefinition> allEffectiveApiList) {
|
public CoverageDTO countInterfaceCoverage(String projectId, Map<String, Map<String, String>> scenarioUrlMap, List<ApiDefinition> allEffectiveApiList) {
|
||||||
CoverageDTO coverage = new CoverageDTO();
|
CoverageDTO coverage = new CoverageDTO();
|
||||||
|
if (CollectionUtils.isEmpty(allEffectiveApiList)) {
|
||||||
if (MapUtils.isEmpty(scenarioUrlMap) || CollectionUtils.isEmpty(allEffectiveApiList)) {
|
|
||||||
return coverage;
|
return coverage;
|
||||||
}
|
}
|
||||||
|
int urlContainsCount = 0;
|
||||||
ProjectApplication urlRepeatableConfig = projectApplicationService.getProjectApplication(projectId, ProjectApplicationType.URL_REPEATABLE.name());
|
if (MapUtils.isNotEmpty(scenarioUrlMap)) {
|
||||||
boolean isUrlRepeatable = BooleanUtils.toBoolean(urlRepeatableConfig.getTypeValue());
|
ProjectApplication urlRepeatableConfig = projectApplicationService.getProjectApplication(projectId, ProjectApplicationType.URL_REPEATABLE.name());
|
||||||
|
boolean isUrlRepeatable = BooleanUtils.toBoolean(urlRepeatableConfig.getTypeValue());
|
||||||
int containsCount = 0;
|
for (ApiDefinition model : allEffectiveApiList) {
|
||||||
for (ApiDefinition model : allEffectiveApiList) {
|
if (StringUtils.equalsIgnoreCase(model.getProtocol(), "http")) {
|
||||||
if (StringUtils.equalsIgnoreCase(model.getProtocol(), "http")) {
|
Map<String, String> stepIdAndUrlMap = scenarioUrlMap.get(model.getMethod());
|
||||||
Map<String, String> stepIdAndUrlMap = scenarioUrlMap.get(model.getMethod());
|
if (stepIdAndUrlMap != null) {
|
||||||
if (stepIdAndUrlMap != null) {
|
if (isUrlRepeatable) {
|
||||||
if (isUrlRepeatable) {
|
String url = stepIdAndUrlMap.get(model.getId());
|
||||||
String url = stepIdAndUrlMap.get(model.getId());
|
if (StringUtils.isNotEmpty(url)) {
|
||||||
if (StringUtils.isNotEmpty(url)) {
|
boolean urlMatched = MockApiUtils.isUrlMatch(model.getPath(), url);
|
||||||
boolean matchedUrl = MockApiUtils.isUrlMatch(model.getPath(), url);
|
if (urlMatched) {
|
||||||
|
urlContainsCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Collection<String> scenarioUrlList = scenarioUrlMap.get(model.getMethod()).values();
|
||||||
|
boolean matchedUrl = MockApiUtils.isUrlInList(model.getPath(), scenarioUrlList);
|
||||||
if (matchedUrl) {
|
if (matchedUrl) {
|
||||||
containsCount++;
|
urlContainsCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
Collection<String> scenarioUrlList = scenarioUrlMap.get(model.getMethod()).values();
|
|
||||||
boolean matchedUrl = MockApiUtils.isUrlInList(model.getPath(), scenarioUrlList);
|
|
||||||
if (matchedUrl) {
|
|
||||||
containsCount++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
} else {
|
Map<String, String> stepIdAndUrlMap = scenarioUrlMap.get("MS_NOT_HTTP");
|
||||||
Map<String, String> stepIdAndUrlMap = scenarioUrlMap.get("MS_NOT_HTTP");
|
if (stepIdAndUrlMap != null && stepIdAndUrlMap.containsKey(model.getId())) {
|
||||||
if (stepIdAndUrlMap != null && stepIdAndUrlMap.containsKey(model.getId())) {
|
urlContainsCount++;
|
||||||
containsCount++;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
coverage.setCoverate(containsCount);
|
coverage.setCoverate(urlContainsCount);
|
||||||
coverage.setNotCoverate(allEffectiveApiList.size() - containsCount);
|
coverage.setNotCoverate(allEffectiveApiList.size() - urlContainsCount);
|
||||||
float coverageRageNumber = (float) containsCount * 100 / allEffectiveApiList.size();
|
float coverageRageNumber = (float) urlContainsCount * 100 / allEffectiveApiList.size();
|
||||||
DecimalFormat df = new DecimalFormat("0.0");
|
DecimalFormat df = new DecimalFormat("0.0");
|
||||||
coverage.setRateOfCoverage(df.format(coverageRageNumber) + "%");
|
coverage.setRateOfCoverage(df.format(coverageRageNumber) + "%");
|
||||||
|
|
||||||
return coverage;
|
return coverage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -629,8 +629,10 @@
|
||||||
FROM api_test_case testCase
|
FROM api_test_case testCase
|
||||||
INNER JOIN api_definition apiDef ON testCase.api_definition_id = apiDef.id
|
INNER JOIN api_definition apiDef ON testCase.api_definition_id = apiDef.id
|
||||||
WHERE testCase.project_id = #{projectId}AND apiDef.status != "Trash"
|
WHERE testCase.project_id = #{projectId}AND apiDef.status != "Trash"
|
||||||
AND testCase.create_time BETWEEN #{firstDayTimestamp}
|
AND (testCase.create_time BETWEEN #{firstDayTimestamp}
|
||||||
AND #{lastDayTimestamp}
|
AND #{lastDayTimestamp})
|
||||||
|
AND (testCase.status is null
|
||||||
|
or testCase.status != 'Trash')
|
||||||
and latest = 1
|
and latest = 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue