fix(接口测试): 修复场景名称含有特殊字符导致生成测试报告失败问题
--bug=1019538 --user=赵勇 【接口测试】名称包含${,场景无法执行 https://www.tapd.cn/55049933/s/1294446
This commit is contained in:
parent
ad11cc380b
commit
091242bf09
|
@ -16,7 +16,7 @@ public class ExtApiDefinitionExecResultProvider {
|
|||
.append("'")
|
||||
.append(result.getId())
|
||||
.append("','")
|
||||
.append(result.getName().replace("\'", "\\'"))
|
||||
.append(translate(result.getName()))
|
||||
.append("','")
|
||||
.append(result.getResourceId())
|
||||
.append("','")
|
||||
|
@ -50,13 +50,9 @@ public class ExtApiDefinitionExecResultProvider {
|
|||
.append("','")
|
||||
.append(result.getEnvConfig());
|
||||
//判断有没有关联的测试报告ID
|
||||
if (StringUtils.isBlank(result.getRelevanceTestPlanReportId())) {
|
||||
sqlList.append("', null");
|
||||
} else {
|
||||
sqlList.append("','")
|
||||
.append(result.getRelevanceTestPlanReportId())
|
||||
.append(StringUtils.defaultIfBlank(result.getRelevanceTestPlanReportId(), "null"))
|
||||
.append("'");
|
||||
}
|
||||
sqlList.append(")");
|
||||
if (i < list.size() - 1) {
|
||||
sqlList.append(",");
|
||||
|
@ -64,4 +60,12 @@ public class ExtApiDefinitionExecResultProvider {
|
|||
}
|
||||
return sqlList.toString();
|
||||
}
|
||||
|
||||
private String translate(String name) {
|
||||
if (StringUtils.isNotBlank(name)) {
|
||||
name = StringUtils.replace(name, "\'", "\\'");
|
||||
name = StringUtils.replace(name, "${", "$ {");
|
||||
}
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ public class ExtApiScenarioReportProvider {
|
|||
.append("','")
|
||||
.append(result.getProjectId())
|
||||
.append("','")
|
||||
.append(result.getName().replace("\'", "\\'"))
|
||||
.append(translate(result.getName()))
|
||||
.append("',")
|
||||
.append(result.getCreateTime())
|
||||
.append(",")
|
||||
|
@ -32,7 +32,7 @@ public class ExtApiScenarioReportProvider {
|
|||
.append("','")
|
||||
.append(result.getExecuteType())
|
||||
.append("','")
|
||||
.append(result.getScenarioName().replace("\'", "\\'"))
|
||||
.append(translate(result.getScenarioName()))
|
||||
.append("','")
|
||||
.append(result.getScenarioId())
|
||||
.append("','")
|
||||
|
@ -52,13 +52,9 @@ public class ExtApiScenarioReportProvider {
|
|||
.append("','")
|
||||
.append(result.getEnvConfig());
|
||||
//判断有没有关联的测试报告ID
|
||||
if (StringUtils.isBlank(result.getRelevanceTestPlanReportId())) {
|
||||
sqlList.append("', null");
|
||||
} else {
|
||||
sqlList.append("','")
|
||||
.append(result.getRelevanceTestPlanReportId())
|
||||
.append(StringUtils.defaultIfBlank(result.getRelevanceTestPlanReportId(), "null"))
|
||||
.append("'");
|
||||
}
|
||||
sqlList.append(")");
|
||||
if (i < list.size() - 1) {
|
||||
sqlList.append(",");
|
||||
|
@ -66,4 +62,12 @@ public class ExtApiScenarioReportProvider {
|
|||
}
|
||||
return sqlList.toString();
|
||||
}
|
||||
|
||||
private String translate(String name) {
|
||||
if (StringUtils.isNotBlank(name)) {
|
||||
name = StringUtils.replace(name, "\'", "\\'");
|
||||
name = StringUtils.replace(name, "${", "$ {");
|
||||
}
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue