修复全并代码出现的一些问题跟bug,完善功能

This commit is contained in:
seagull 2018-10-24 17:35:27 +08:00
parent 09245a567e
commit ac81c0da5e
14 changed files with 188 additions and 115 deletions

View File

@ -113,8 +113,8 @@ public class AppTestControl {
task = GetServerAPI.cgetTaskbyid(Integer.valueOf(taskid));
TestJobs testJob = task.getTestJob();
String jobname = task.getTestJob().getTaskName();
// 判断是否要自动重启TOMCAT
int[] tastcount = null;
// 判断是否要自动重启TOMCAT
if (restartstatus.indexOf("Status:true") > -1) {
// 判断是否构建是否成功
if (buildstatus.indexOf("Status:true") > -1) {

View File

@ -32,8 +32,6 @@ import luckyclient.publicclass.LogUtil;
*/
public class AndroidCaseExecution extends TestCaseExecution{
static Map<String, String> variable = new HashMap<String, String>();
// 0:成功 1:失败 2:锁定 其他锁定
private static int setresult = 0;
private static String casenote = "备注初始化";
private static String imagname = "";
@ -45,7 +43,8 @@ public class AndroidCaseExecution extends TestCaseExecution{
}
//插入开始执行的用例
caselog.addCaseDetail(taskid, testcase.getSign(), "1", testcase.getName(), 4);
// 0:成功 1:失败 2:锁定 其他锁定
int setcaseresult = 0;
for (ProjectCasesteps step : steps) {
Map<String, String> params;
String result;
@ -58,7 +57,7 @@ public class AndroidCaseExecution extends TestCaseExecution{
}
if(params.get("exception")!=null&&params.get("exception").toString().indexOf("解析异常")>-1){
setresult = 2;
setcaseresult = 2;
break;
}
@ -73,15 +72,22 @@ public class AndroidCaseExecution extends TestCaseExecution{
expectedResults=ChangString.changparams(expectedResults, variable,"预期结果");
// 判断结果
setresult = judgeResult(testcase, step, params, appium, taskid, expectedResults, result, caselog);
if (0 != setresult) {
break;
}
int stepresult = judgeResult(testcase, step, params, appium, taskid, expectedResults, result, caselog);
// 失败并且不在继续,直接终止
if (0 != stepresult) {
setcaseresult = stepresult;
if (testcase.getFailcontinue() == 0) {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcase.getSign()+"】第【"+step.getStepnum()+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
break;
} else {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcase.getSign()+"】第【"+step.getStepnum()+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
}
}
}
variable.clear();
caselog.updateCaseDetail(taskid, testcase.getSign(), setresult);
if(setresult==0){
caselog.updateCaseDetail(taskid, testcase.getSign(), setcaseresult);
if(setcaseresult==0){
luckyclient.publicclass.LogUtil.APP.info("用例【"+testcase.getSign()+"】全部步骤执行结果成功...");
caselog.caseLogDetail(taskid, testcase.getSign(), "用例全部步骤执行结果成功","info", "ending","");
}else{
@ -219,7 +225,7 @@ public class AndroidCaseExecution extends TestCaseExecution{
}
public static int judgeResult(ProjectCase testcase, ProjectCasesteps step, Map<String, String> params, AndroidDriver<AndroidElement> appium, String taskid, String expect, String result, LogOperation caselog) throws InterruptedException {
setresult = 0;
int setresult = 0;
java.text.DateFormat timeformat = new java.text.SimpleDateFormat("MMdd-hhmmss");
imagname = timeformat.format(new Date());

View File

@ -32,8 +32,6 @@ import luckyclient.publicclass.LogUtil;
*/
public class IosCaseExecution extends TestCaseExecution{
static Map<String, String> variable = new HashMap<String, String>();
// 0:成功 1:失败 2:锁定 其他锁定
private static int setresult = 0;
private static String casenote = "备注初始化";
private static String imagname = "";
@ -45,7 +43,8 @@ public class IosCaseExecution extends TestCaseExecution{
}
//插入开始执行的用例
caselog.addCaseDetail(taskid, testcase.getSign(), "1", testcase.getName(), 4);
// 0:成功 1:失败 2:锁定 其他锁定
int setcaseresult = 0;
for (ProjectCasesteps step : steps) {
Map<String, String> params;
String result;
@ -58,7 +57,7 @@ public class IosCaseExecution extends TestCaseExecution{
}
if(params.get("exception")!=null&&params.get("exception").toString().indexOf("解析异常")>-1){
setresult = 2;
setcaseresult = 2;
break;
}
@ -73,16 +72,23 @@ public class IosCaseExecution extends TestCaseExecution{
expectedResults=ChangString.changparams(expectedResults, variable,"预期结果");
// 判断结果
setresult = judgeResult(testcase, step, params, appium, taskid, expectedResults, result, caselog);
if (0 != setresult) {
break;
}
int stepresult = judgeResult(testcase, step, params, appium, taskid, expectedResults, result, caselog);
// 失败并且不在继续,直接终止
if (0 != stepresult) {
setcaseresult = stepresult;
if (testcase.getFailcontinue() == 0) {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcase.getSign()+"】第【"+step.getStepnum()+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
break;
} else {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcase.getSign()+"】第【"+step.getStepnum()+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
}
}
}
variable.clear();
caselog.updateCaseDetail(taskid, testcase.getSign(), setresult);
if(setresult==0){
caselog.updateCaseDetail(taskid, testcase.getSign(), setcaseresult);
if(setcaseresult==0){
luckyclient.publicclass.LogUtil.APP.info("用例【"+testcase.getSign()+"】全部步骤执行结果成功...");
caselog.caseLogDetail(taskid, testcase.getSign(), "用例全部步骤执行结果成功","info", "ending","");
}else{
@ -226,7 +232,7 @@ public class IosCaseExecution extends TestCaseExecution{
}
public static int judgeResult(ProjectCase testcase, ProjectCasesteps step, Map<String, String> params, IOSDriver<IOSElement> appium, String taskid, String expect, String result, LogOperation caselog) throws InterruptedException {
setresult = 0;
int setresult = 0;
java.text.DateFormat timeformat = new java.text.SimpleDateFormat("MMdd-hhmmss");
imagname = timeformat.format(new Date());
if (null != result && !result.contains("步骤执行失败:")) {

View File

@ -44,7 +44,7 @@ public class ApiTestCaseDebug {
String packagename = null;
String functionname = null;
String expectedresults = null;
Integer setresult = 1;
Integer setcaseresult = 0;
Object[] getParameterValues = null;
String testnote = "初始化测试结果";
int k = 0;
@ -56,7 +56,7 @@ public class ApiTestCaseDebug {
}
List<ProjectCasesteps> steps = GetServerAPI.getStepsbycaseid(testcaseob.getId());
if (steps.size() == 0) {
setresult = 2;
setcaseresult = 2;
luckyclient.publicclass.LogUtil.APP.error("用例中未找到步骤,请检查!");
testnote = "用例中未找到步骤,请检查!";
}
@ -121,16 +121,20 @@ public class ApiTestCaseDebug {
else if (expectedresults.length() > FUZZY_MATCHING_SIGN.length()
&& expectedresults.startsWith(FUZZY_MATCHING_SIGN)) {
if (testnote.contains(expectedresults.substring(FUZZY_MATCHING_SIGN.length()))) {
setresult = 0;
luckyclient.publicclass.LogUtil.APP.info(
"用例:" + testcaseob.getSign() + "" + (i + 1) + "步,模糊匹配预期结果成功!执行结果:" + testnote);
} else {
setresult = 1;
setcaseresult = 1;
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcaseob.getSign() + "" + (i + 1)
+ "步,模糊匹配预期结果失败!预期结果:" + expectedresults.substring(FUZZY_MATCHING_SIGN.length())
+ ",测试结果:" + testnote);
testnote = "用例第" + (i + 1) + "步,模糊匹配预期结果失败!";
break; // 某一步骤失败后此条用例置为失败退出
if (testcaseob.getFailcontinue() == 0) {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
break;
} else {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
}
}
}
// 正则匹配
@ -139,30 +143,38 @@ public class ApiTestCaseDebug {
Pattern pattern = Pattern.compile(expectedresults.substring(REGULAR_MATCHING_SIGN.length()));
Matcher matcher = pattern.matcher(testnote);
if (matcher.find()) {
setresult = 0;
luckyclient.publicclass.LogUtil.APP.info(
"用例:" + testcaseob.getSign() + "" + (i + 1) + "步,正则匹配预期结果成功!执行结果:" + testnote);
} else {
setresult = 1;
setcaseresult = 1;
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcaseob.getSign() + "" + (i + 1)
+ "步,正则匹配预期结果失败!预期结果:" + expectedresults.substring(REGULAR_MATCHING_SIGN.length())
+ ",测试结果:" + testnote);
testnote = "用例第" + (i + 1) + "步,正则匹配预期结果失败!";
break; // 某一步骤失败后此条用例置为失败退出
if (testcaseob.getFailcontinue() == 0) {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
break;
} else {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
}
}
}
// 完全相等
else {
if (expectedresults.equals(testnote)) {
setresult = 0;
luckyclient.publicclass.LogUtil.APP.info(
"用例:" + testcaseob.getSign() + "" + (i + 1) + "步,精确匹配预期结果成功!执行结果:" + testnote);
} else {
setresult = 1;
setcaseresult = 1;
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcaseob.getSign() + "" + (i + 1)
+ "步,精确匹配预期结果失败!预期结果:" + expectedresults + ",测试结果:" + testnote);
testnote = "用例第" + (i + 1) + "步,精确匹配预期结果失败!";
break; // 某一步骤失败后此条用例置为失败退出
if (testcaseob.getFailcontinue() == 0) {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
break;
} else {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
}
}
}
}
@ -172,12 +184,17 @@ public class ApiTestCaseDebug {
Thread.sleep(waitsec * 1000);
}
} catch (Exception e) {
setresult = 1;
setcaseresult = 1;
luckyclient.publicclass.LogUtil.APP.error("调用方法过程出错,方法名:" + functionname + " 请重新检查脚本方法名称以及参数!");
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
testnote = "CallCase调用出错";
e.printStackTrace();
break;
if (testcaseob.getFailcontinue() == 0) {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
break;
} else {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
}
}
}
variable.clear(); // 清空传参MAP
@ -187,7 +204,7 @@ public class ApiTestCaseDebug {
} else {
luckyclient.publicclass.LogUtil.APP.error("用例 " + testCaseExternalId + "解析或是调用步骤中的方法出错!");
}
if (0 == setresult) {
if (0 == setcaseresult) {
luckyclient.publicclass.LogUtil.APP.info("用例 " + testCaseExternalId + "步骤全部执行成功!");
} else {
luckyclient.publicclass.LogUtil.APP.error("用例 " + testCaseExternalId + "在执行过程中失败,请检查日志!");

View File

@ -59,7 +59,7 @@ public class TestCaseExecution {
String packagename = null;
String functionname = null;
String expectedresults = null;
Integer setresult = 1;
Integer setcaseresult = 0;
Object[] getParameterValues = null;
String testnote = "初始化测试结果";
int k = 0;
@ -73,7 +73,7 @@ public class TestCaseExecution {
}
List<ProjectCasesteps> steps = GetServerAPI.getStepsbycaseid(testcaseob.getId());
if (steps.size() == 0) {
setresult = 2;
setcaseresult = 2;
luckyclient.publicclass.LogUtil.APP.error("用例中未找到步骤,请检查!");
LogOperation.updateCaseLogDetail(testCaseExternalId, taskid, "用例中未找到步骤,请检查!", "error", "1");
testnote = "用例中未找到步骤,请检查!";
@ -137,13 +137,17 @@ public class TestCaseExecution {
// 模糊匹配
else if (expectedresults.length() > FUZZY_MATCHING_SIGN.length() && expectedresults.startsWith(FUZZY_MATCHING_SIGN)) {
if (testnote.contains(expectedresults.substring(FUZZY_MATCHING_SIGN.length()))) {
setresult = 0;
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcaseob.getSign() + "" + (i + 1) + "步,模糊匹配预期结果成功!执行结果:" + testnote);
} else {
setresult = 1;
setcaseresult = 1;
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcaseob.getSign() + "" + (i + 1) + "步,模糊匹配预期结果失败!预期结果:" + expectedresults.substring(FUZZY_MATCHING_SIGN.length()) + ",测试结果:" + testnote);
testnote = "用例第" + (i + 1) + "步,模糊匹配预期结果失败!";
break; // 某一步骤失败后此条用例置为失败退出
if (testcaseob.getFailcontinue() == 0) {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
break;
} else {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
}
}
}
// 正则匹配
@ -151,25 +155,33 @@ public class TestCaseExecution {
Pattern pattern = Pattern.compile(expectedresults.substring(REGULAR_MATCHING_SIGN.length()));
Matcher matcher = pattern.matcher(testnote);
if (matcher.find()) {
setresult = 0;
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcaseob.getSign() + "" + (i + 1) + "步,正则匹配预期结果成功!执行结果:" + testnote);
} else {
setresult = 1;
setcaseresult = 1;
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcaseob.getSign() + "" + (i + 1) + "步,正则匹配预期结果失败!预期结果:" + expectedresults.substring(REGULAR_MATCHING_SIGN.length()) + ",测试结果:" + testnote);
testnote = "用例第" + (i + 1) + "步,正则匹配预期结果失败!";
break; // 某一步骤失败后此条用例置为失败退出
if (testcaseob.getFailcontinue() == 0) {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
break;
} else {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
}
}
}
// 完全相等
else {
if (expectedresults.equals(testnote)) {
setresult = 0;
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcaseob.getSign() + "" + (i + 1) + "步,精确匹配预期结果成功!执行结果:" + testnote);
} else {
setresult = 1;
setcaseresult = 1;
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcaseob.getSign() + "" + (i + 1) + "步,精确匹配预期结果失败!预期结果:" + expectedresults + ",测试结果:" + testnote);
testnote = "用例第" + (i + 1) + "步,精确匹配预期结果失败!";
break; // 某一步骤失败后此条用例置为失败退出
if (testcaseob.getFailcontinue() == 0) {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
break;
} else {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
}
}
}
}
@ -184,9 +196,14 @@ public class TestCaseExecution {
LogOperation.updateCaseLogDetail(testCaseExternalId, taskid, "调用方法过程出错,方法名:" + functionname + " 请重新检查脚本方法名称以及参数!", "error", String.valueOf(i + 1));
luckyclient.publicclass.LogUtil.ERROR.error(e, e);
testnote = "CallCase调用出错";
setresult = 1;
setcaseresult = 1;
e.printStackTrace();
break;
if (testcaseob.getFailcontinue() == 0) {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
break;
} else {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
}
}
}
variable.clear(); // 清空传参MAP
@ -194,14 +211,14 @@ public class TestCaseExecution {
if (!testnote.contains("CallCase调用出错") && !testnote.contains("解析出错啦!")) {
luckyclient.publicclass.LogUtil.APP.info("用例 " + testCaseExternalId + "解析成功,并成功调用用例中方法,请继续查看执行结果!");
LogOperation.updateCaseLogDetail(testCaseExternalId, taskid, "解析成功,并成功调用用例中方法,请继续查看执行结果!", "info", "SETCASERESULT...");
caselog.updateCaseDetail(taskid, testCaseExternalId, setresult);
caselog.updateCaseDetail(taskid, testCaseExternalId, setcaseresult);
} else {
setresult = 1;
setcaseresult = 1;
luckyclient.publicclass.LogUtil.APP.error("用例 " + testCaseExternalId + "解析或是调用步骤中的方法出错!");
LogOperation.updateCaseLogDetail(testCaseExternalId, taskid, "解析或是调用步骤中的方法出错!", "error", "SETCASERESULT...");
caselog.updateCaseDetail(taskid, testCaseExternalId, 2);
}
if (0 == setresult) {
if (0 == setcaseresult) {
luckyclient.publicclass.LogUtil.APP.info("用例 " + testCaseExternalId + "步骤全部执行成功!");
LogOperation.updateCaseLogDetail(testCaseExternalId, taskid, "步骤全部执行成功!", "info", "EXECUTECASESUC...");
} else {

View File

@ -137,11 +137,11 @@ public class TestControl {
String projectname=task.getTestJob().getPlanproj();
int timeout = task.getTestJob().getTimeout();
TestJobs testJob = task.getTestJob();
int[] tastcount=null;
List<PublicCaseParams> pcplist=GetServerAPI.cgetParamsByProjectid(task.getTestJob().getProjectid().toString());
// 初始化写用例结果以及日志模块
LogOperation caselog = new LogOperation();
// 判断是否要自动重启TOMCAT
int[] tastcount=null;
if (restartstatus.indexOf("Status:true") > -1) {
// 判断是否构建是否成功
if (buildstatus.indexOf("Status:true") > -1) {

View File

@ -57,7 +57,7 @@ public class ThreadForExecuteCase extends Thread {
String functionname = null;
String packagename = null;
String expectedresults = null;
Integer setresult = 1;
Integer setcaseresult = 0;
Object[] getParameterValues = null;
String testnote = "初始化测试结果";
int k = 0;
@ -123,15 +123,19 @@ public class ThreadForExecuteCase extends Thread {
// 模糊匹配
else if (expectedresults.length() > FUZZY_MATCHING_SIGN.length() && expectedresults.startsWith(FUZZY_MATCHING_SIGN)) {
if (testnote.contains(expectedresults.substring(FUZZY_MATCHING_SIGN.length()))) {
setresult = 0;
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcaseob.getSign() + "" + (i + 1) + "步,模糊匹配预期结果成功!执行结果:" + testnote);
caselog.caseLogDetail(taskid, caseid, "模糊匹配预期结果成功!执行结果:" + testnote, "info", String.valueOf(i + 1), "");
} else {
setresult = 1;
setcaseresult = 1;
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcaseob.getSign() + "" + (i + 1) + "步,模糊匹配预期结果失败!预期结果:" + expectedresults.substring(FUZZY_MATCHING_SIGN.length()) + ",测试结果:" + testnote);
caselog.caseLogDetail(taskid, caseid, "" + (i + 1) + "步,模糊匹配预期结果失败!预期结果:" + expectedresults.substring(FUZZY_MATCHING_SIGN.length()) + ",测试结果:" + testnote, "error", String.valueOf(i + 1), "");
testnote = "用例第" + (i + 1) + "步,模糊匹配预期结果失败!";
break; // 某一步骤失败后此条用例置为失败退出
if (testcaseob.getFailcontinue() == 0) {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
break;
} else {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
}
}
}
// 正则匹配
@ -139,29 +143,37 @@ public class ThreadForExecuteCase extends Thread {
Pattern pattern = Pattern.compile(expectedresults.substring(REGULAR_MATCHING_SIGN.length()));
Matcher matcher = pattern.matcher(testnote);
if (matcher.find()) {
setresult = 0;
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcaseob.getSign() + "" + (i + 1) + "步,正则匹配预期结果成功!执行结果:" + testnote);
caselog.caseLogDetail(taskid, caseid, "正则匹配预期结果成功!执行结果:" + testnote, "info", String.valueOf(i + 1), "");
} else {
setresult = 1;
setcaseresult = 1;
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcaseob.getSign() + "" + (i + 1) + "步,正则匹配预期结果失败!预期结果:" + expectedresults.substring(REGULAR_MATCHING_SIGN.length()) + ",测试结果:" + testnote);
caselog.caseLogDetail(taskid, caseid, "" + (i + 1) + "步,正则匹配预期结果失败!预期结果:" + expectedresults.substring(REGULAR_MATCHING_SIGN.length()) + ",测试结果:" + testnote, "error", String.valueOf(i + 1), "");
testnote = "用例第" + (i + 1) + "步,正则匹配预期结果失败!";
break; // 某一步骤失败后此条用例置为失败退出
if (testcaseob.getFailcontinue() == 0) {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
break;
} else {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
}
}
}
// 完全相等
else {
if (expectedresults.equals(testnote)) {
setresult = 0;
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcaseob.getSign() + "" + (i + 1) + "步,精确匹配预期结果成功!执行结果:" + testnote);
caselog.caseLogDetail(taskid, caseid, "精确匹配预期结果成功!执行结果:" + testnote, "info", String.valueOf(i + 1), "");
} else {
setresult = 1;
setcaseresult = 1;
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcaseob.getSign() + "" + (i + 1) + "步,精确匹配预期结果失败!预期结果:" + expectedresults + ",测试结果:" + testnote);
caselog.caseLogDetail(taskid, caseid, "" + (i + 1) + "步,精确匹配预期结果失败!预期结果:" + expectedresults + ",测试结果:" + testnote, "error", String.valueOf(i + 1), "");
testnote = "用例第" + (i + 1) + "步,精确匹配预期结果失败!";
break; // 某一步骤失败后此条用例置为失败退出
if (testcaseob.getFailcontinue() == 0) {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
break;
} else {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
}
}
}
}
@ -176,28 +188,33 @@ public class ThreadForExecuteCase extends Thread {
caselog.caseLogDetail(taskid, caseid, "调用方法过程出错,方法名:" + functionname + " 请重新检查脚本方法名称以及参数!", "error", String.valueOf(i + 1), "");
luckyclient.publicclass.LogUtil.ERROR.error(e, e);
testnote = "CallCase调用出错调用方法过程出错方法名" + functionname + " 请重新检查脚本方法名称以及参数!";
setresult = 1;
setcaseresult = 1;
e.printStackTrace();
break;
if (testcaseob.getFailcontinue() == 0) {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
break;
} else {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
}
}
}
// 如果调用方法过程中未出错进入设置测试结果流程
try {
// 成功跟失败的用例走此流程
if (!testnote.contains("CallCase调用出错") && !testnote.contains("解析出错啦!")) {
caselog.updateCaseDetail(taskid, caseid, setresult);
caselog.updateCaseDetail(taskid, caseid, setcaseresult);
} else {
// 解析用例或是调用方法出错全部把用例置为锁定
luckyclient.publicclass.LogUtil.ERROR.error("用例:" + testcaseob.getSign() + "设置执行结果为锁定,请参考错误日志查找锁定用例的原因.....");
caselog.caseLogDetail(taskid, caseid, "设置执行结果为锁定,请参考错误日志查找锁定用例的原因.....","error", "SETCASERESULT...", "");
setresult = 2;
caselog.updateCaseDetail(taskid, caseid, setresult);
setcaseresult = 2;
caselog.updateCaseDetail(taskid, caseid, setcaseresult);
}
if (0 == setresult) {
if (0 == setcaseresult) {
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcaseob.getSign() + "执行结果成功......");
caselog.caseLogDetail(taskid, caseid, "用例步骤执行全部成功......", "info", "ending", "");
luckyclient.publicclass.LogUtil.APP.info("*********用例【" + testcaseob.getSign() + "】执行完成,测试结果:成功*********");
} else if (1 == setresult) {
} else if (1 == setcaseresult) {
luckyclient.publicclass.LogUtil.ERROR.error("用例:" + testcaseob.getSign() + "执行结果失败......");
caselog.caseLogDetail(taskid, caseid, "用例执行结果失败......", "error", "ending", "");
luckyclient.publicclass.LogUtil.APP.info("*********用例【" + testcaseob.getSign() + "】执行完成,测试结果:失败*********");

View File

@ -40,7 +40,7 @@ public class WebTestCaseDebug {
String packagename = null;
String functionname = null;
String expectedresults = null;
Integer setresult = 1;
Integer setcaseresult = 0;
Object[] getParameterValues = null;
String testnote = "初始化测试结果";
int k = 0;
@ -106,13 +106,17 @@ public class WebTestCaseDebug {
// 模糊匹配
else if (expectedresults.length() > FUZZY_MATCHING_SIGN.length() && expectedresults.startsWith(FUZZY_MATCHING_SIGN)) {
if (testnote.contains(expectedresults.substring(FUZZY_MATCHING_SIGN.length()))) {
setresult = 0;
GetServerAPI.cPostDebugLog(sign, executor, "INFO", "模糊匹配预期结果成功!执行结果:" + testnote);
} else {
setresult = 1;
setcaseresult = 1;
GetServerAPI.cPostDebugLog(sign, executor, "ERROR", "" + (i + 1) + "步,模糊匹配预期结果失败!预期结果:" + expectedresults.substring(FUZZY_MATCHING_SIGN.length()) + ",测试结果:" + testnote);
testnote = "用例第" + (i + 1) + "步,模糊匹配预期结果失败!";
break; // 某一步骤失败后此条用例置为失败退出
if (testcaseob.getFailcontinue() == 0) {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
break;
} else {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
}
}
}
// 正则匹配
@ -120,25 +124,33 @@ public class WebTestCaseDebug {
Pattern pattern = Pattern.compile(expectedresults.substring(REGULAR_MATCHING_SIGN.length()));
Matcher matcher = pattern.matcher(testnote);
if (matcher.find()) {
setresult = 0;
GetServerAPI.cPostDebugLog(sign, executor, "INFO", "正则匹配预期结果成功!执行结果:" + testnote);
} else {
setresult = 1;
setcaseresult = 1;
GetServerAPI.cPostDebugLog(sign, executor, "ERROR", "" + (i + 1) + "步,正则匹配预期结果失败!预期结果:" + expectedresults.substring(REGULAR_MATCHING_SIGN.length()) + ",测试结果:" + testnote);
testnote = "用例第" + (i + 1) + "步,正则匹配预期结果失败!";
break; // 某一步骤失败后此条用例置为失败退出
if (testcaseob.getFailcontinue() == 0) {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
break;
} else {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
}
}
}
// 完全相等
else {
if (expectedresults.equals(testnote)) {
setresult = 0;
GetServerAPI.cPostDebugLog(sign, executor, "INFO", "精确匹配预期结果成功!执行结果:" + testnote);
} else {
setresult = 1;
setcaseresult = 1;
GetServerAPI.cPostDebugLog(sign, executor, "ERROR", "" + (i + 1) + "步,精确匹配预期结果失败!预期结果:" + expectedresults + ",测试结果:" + testnote);
testnote = "用例第" + (i + 1) + "步,精确匹配预期结果失败!";
break; // 某一步骤失败后此条用例置为失败退出
if (testcaseob.getFailcontinue() == 0) {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
break;
} else {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
}
}
}
}
@ -148,11 +160,16 @@ public class WebTestCaseDebug {
Thread.sleep(waitsec * 1000);
}
} catch (Exception e) {
setresult = 1;
setcaseresult = 1;
GetServerAPI.cPostDebugLog(sign, executor, "ERROR", "调用方法过程出错,方法名:" + functionname + " 请重新检查脚本方法名称以及参数!");
testnote = "CallCase调用出错";
e.printStackTrace();
break;
if (testcaseob.getFailcontinue() == 0) {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
break;
} else {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
}
}
}
variable.clear(); //清空传参MAP
@ -162,7 +179,7 @@ public class WebTestCaseDebug {
} else {
GetServerAPI.cPostDebugLog(sign, executor, "ERRORover", "用例 " + sign + "解析或是调用步骤中的方法出错!");
}
if (0 == setresult) {
if (0 == setcaseresult) {
GetServerAPI.cPostDebugLog(sign, executor, "INFOover", "用例 " + sign + "步骤全部执行成功!");
} else {
GetServerAPI.cPostDebugLog(sign, executor, "ERRORover", "用例 " + sign + "在执行过程中失败,请检查!");

View File

@ -94,8 +94,8 @@ public class WebTestControl{
String jobname = task.getTestJob().getTaskName();
int drivertype = LogOperation.querydrivertype(taskid);
TestJobs testJob = task.getTestJob();
// 判断是否要自动重启TOMCAT
int[] tastcount=null;
// 判断是否要自动重启TOMCAT
if (restartstatus.indexOf("Status:true") > -1) {
// 判断是否构建是否成功
if (buildstatus.indexOf("Status:true") > -1) {

View File

@ -33,8 +33,6 @@ import java.util.regex.Pattern;
*/
public class WebCaseExecution extends TestCaseExecution {
private static Map<String, String> variable = new HashMap<>();
// 0:成功 1:失败 2:锁定 其他锁定
private static int setresult = 0;
private static String casenote = "备注初始化";
private static String imagname = "";
@ -45,7 +43,8 @@ public class WebCaseExecution extends TestCaseExecution {
}
//插入开始执行的用例
caselog.addCaseDetail(taskid, testcase.getSign(), "1", testcase.getName(), 4);
// 0:成功 1:失败 2:锁定 其他锁定
int setcaseresult = 0;
for (ProjectCasesteps step : steps) {
Map<String, String> params;
String result;
@ -59,7 +58,7 @@ public class WebCaseExecution extends TestCaseExecution {
// 判断分析步骤参数是否有异常
if (null != params.get("exception") && params.get("exception").contains("解析异常")) {
setresult = 2;
setcaseresult = 2;
break;
}
@ -74,21 +73,22 @@ public class WebCaseExecution extends TestCaseExecution {
expectedResults = ChangString.changparams(expectedResults, variable, "预期结果");
// 判断结果
setresult = judgeResult(testcase, step, params, wd, taskid, expectedResults, result, caselog);
int stepresult = judgeResult(testcase, step, params, wd, taskid, expectedResults, result, caselog);
// 失败并且不在继续,直接终止
if (0 != setresult) {
if (step.getFailcontinue() == 0) {
luckyclient.publicclass.LogUtil.APP.error("用例【" + testcase.getSign() + "】步骤【" + step.getOperation() + "】执行过程中失败!本次步骤设置为了失败就终止:" + step.getFailcontinue());
if (0 != stepresult) {
setcaseresult = stepresult;
if (testcase.getFailcontinue() == 0) {
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcase.getSign()+"】第【"+step.getStepnum()+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
break;
} else {
luckyclient.publicclass.LogUtil.APP.error("用例【" + testcase.getSign() + "】步骤【" + step.getOperation() + "】执行过程中失败!本次步骤设置为了失败就继续:" + step.getFailcontinue());
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcase.getSign()+"】第【"+step.getStepnum()+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
}
}
}
variable.clear();
caselog.updateCaseDetail(taskid, testcase.getSign(), setresult);
if (setresult == 0) {
caselog.updateCaseDetail(taskid, testcase.getSign(), setcaseresult);
if (setcaseresult == 0) {
luckyclient.publicclass.LogUtil.APP.info("用例【" + testcase.getSign() + "】全部步骤执行结果成功...");
caselog.caseLogDetail(taskid, testcase.getSign(), "用例全部步骤执行结果成功", "info", "ending", "");
} else {
@ -221,7 +221,7 @@ public class WebCaseExecution extends TestCaseExecution {
}
public static int judgeResult(ProjectCase testcase, ProjectCasesteps step, Map<String, String> params, WebDriver driver, String taskid, String expect, String result, LogOperation caselog) throws InterruptedException {
setresult = 0;
int setresult = 0;
java.text.DateFormat timeformat = new java.text.SimpleDateFormat("MMdd-hhmmss");
imagname = timeformat.format(new Date());

View File

@ -24,13 +24,13 @@ public class MailSendInitialization {
} else {
if (taskCount.length == 5 && null != testJob) {
Integer sendCondition = testJob.getSendCondition();
// 成功了发送, casecount != casesuc
// 用例全部成功了发送, casecount != casesuc
if (1 == sendCondition) {
if (taskCount[0] == taskCount[1]) {
isSend = true;
}
}
// 失败了发送
// 用例部分失败了发送
if (-1 == sendCondition) {
if (taskCount[2] > 0) {
isSend = true;

View File

@ -30,7 +30,8 @@ public class ProjectCase implements java.io.Serializable{
private String operationer;
private int priority;
private int checktype;
// 失败了是否继续
private Integer failcontinue;
public String getModulename() {
return modulename;
@ -116,6 +117,11 @@ public class ProjectCase implements java.io.Serializable{
public void setOperationer(String operationer) {
this.operationer = operationer;
}
public Integer getFailcontinue() {
return failcontinue;
}
public void setFailcontinue(Integer failcontinue) {
this.failcontinue = failcontinue;
}
}

View File

@ -29,8 +29,7 @@ public class ProjectCasesteps implements java.io.Serializable{
private String time;
private String operationer;
private String remark;
// 失败了是否继续
private Integer failcontinue;
public int getId() {
return id;
}
@ -110,12 +109,4 @@ public class ProjectCasesteps implements java.io.Serializable{
public void setRemark(String remark) {
this.remark = remark;
}
public Integer getFailcontinue() {
return failcontinue;
}
public void setFailcontinue(Integer failcontinue) {
this.failcontinue = failcontinue;
}
}

View File

@ -12,10 +12,6 @@ package luckyclient.planapi.entity;
*
*/
public class TestJobs implements java.io.Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private int id;
private String taskName;