mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-01 03:28:59 +08:00
fix(UI自动化): 用例状态通过,但是测试报告状态为ERROR
--bug=1016682 --user=张大海 【UI测试】github#17821,UI自动化执行成功,用例状态也是通过,但是测试报告状态为ERROR https://www.tapd.cn/55049933/s/1242333
This commit is contained in:
parent
b8d2750088
commit
bc6ed06cce
@ -964,12 +964,7 @@ public class ApiScenarioReportService {
|
||||
//类型为ui时的统计
|
||||
if (StringUtils.isNotEmpty(dto.getRunMode()) && dto.getRunMode().startsWith("UI")) {
|
||||
try {
|
||||
errorSize = dto.getRequestResults().stream().filter(requestResult ->
|
||||
StringUtils.isNotEmpty(requestResult.getResponseResult().getHeaders())
|
||||
&& JSONArray.parseArray(requestResult.getResponseResult().getHeaders()).stream().filter(
|
||||
r -> ((JSONObject) r).containsKey("success") && !((JSONObject) r).getBoolean("success")
|
||||
).count() > 0)
|
||||
.count();
|
||||
errorSize = getUiErrorSize(dto);
|
||||
} catch (Exception e) {
|
||||
// UI 返回的结果在 headers 里面,格式不符合规范的直接认定结果为失败
|
||||
errorSize = 1;
|
||||
@ -989,6 +984,32 @@ public class ApiScenarioReportService {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 主流程或者有断言失败的就算失败
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
private long getUiErrorSize(ResultDTO dto) {
|
||||
int errorSize = 0;
|
||||
for (RequestResult r : dto.getRequestResults()) {
|
||||
if (StringUtils.isNotEmpty(r.getResponseResult().getHeaders())) {
|
||||
JSONArray responseArr = JSONArray.parseArray(r.getResponseResult().getHeaders());
|
||||
for (int i = 0; i < responseArr.size(); i++) {
|
||||
JSONObject stepResult = responseArr.getJSONObject(i);
|
||||
if (stepResult.containsKey("success") && !stepResult.getBoolean("success")) {
|
||||
if ((stepResult.containsKey("processType") && StringUtils.equalsIgnoreCase("MAIN", stepResult.getString("processType")))
|
||||
|| (stepResult.containsKey("cmdName")
|
||||
&& ((stepResult.getString("cmdName").startsWith("verify")) || stepResult.getString("cmdName").startsWith("assert")))) {
|
||||
errorSize++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return errorSize;
|
||||
}
|
||||
|
||||
public List<PlanReportCaseDTO> selectForPlanReport(List<String> reportIds) {
|
||||
return extApiScenarioReportMapper.selectForPlanReport(reportIds);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user