fix(接口测试): 修复接口含失败断言的请求时环境开启了不匹配的误报导致接口结果应为失败实为成功的缺陷
--bug=1009950 --user=宋天阳 【接口测试】开启误报库后,断言有失败的,但是用例执行结果是通过 https://www.tapd.cn/55049933/s/1099392
This commit is contained in:
parent
35d3330b14
commit
fdc8a8c615
|
@ -28,6 +28,9 @@ public class ScriptFilter {
|
|||
}
|
||||
|
||||
public static void verify(String language, String label, String script) {
|
||||
if(language == null){
|
||||
language = "";
|
||||
}
|
||||
if (StringUtils.isNotEmpty(script)) {
|
||||
final StringBuffer buffer = new StringBuffer();
|
||||
switch (language) {
|
||||
|
|
|
@ -20,9 +20,14 @@ public class ErrorReportLibraryUtil {
|
|||
ErrorReportLibraryParseDTO returnDTO = new ErrorReportLibraryParseDTO();
|
||||
if (result != null && result.getResponseResult() != null && CollectionUtils.isNotEmpty(result.getResponseResult().getAssertions())) {
|
||||
List<ResponseAssertionResult> errorReportAssertionList = new ArrayList<>();
|
||||
boolean hasOtherErrorAssertion = false;
|
||||
for (ResponseAssertionResult assertion : result.getResponseResult().getAssertions()) {
|
||||
if (StringUtils.startsWith(assertion.getContent(), ERROR_CODE_START)) {
|
||||
errorReportAssertionList.add(assertion);
|
||||
}else {
|
||||
if(!assertion.isPass()){
|
||||
hasOtherErrorAssertion = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(errorReportAssertionList)) {
|
||||
|
@ -41,7 +46,9 @@ public class ErrorReportLibraryUtil {
|
|||
if (result.getResponseResult() != null
|
||||
&& StringUtils.equalsIgnoreCase(result.getResponseResult().getResponseCode(), "200")
|
||||
&& result.getError() > 0) {
|
||||
result.setError(result.getError() - 1);
|
||||
if(!hasOtherErrorAssertion){
|
||||
result.setError(result.getError() - 1);
|
||||
}
|
||||
}
|
||||
result.setTotalAssertions(result.getTotalAssertions() - unMatchErrorReportAssertions.size());
|
||||
result.getResponseResult().getAssertions().removeAll(unMatchErrorReportAssertions);
|
||||
|
|
Loading…
Reference in New Issue