增加测试结果为空时,支持预期结果使用NULL字符匹配

This commit is contained in:
seagull 2020-11-10 20:12:25 +08:00
parent 9256a564af
commit 4ed74b8a48
7 changed files with 37 additions and 2 deletions

View File

@ -21,6 +21,7 @@ import luckyclient.remote.entity.ProjectCaseParams;
import luckyclient.remote.entity.ProjectCaseSteps;
import luckyclient.utils.Constants;
import luckyclient.utils.LogUtil;
import org.apache.commons.lang.StringUtils;
/**
* =================================================================
@ -295,6 +296,10 @@ public class AndroidCaseExecution{
if (expect.equals(result)) {
LogUtil.APP.info("用例:{} 第{}步,精确匹配预期结果成功!执行结果:{}",testcase.getCaseSign(),step.getStepSerialNumber(),result);
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "精确匹配预期结果成功!", "info", String.valueOf(step.getStepSerialNumber()), "");
} else if(expect.trim().equals("NULL")&& StringUtils.isBlank(result)){
result = "返回结果为空匹配NULL成功";
LogUtil.APP.info("用例:{} 第{}步,精确匹配预期结果成功!执行结果:{}",testcase.getCaseSign(),step.getStepSerialNumber(),result);
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "精确匹配预期结果成功!", "info", String.valueOf(step.getStepSerialNumber()), "");
} else {
casenote = "" + step.getStepSerialNumber() + "步,精确匹配预期结果失败!";
setresult = 1;

View File

@ -21,6 +21,7 @@ import luckyclient.remote.entity.ProjectCaseParams;
import luckyclient.remote.entity.ProjectCaseSteps;
import luckyclient.utils.Constants;
import luckyclient.utils.LogUtil;
import org.apache.commons.lang.StringUtils;
/**
* =================================================================
@ -308,6 +309,10 @@ public class IosCaseExecution{
if (expect.equals(result)) {
LogUtil.APP.info("用例:{} 第{}步,精确匹配预期结果成功!执行结果:{}",testcase.getCaseSign(),step.getStepSerialNumber(),result);
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "精确匹配预期结果成功!", "info", String.valueOf(step.getStepSerialNumber()), "");
} else if(expect.trim().equals("NULL")&& StringUtils.isBlank(result)){
result = "返回结果为空匹配NULL成功";
LogUtil.APP.info("用例:{} 第{}步,精确匹配预期结果成功!执行结果:{}",testcase.getCaseSign(),step.getStepSerialNumber(),result);
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "精确匹配预期结果成功!", "info", String.valueOf(step.getStepSerialNumber()), "");
} else {
casenote = "" + step.getStepSerialNumber() + "步,精确匹配预期结果失败!";
setresult = 1;

View File

@ -9,12 +9,14 @@ import java.util.regex.Pattern;
import luckyclient.execution.dispose.ActionManageForSteps;
import luckyclient.execution.httpinterface.analyticsteps.InterfaceAnalyticCase;
import luckyclient.remote.api.GetServerApi;
import luckyclient.remote.api.PostServerApi;
import luckyclient.remote.entity.ProjectCase;
import luckyclient.remote.entity.ProjectCaseParams;
import luckyclient.remote.entity.ProjectCaseSteps;
import luckyclient.utils.InvokeMethod;
import luckyclient.utils.LogUtil;
import luckyclient.utils.httputils.HttpRequest;
import org.apache.commons.lang.StringUtils;
/**
* =================================================================
@ -148,6 +150,10 @@ public class ApiTestCaseDebug {
if (expectedresults.equals(testnote)) {
LogUtil.APP.info(
"用例:{} 第{}步,精确匹配预期结果成功!执行结果:{}",testcase.getCaseSign(),(i+1),testnote);
} else if(expectedresults.trim().equals("NULL")&& StringUtils.isBlank(testnote)){
testnote = "返回结果为空匹配NULL成功";
LogUtil.APP.info(
"用例:{} 第{}步,精确匹配预期结果成功!执行结果:{}",testcase.getCaseSign(),(i+1),testnote);
} else {
setcaseresult = 1;
LogUtil.APP.warn("用例:{} 第{}步,精确匹配预期结果失败!预期结果:{},测试结果:{}",testcase.getCaseSign(),(i+1),expectedresults,testnote);

View File

@ -6,6 +6,7 @@ import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.lang.StringUtils;
import org.openqa.selenium.WebDriver;
import io.appium.java_client.android.AndroidDriver;
@ -382,6 +383,10 @@ public class TestCaseExecution {
if (expectedresults.equals(testnote)) {
LogUtil.APP.info("用例:{} 第{}步,精确匹配预期结果成功!执行结果:{}",testcase.getCaseSign(),step.getStepSerialNumber(),testnote);
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "精确匹配预期结果成功!执行结果:" + testnote, "info", String.valueOf(step.getStepSerialNumber()), "");
} else if(expectedresults.trim().equals("NULL")&& StringUtils.isBlank(testnote)){
testnote = "返回结果为空匹配NULL成功";
LogUtil.APP.info("用例:{} 第{}步,精确匹配预期结果成功!执行结果:{}",testcase.getCaseSign(),step.getStepSerialNumber(),testnote);
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "精确匹配预期结果成功!执行结果:" + testnote, "info", String.valueOf(step.getStepSerialNumber()), "");
} else {
setresult = 1;
LogUtil.APP.warn("用例:{} 第{}步,精确匹配预期结果失败!预期结果:{},测试结果:{}",testcase.getCaseSign(),step.getStepSerialNumber(),expectedresults,testnote);

View File

@ -17,6 +17,7 @@ import luckyclient.remote.entity.ProjectCaseSteps;
import luckyclient.utils.Constants;
import luckyclient.utils.InvokeMethod;
import luckyclient.utils.LogUtil;
import org.apache.commons.lang.StringUtils;
/**
* =================================================================
@ -197,6 +198,10 @@ public class ThreadForExecuteCase extends Thread {
if (expectedresults.equals(testnote)) {
LogUtil.APP.info("用例:{} 第{}步,精确匹配预期结果成功!执行结果:{}",testcase.getCaseSign(),(i+1),testnote);
caselog.insertTaskCaseLog(taskid, caseId, "精确匹配预期结果成功!执行结果:" + testnote, "info", String.valueOf(i + 1), "");
} else if(expectedresults.trim().equals("NULL")&&StringUtils.isBlank(testnote)){
testnote = "返回结果为空匹配NULL成功";
LogUtil.APP.info("用例:{} 第{}步,精确匹配预期结果成功!执行结果:{}",testcase.getCaseSign(),(i+1),testnote);
caselog.insertTaskCaseLog(taskid, caseId, "精确匹配预期结果成功!执行结果:" + testnote, "info", String.valueOf(i + 1), "");
} else {
setcaseresult = 1;
LogUtil.APP.warn("用例:{} 第{}步,精确匹配预期结果失败!预期结果:{},测试结果:{}",testcase.getCaseSign(),(i+1),expectedresults,testnote);

View File

@ -18,6 +18,7 @@ import luckyclient.remote.entity.ProjectCaseSteps;
import luckyclient.utils.Constants;
import luckyclient.utils.InvokeMethod;
import luckyclient.utils.LogUtil;
import org.apache.commons.lang.StringUtils;
/**
* =================================================================
@ -171,6 +172,9 @@ public class WebTestCaseDebug {
else {
if (expectedresults.equals(testnote)) {
PostServerApi.cPostDebugLog(userId, caseId, "INFO", "精确匹配预期结果成功!执行结果:" + testnote,0);
} else if(expectedresults.trim().equals("NULL")&& StringUtils.isBlank(testnote)){
testnote = "返回结果为空匹配NULL成功";
PostServerApi.cPostDebugLog(userId, caseId, "INFO", "精确匹配预期结果成功!执行结果:" + testnote,0);
} else {
setcaseresult = 1;
PostServerApi.cPostDebugLog(userId, caseId, "ERROR", "" + (i + 1) + "步,精确匹配预期结果失败!预期结果:" + expectedresults + ",测试结果:" + testnote,0);

View File

@ -7,6 +7,7 @@ import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.lang.StringUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
@ -311,6 +312,10 @@ public class WebCaseExecution{
if (expect.equals(result)) {
LogUtil.APP.info("用例:{} 第{}步,精确匹配预期结果成功!执行结果:{}",testcase.getCaseSign(),step.getStepSerialNumber(),result);
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "精确匹配预期结果成功!", "info", String.valueOf(step.getStepSerialNumber()), "");
} else if(expect.trim().equals("NULL")&& StringUtils.isBlank(result)){
result = "返回结果为空匹配NULL成功";
LogUtil.APP.info("用例:{} 第{}步,精确匹配预期结果成功!执行结果:{}",testcase.getCaseSign(),step.getStepSerialNumber(),result);
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "精确匹配预期结果成功!", "info", String.valueOf(step.getStepSerialNumber()), "");
} else {
casenote = "" + step.getStepSerialNumber() + "步,精确匹配预期结果失败!";
setresult = 1;