fix(接口测试): 修复接口测试首页执行率错误的问题

修复接口测试首页执行率错误的问题
This commit is contained in:
song-tianyang 2022-11-12 11:29:52 +08:00 committed by 刘瑞斌
parent 5fb85b377d
commit f88e2f69cb
2 changed files with 14 additions and 2 deletions

View File

@ -28,7 +28,9 @@ public class ApiDataCountDTO {
private long runningCount = 0; private long runningCount = 0;
private long finishedCount = 0; private long finishedCount = 0;
private long notStartedCount = 0; private long notStartedCount = 0;
//本周执行次数
private long executedTimesInWeek = 0; private long executedTimesInWeek = 0;
//历史执行总次数
private long executedCount = 0; private long executedCount = 0;
private long notExecutedCount = 0; private long notExecutedCount = 0;
private long passCount = 0; private long passCount = 0;
@ -119,6 +121,15 @@ public class ApiDataCountDTO {
} }
} }
/**
* 获取执行过的数据数
*
* @return
*/
public long getExecutedData() {
return this.unPassCount + this.fakeErrorCount + this.passCount;
}
public void countApiCaseRunResult(List<ExecuteResultCountDTO> executeResultCountDTOList) { public void countApiCaseRunResult(List<ExecuteResultCountDTO> executeResultCountDTOList) {
for (ExecuteResultCountDTO execResult : executeResultCountDTOList) { for (ExecuteResultCountDTO execResult : executeResultCountDTOList) {
if (StringUtils.isEmpty(execResult.getExecResult())) { if (StringUtils.isEmpty(execResult.getExecResult())) {

View File

@ -117,7 +117,7 @@ public class ApiHomeController {
DecimalFormat coveredRateFormat = new DecimalFormat("0.0"); DecimalFormat coveredRateFormat = new DecimalFormat("0.0");
apiCountResult.setPassRate(coveredRateFormat.format(coveredRateNumber) + "%"); apiCountResult.setPassRate(coveredRateFormat.format(coveredRateNumber) + "%");
float executedRateNumber = (float) apiCountResult.getExecutedCount() * 100 / apiCountResult.getTotal(); float executedRateNumber = (float) apiCountResult.getExecutedData() * 100 / apiCountResult.getTotal();
DecimalFormat executedRateFormat = new DecimalFormat("0.0"); DecimalFormat executedRateFormat = new DecimalFormat("0.0");
apiCountResult.setExecutedRate(executedRateFormat.format(executedRateNumber) + "%"); apiCountResult.setExecutedRate(executedRateFormat.format(executedRateNumber) + "%");
} else { } else {
@ -137,6 +137,7 @@ public class ApiHomeController {
apiCountResult.setCreatedInWeek(dateCountByCreateInThisWeek); apiCountResult.setCreatedInWeek(dateCountByCreateInThisWeek);
long executedInThisWeekCountNumber = apiScenarioReportService.countByProjectIdAndCreateInThisWeek(projectId); long executedInThisWeekCountNumber = apiScenarioReportService.countByProjectIdAndCreateInThisWeek(projectId);
apiCountResult.setExecutedTimesInWeek(executedInThisWeekCountNumber); apiCountResult.setExecutedTimesInWeek(executedInThisWeekCountNumber);
//所有执行次数
long executedCount = apiAutomationService.countExecuteTimesByProjectID(projectId, null); long executedCount = apiAutomationService.countExecuteTimesByProjectID(projectId, null);
apiCountResult.setExecutedCount(executedCount); apiCountResult.setExecutedCount(executedCount);
//未执行未通过已通过 //未执行未通过已通过
@ -148,7 +149,7 @@ public class ApiHomeController {
float coveredRateNumber = (float) apiCountResult.getPassCount() * 100 / executedCount; float coveredRateNumber = (float) apiCountResult.getPassCount() * 100 / executedCount;
apiCountResult.setPassRate(df.format(coveredRateNumber) + "%"); apiCountResult.setPassRate(df.format(coveredRateNumber) + "%");
//执行率 //执行率
float executedRateNumber = (float) apiCountResult.getExecutedCount() * 100 / apiCountResult.getTotal(); float executedRateNumber = (float) apiCountResult.getExecutedData() * 100 / apiCountResult.getTotal();
apiCountResult.setExecutedRate(df.format(executedRateNumber) + "%"); apiCountResult.setExecutedRate(df.format(executedRateNumber) + "%");
} }