fix(接口测试): 修复请求中包含误报断言和失败断言时最终用例执行结果失败的缺陷

修复请求中包含误报断言和失败断言时最终用例执行结果失败的缺陷
This commit is contained in:
song-tianyang 2022-01-27 11:48:41 +08:00 committed by 刘瑞斌
parent d988fa68db
commit eb45e07cb8
3 changed files with 10 additions and 7 deletions

View File

@ -74,17 +74,17 @@ public class JMeterScriptUtil {
boolean globalPreScriptIsFilter = JMeterScriptUtil.isScriptFilter(preFilterProtocal, protocal);
boolean globalPostScriptIsFilter = JMeterScriptUtil.isScriptFilter(postFilterProtocal, protocal);
if (isAfterPrivateScript) {
if (isPreScriptExecAfterPrivateScript && !globalPreScriptIsFilter) {
if (isPreScriptExecAfterPrivateScript && !globalPreScriptIsFilter && StringUtils.isNotEmpty(preProcessor.getScript())) {
addItemHashTree(preProcessor, samplerHashTree, config, environmentId);
}
if (isPostScriptExecAfterPrivateScript && !globalPostScriptIsFilter) {
if (isPostScriptExecAfterPrivateScript && !globalPostScriptIsFilter && StringUtils.isNotEmpty(postProcessor.getScript())) {
addItemHashTree(postProcessor, samplerHashTree, config, environmentId);
}
} else {
if (!isPreScriptExecAfterPrivateScript && !globalPreScriptIsFilter) {
if (!isPreScriptExecAfterPrivateScript && !globalPreScriptIsFilter && StringUtils.isNotEmpty(preProcessor.getScript())) {
addItemHashTree(preProcessor, samplerHashTree, config, environmentId);
}
if (!isPostScriptExecAfterPrivateScript && !globalPostScriptIsFilter) {
if (!isPostScriptExecAfterPrivateScript && !globalPostScriptIsFilter && StringUtils.isNotEmpty(postProcessor.getScript())) {
addItemHashTree(postProcessor, samplerHashTree, config, environmentId);
}
}

View File

@ -21,12 +21,14 @@ public class ErrorReportLibraryUtil {
if (result != null && result.getResponseResult() != null && CollectionUtils.isNotEmpty(result.getResponseResult().getAssertions())) {
List<ResponseAssertionResult> errorReportAssertionList = new ArrayList<>();
boolean hasOtherErrorAssertion = false;
int otherAssertionCount = 0;
for (ResponseAssertionResult assertion : result.getResponseResult().getAssertions()) {
if (StringUtils.startsWith(assertion.getContent(), ERROR_CODE_START)) {
errorReportAssertionList.add(assertion);
}else {
if(!assertion.isPass()){
hasOtherErrorAssertion = true;
otherAssertionCount ++;
}
}
}
@ -46,7 +48,7 @@ public class ErrorReportLibraryUtil {
if (result.getResponseResult() != null
&& StringUtils.equalsIgnoreCase(result.getResponseResult().getResponseCode(), "200")
&& result.getError() > 0) {
if(!hasOtherErrorAssertion){
if(otherAssertionCount == 0 || !hasOtherErrorAssertion){
result.setError(result.getError() - 1);
}
}

View File

@ -15,11 +15,12 @@ import java.util.Map;
public class ResponseUtil {
public static RequestResultExpandDTO parseByRequestResult(RequestResult requestResult) {
//解析是否含有误报库信息
ErrorReportLibraryParseDTO errorCodeDTO = ErrorReportLibraryUtil.parseAssertions(requestResult);
RequestResultExpandDTO expandDTO = new RequestResultExpandDTO();
BeanUtils.copyBean(expandDTO, requestResult);
//解析是否含有误报库信息
ErrorReportLibraryParseDTO errorCodeDTO = ErrorReportLibraryUtil.parseAssertions(requestResult);
if(CollectionUtils.isNotEmpty(errorCodeDTO.getErrorCodeList())){
Map<String, String> expandMap = new HashMap<>();
expandDTO.setStatus(ExecuteResult.errorReportResult.name());