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 sourceIdCount = apiDefinitionService.countQuotedApiByProjectId(projectId);
|
||||
try {
|
||||
if (sourceIdCount != 0) {
|
||||
if (effectiveApiCount == 0) {
|
||||
coverage.setCoverate(0);
|
||||
coverage.setNotCoverate(0);
|
||||
} else {
|
||||
coverage.setCoverate(sourceIdCount);
|
||||
coverage.setNotCoverate(effectiveApiCount - sourceIdCount);
|
||||
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) {
|
||||
CoverageDTO coverage = new CoverageDTO();
|
||||
|
||||
if (MapUtils.isEmpty(scenarioUrlMap) || CollectionUtils.isEmpty(allEffectiveApiList)) {
|
||||
if (CollectionUtils.isEmpty(allEffectiveApiList)) {
|
||||
return coverage;
|
||||
}
|
||||
|
||||
ProjectApplication urlRepeatableConfig = projectApplicationService.getProjectApplication(projectId, ProjectApplicationType.URL_REPEATABLE.name());
|
||||
boolean isUrlRepeatable = BooleanUtils.toBoolean(urlRepeatableConfig.getTypeValue());
|
||||
|
||||
int containsCount = 0;
|
||||
for (ApiDefinition model : allEffectiveApiList) {
|
||||
if (StringUtils.equalsIgnoreCase(model.getProtocol(), "http")) {
|
||||
Map<String, String> stepIdAndUrlMap = scenarioUrlMap.get(model.getMethod());
|
||||
if (stepIdAndUrlMap != null) {
|
||||
if (isUrlRepeatable) {
|
||||
String url = stepIdAndUrlMap.get(model.getId());
|
||||
if (StringUtils.isNotEmpty(url)) {
|
||||
boolean matchedUrl = MockApiUtils.isUrlMatch(model.getPath(), url);
|
||||
int urlContainsCount = 0;
|
||||
if (MapUtils.isNotEmpty(scenarioUrlMap)) {
|
||||
ProjectApplication urlRepeatableConfig = projectApplicationService.getProjectApplication(projectId, ProjectApplicationType.URL_REPEATABLE.name());
|
||||
boolean isUrlRepeatable = BooleanUtils.toBoolean(urlRepeatableConfig.getTypeValue());
|
||||
for (ApiDefinition model : allEffectiveApiList) {
|
||||
if (StringUtils.equalsIgnoreCase(model.getProtocol(), "http")) {
|
||||
Map<String, String> stepIdAndUrlMap = scenarioUrlMap.get(model.getMethod());
|
||||
if (stepIdAndUrlMap != null) {
|
||||
if (isUrlRepeatable) {
|
||||
String url = stepIdAndUrlMap.get(model.getId());
|
||||
if (StringUtils.isNotEmpty(url)) {
|
||||
boolean urlMatched = 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) {
|
||||
containsCount++;
|
||||
urlContainsCount++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Collection<String> scenarioUrlList = scenarioUrlMap.get(model.getMethod()).values();
|
||||
boolean matchedUrl = MockApiUtils.isUrlInList(model.getPath(), scenarioUrlList);
|
||||
if (matchedUrl) {
|
||||
containsCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Map<String, String> stepIdAndUrlMap = scenarioUrlMap.get("MS_NOT_HTTP");
|
||||
if (stepIdAndUrlMap != null && stepIdAndUrlMap.containsKey(model.getId())) {
|
||||
containsCount++;
|
||||
} else {
|
||||
Map<String, String> stepIdAndUrlMap = scenarioUrlMap.get("MS_NOT_HTTP");
|
||||
if (stepIdAndUrlMap != null && stepIdAndUrlMap.containsKey(model.getId())) {
|
||||
urlContainsCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
coverage.setCoverate(containsCount);
|
||||
coverage.setNotCoverate(allEffectiveApiList.size() - containsCount);
|
||||
float coverageRageNumber = (float) containsCount * 100 / allEffectiveApiList.size();
|
||||
coverage.setCoverate(urlContainsCount);
|
||||
coverage.setNotCoverate(allEffectiveApiList.size() - urlContainsCount);
|
||||
float coverageRageNumber = (float) urlContainsCount * 100 / allEffectiveApiList.size();
|
||||
DecimalFormat df = new DecimalFormat("0.0");
|
||||
coverage.setRateOfCoverage(df.format(coverageRageNumber) + "%");
|
||||
|
||||
return coverage;
|
||||
}
|
||||
|
||||
|
|
|
@ -629,8 +629,10 @@
|
|||
FROM api_test_case testCase
|
||||
INNER JOIN api_definition apiDef ON testCase.api_definition_id = apiDef.id
|
||||
WHERE testCase.project_id = #{projectId}AND apiDef.status != "Trash"
|
||||
AND testCase.create_time BETWEEN #{firstDayTimestamp}
|
||||
AND #{lastDayTimestamp}
|
||||
AND (testCase.create_time BETWEEN #{firstDayTimestamp}
|
||||
AND #{lastDayTimestamp})
|
||||
AND (testCase.status is null
|
||||
or testCase.status != 'Trash')
|
||||
and latest = 1
|
||||
</select>
|
||||
|
||||
|
|
Loading…
Reference in New Issue