fix(接口测试): 修复场景集成报告状态只有失败和成功两种类型的问题
--bug=1013583 --user=宋天阳 【接口测试】批量执行 误报 场景,集合报告,报告状态不是误报 https://www.tapd.cn/55049933/s/1169496
This commit is contained in:
parent
0b2225c010
commit
d3d3d1b21b
|
@ -13,6 +13,7 @@ import io.metersphere.api.jmeter.FixedCapacityUtils;
|
||||||
import io.metersphere.base.domain.*;
|
import io.metersphere.base.domain.*;
|
||||||
import io.metersphere.base.mapper.*;
|
import io.metersphere.base.mapper.*;
|
||||||
import io.metersphere.base.mapper.ext.ExtApiScenarioReportMapper;
|
import io.metersphere.base.mapper.ext.ExtApiScenarioReportMapper;
|
||||||
|
import io.metersphere.base.mapper.ext.ExtApiScenarioReportResultMapper;
|
||||||
import io.metersphere.commons.constants.*;
|
import io.metersphere.commons.constants.*;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
import io.metersphere.commons.utils.*;
|
import io.metersphere.commons.utils.*;
|
||||||
|
@ -83,6 +84,8 @@ public class ApiScenarioReportService {
|
||||||
private ApiDefinitionExecResultMapper definitionExecResultMapper;
|
private ApiDefinitionExecResultMapper definitionExecResultMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private UiReportServiceProxy uiReportServiceProxy;
|
private UiReportServiceProxy uiReportServiceProxy;
|
||||||
|
@Resource
|
||||||
|
private ExtApiScenarioReportResultMapper extApiScenarioReportResultMapper;
|
||||||
|
|
||||||
public void saveResult(ResultDTO dto) {
|
public void saveResult(ResultDTO dto) {
|
||||||
// 报告详情内容
|
// 报告详情内容
|
||||||
|
@ -363,10 +366,30 @@ public class ApiScenarioReportService {
|
||||||
if (!StringUtils.equalsAnyIgnoreCase(report.getStatus(), APITestStatus.Rerunning.name())) {
|
if (!StringUtils.equalsAnyIgnoreCase(report.getStatus(), APITestStatus.Rerunning.name())) {
|
||||||
report.setEndTime(System.currentTimeMillis());
|
report.setEndTime(System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
ApiScenarioReportResultExample example = new ApiScenarioReportResultExample();
|
List<String> statusList = extApiScenarioReportResultMapper.selectDistinctStatusByReportId(reportId);
|
||||||
example.createCriteria().andReportIdEqualTo(reportId).andStatusEqualTo(ScenarioStatus.Error.name());
|
boolean hasError = false, hasErrorReport = false, hasUnExecute = false, hasOtherStatus = false;
|
||||||
long size = apiScenarioReportResultMapper.countByExample(example);
|
for (String status : statusList) {
|
||||||
report.setStatus(size > 0 ? ScenarioStatus.Error.name() : ScenarioStatus.Success.name());
|
if (StringUtils.equalsIgnoreCase(status, ExecuteResult.Error.name())) {
|
||||||
|
hasError = true;
|
||||||
|
} else if (StringUtils.equalsIgnoreCase(status, ExecuteResult.errorReportResult.name())) {
|
||||||
|
hasErrorReport = true;
|
||||||
|
} else if (StringUtils.equalsIgnoreCase(status, ExecuteResult.unexecute.name())) {
|
||||||
|
hasUnExecute = true;
|
||||||
|
} else {
|
||||||
|
hasOtherStatus = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasUnExecute && (hasError || hasErrorReport || hasOtherStatus)) {
|
||||||
|
//只有全部状态都是未执行时,集合报告的状态才可以是未执行
|
||||||
|
hasUnExecute = false;
|
||||||
|
}else if(CollectionUtils.isEmpty(statusList)){
|
||||||
|
//查不到任何结果也按照未执行来处理
|
||||||
|
hasUnExecute = true;
|
||||||
|
}
|
||||||
|
report.setStatus(hasError ? ScenarioStatus.Error.name() :
|
||||||
|
hasErrorReport ? ExecuteResult.errorReportResult.name() :
|
||||||
|
hasUnExecute ? ExecuteResult.unexecute.name() : ScenarioStatus.Success.name());
|
||||||
// 更新报告
|
// 更新报告
|
||||||
apiScenarioReportMapper.updateByPrimaryKey(report);
|
apiScenarioReportMapper.updateByPrimaryKey(report);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,4 +12,5 @@ public interface ExtApiScenarioReportResultMapper {
|
||||||
|
|
||||||
List<String> getReportIds(@Param("ids") List<String> ids);
|
List<String> getReportIds(@Param("ids") List<String> ids);
|
||||||
|
|
||||||
|
List<String> selectDistinctStatusByReportId(String reportId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,4 +30,9 @@
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectDistinctStatusByReportId" resultType="java.lang.String">
|
||||||
|
SELECT DISTINCT status
|
||||||
|
FROM api_scenario_report_result
|
||||||
|
WHERE report_id = #{0}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -121,6 +121,10 @@
|
||||||
class="ms-task-stopped">
|
class="ms-task-stopped">
|
||||||
Stopped
|
Stopped
|
||||||
</span>
|
</span>
|
||||||
|
<span v-else-if="item.executionStatus && item.executionStatus.toLowerCase() === 'unexecute'"
|
||||||
|
class="ms-task-stopped">
|
||||||
|
unexecute
|
||||||
|
</span>
|
||||||
<span v-else-if="item.executionStatus && item.executionStatus.toLowerCase() === 'errorreportresult'"
|
<span v-else-if="item.executionStatus && item.executionStatus.toLowerCase() === 'errorreportresult'"
|
||||||
class="ms-task-error-report-status">
|
class="ms-task-error-report-status">
|
||||||
{{ $t('error_report_library.option.name') }}
|
{{ $t('error_report_library.option.name') }}
|
||||||
|
@ -325,7 +329,7 @@ export default {
|
||||||
if (status === "waiting" || status === 'stop') {
|
if (status === "waiting" || status === 'stop') {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (status === 'saved' || status === 'completed' || status === 'success' || status === 'error' || status === 'errorreportresult') {
|
if (status === 'saved' || status === 'completed' || status === 'success' || status === 'error' || status === 'unexecute' || status === 'errorreportresult') {
|
||||||
return 100;
|
return 100;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue