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时的统计
|
//类型为ui时的统计
|
||||||
if (StringUtils.isNotEmpty(dto.getRunMode()) && dto.getRunMode().startsWith("UI")) {
|
if (StringUtils.isNotEmpty(dto.getRunMode()) && dto.getRunMode().startsWith("UI")) {
|
||||||
try {
|
try {
|
||||||
errorSize = dto.getRequestResults().stream().filter(requestResult ->
|
errorSize = getUiErrorSize(dto);
|
||||||
StringUtils.isNotEmpty(requestResult.getResponseResult().getHeaders())
|
|
||||||
&& JSONArray.parseArray(requestResult.getResponseResult().getHeaders()).stream().filter(
|
|
||||||
r -> ((JSONObject) r).containsKey("success") && !((JSONObject) r).getBoolean("success")
|
|
||||||
).count() > 0)
|
|
||||||
.count();
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// UI 返回的结果在 headers 里面,格式不符合规范的直接认定结果为失败
|
// UI 返回的结果在 headers 里面,格式不符合规范的直接认定结果为失败
|
||||||
errorSize = 1;
|
errorSize = 1;
|
||||||
|
@ -989,6 +984,32 @@ public class ApiScenarioReportService {
|
||||||
return status;
|
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) {
|
public List<PlanReportCaseDTO> selectForPlanReport(List<String> reportIds) {
|
||||||
return extApiScenarioReportMapper.selectForPlanReport(reportIds);
|
return extApiScenarioReportMapper.selectForPlanReport(reportIds);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue