fix(接口测试): 修复场景中的自定义请求步骤在某些条件下修改地址,不会覆盖到接口,也不会影响接口覆盖率的问题

--bug=1036522 --user=宋天阳 【接口测试】github#29161,场景用例中步骤的URI与接口定义一致,但接口覆盖率未统计到 https://www.tapd.cn/55049933/s/1468590
This commit is contained in:
song-tianyang 2024-03-04 16:09:36 +08:00 committed by Craftsman
parent 8a2b32b07f
commit a6c5086e8a
1 changed files with 19 additions and 4 deletions

View File

@ -98,10 +98,25 @@ public class ApiScenarioReferenceIdService {
if (item.has(MsHashTreeService.ID) && item.has(MsHashTreeService.REFERENCED)) {
String url = null;
String method;
if (item.has(MsHashTreeService.PATH) && StringUtils.isNotEmpty(MsHashTreeService.PATH)) {
url = item.optString(MsHashTreeService.PATH);
} else if (item.has(MsHashTreeService.URL)) {
url = item.optString(MsHashTreeService.URL);
boolean customizeReq = item.optBoolean("customizeReq");
if (customizeReq) {
/*
判断是否是自定义请求因为自定义请求中针对是否引用环境字段的不同设置 真正的url也会放在不同的字段中
据说这个功能是刚子写的
*/
boolean isRefEnvironment = item.optBoolean("isRefEnvironment");
if (isRefEnvironment) {
url = item.optString(MsHashTreeService.PATH);
} else {
url = item.optString(MsHashTreeService.URL);
}
} else {
if (item.has(MsHashTreeService.PATH) && StringUtils.isNotEmpty(MsHashTreeService.PATH)) {
url = item.optString(MsHashTreeService.PATH);
} else if (item.has(MsHashTreeService.URL)) {
url = item.optString(MsHashTreeService.URL);
}
}
method = this.getMethodFromSample(item);
ApiScenarioReferenceId saveItem = new ApiScenarioReferenceId();