!34 新增功能【聚合计划】,可以将多个测试计划聚合起来一次执行

Merge pull request !34 from Jerel/feature20220125
This commit is contained in:
seagull 2022-01-25 11:20:57 +00:00 committed by Gitee
commit 26ef98bfd3
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
24 changed files with 621 additions and 352 deletions

View File

@ -16,11 +16,7 @@ import luckyclient.execution.appium.iosex.IosCaseExecution;
import luckyclient.execution.httpinterface.TestControl; import luckyclient.execution.httpinterface.TestControl;
import luckyclient.remote.api.GetServerApi; import luckyclient.remote.api.GetServerApi;
import luckyclient.remote.api.serverOperation; import luckyclient.remote.api.serverOperation;
import luckyclient.remote.entity.ProjectCase; import luckyclient.remote.entity.*;
import luckyclient.remote.entity.ProjectCaseParams;
import luckyclient.remote.entity.ProjectCaseSteps;
import luckyclient.remote.entity.TaskExecute;
import luckyclient.remote.entity.TaskScheduling;
import luckyclient.tool.jenkins.BuildingInitialization; import luckyclient.tool.jenkins.BuildingInitialization;
import luckyclient.tool.mail.HtmlMail; import luckyclient.tool.mail.HtmlMail;
import luckyclient.tool.mail.MailSendInitialization; import luckyclient.tool.mail.MailSendInitialization;
@ -80,9 +76,9 @@ public class AppTestControl {
LogUtil.APP.info("开始执行计划中的第{}条用例:【{}】......",i,testcase.getCaseSign()); LogUtil.APP.info("开始执行计划中的第{}条用例:【{}】......",i,testcase.getCaseSign());
try { try {
if ("Android".equals(properties.getProperty("platformName"))) { if ("Android".equals(properties.getProperty("platformName"))) {
AndroidCaseExecution.caseExcution(testcase, steps, taskid, androiddriver, caselog, pcplist); AndroidCaseExecution.caseExcution(testcase, steps, taskid,null, androiddriver, caselog, pcplist);
} else if ("IOS".equals(properties.getProperty("platformName"))) { } else if ("IOS".equals(properties.getProperty("platformName"))) {
IosCaseExecution.caseExcution(testcase, steps, taskid, iosdriver, caselog, pcplist); IosCaseExecution.caseExcution(testcase, steps, taskid, null,iosdriver, caselog, pcplist);
} }
} catch (Exception e) { } catch (Exception e) {
LogUtil.APP.error("用户执行过程中抛出Exception异常", e); LogUtil.APP.error("用户执行过程中抛出Exception异常", e);
@ -127,6 +123,28 @@ public class AppTestControl {
if (restartstatus.contains("Status:true")) { if (restartstatus.contains("Status:true")) {
// 判断是否构建是否成功 // 判断是否构建是否成功
if (BuildResult.SUCCESS.equals(buildResult)) { if (BuildResult.SUCCESS.equals(buildResult)) {
List<ProjectPlan> plans=new ArrayList<>();
// 单计划执行
if(taskScheduling.getPlanType()==1){
ProjectPlan projectPlan=new ProjectPlan();
projectPlan.setPlanId(taskScheduling.getPlanId());
plans.add(projectPlan);
}
// 聚合多计划执行
else if(taskScheduling.getPlanType()==2){
plans.addAll(GetServerApi.getPlansbysuiteId(taskScheduling.getSuiteId()));
}
LogUtil.APP.info("当前测试任务 {} 中共有【{}】条测试计划...",task.getTaskName(),plans.size());
int caseCount=0;
for(ProjectPlan pp:plans){
List<ProjectCase> cases = GetServerApi.getCasesbyplanId(pp.getPlanId());
caseCount+=cases.size();
}
for(ProjectPlan pp:plans){
try { try {
if ("Android".equals(properties.getProperty("platformName"))) { if ("Android".equals(properties.getProperty("platformName"))) {
androiddriver = AppiumInitialization.setAndroidAppium(properties); androiddriver = AppiumInitialization.setAndroidAppium(properties);
@ -139,9 +157,9 @@ public class AppTestControl {
LogUtil.APP.error("初始化AppiumDriver出错 APPIUM Server【http://{}/wd/hub】",properties.getProperty("appiumsever"), e); LogUtil.APP.error("初始化AppiumDriver出错 APPIUM Server【http://{}/wd/hub】",properties.getProperty("appiumsever"), e);
} }
serverOperation caselog = new serverOperation(); serverOperation caselog = new serverOperation();
List<ProjectCase> cases = GetServerApi.getCasesbyplanId(taskScheduling.getPlanId()); List<ProjectCase> cases = GetServerApi.getCasesbyplanId(pp.getPlanId());
LogUtil.APP.info("当前计划【{}】中共有【{}】条待测试用例...",task.getTaskName(),cases.size()); LogUtil.APP.info("当前计划【{}】中共有【{}】条待测试用例...",pp.getPlanName(),cases.size());
serverOperation.updateTaskExecuteStatusIng(taskId, cases.size()); serverOperation.updateTaskExecuteStatusIng(taskId, caseCount);
int i = 0; int i = 0;
for (ProjectCase testcase : cases) { for (ProjectCase testcase : cases) {
i++; i++;
@ -152,23 +170,18 @@ public class AppTestControl {
} }
try { try {
//插入开始执行的用例 //插入开始执行的用例
caselog.insertTaskCaseExecute(taskId, taskScheduling.getProjectId(),testcase.getCaseId(),testcase.getCaseSign(), testcase.getCaseName(), 4); caselog.insertTaskCaseExecute(taskId, taskScheduling.getProjectId(),pp.getPlanId(),testcase.getCaseId(),testcase.getCaseSign(), testcase.getCaseName(), 4);
if ("Android".equals(properties.getProperty("platformName"))) { if ("Android".equals(properties.getProperty("platformName"))) {
AndroidCaseExecution.caseExcution(testcase, steps, taskId, androiddriver, caselog, pcplist); AndroidCaseExecution.caseExcution(testcase, steps, taskId, pp.getPlanId(),androiddriver, caselog, pcplist);
} else if ("IOS".equals(properties.getProperty("platformName"))) { } else if ("IOS".equals(properties.getProperty("platformName"))) {
IosCaseExecution.caseExcution(testcase, steps, taskId, iosdriver, caselog, pcplist); IosCaseExecution.caseExcution(testcase, steps, taskId, pp.getPlanId(),iosdriver, caselog, pcplist);
} }
} catch (Exception e) { } catch (Exception e) {
LogUtil.APP.error("用户执行过程中抛出异常!", e); LogUtil.APP.error("用户执行过程中抛出异常!", e);
} }
LogUtil.APP.info("当前用例:【{}】执行完成......进入下一条",testcase.getCaseSign()); LogUtil.APP.info("当前用例:【{}】执行完成......进入下一条",testcase.getCaseSign());
} }
tastcount = serverOperation.updateTaskExecuteData(taskId, cases.size(),2); LogUtil.APP.info("当前【{}】测试计划中的用例已经全部执行完成...",pp.getPlanName());
String testtime = serverOperation.getTestTime(taskId);
LogUtil.APP.info("当前项目【{}】测试计划中的用例已经全部执行完成...",projectname);
MailSendInitialization.sendMailInitialization(HtmlMail.htmlSubjectFormat(jobname),
HtmlMail.htmlContentFormat(tastcount, taskId, buildResult.toString(), restartstatus, testtime, jobname),
taskId, taskScheduling, tastcount,testtime,buildResult.toString(),restartstatus);
// 关闭APP以及appium会话 // 关闭APP以及appium会话
if ("Android".equals(properties.getProperty("platformName"))) { if ("Android".equals(properties.getProperty("platformName"))) {
assert androiddriver != null; assert androiddriver != null;
@ -177,6 +190,15 @@ public class AppTestControl {
assert iosdriver != null; assert iosdriver != null;
iosdriver.closeApp(); iosdriver.closeApp();
} }
}
tastcount = serverOperation.updateTaskExecuteData(taskId, caseCount,2);
tastcount[0]=caseCount;
String testtime = serverOperation.getTestTime(taskId);
LogUtil.APP.info("当前项目【{}】测试计划中的用例已经全部执行完成...",projectname);
MailSendInitialization.sendMailInitialization(HtmlMail.htmlSubjectFormat(jobname),
HtmlMail.htmlContentFormat(tastcount, taskId, buildResult.toString(), restartstatus, testtime, jobname),
taskId, taskScheduling, tastcount,testtime,buildResult.toString(),restartstatus);
} else { } else {
LogUtil.APP.warn("项目构建失败自动化测试自动退出请前往JENKINS中检查项目构建情况。"); LogUtil.APP.warn("项目构建失败自动化测试自动退出请前往JENKINS中检查项目构建情况。");
MailSendInitialization.sendMailInitialization(jobname, "构建项目过程中失败自动化测试自动退出请前去JENKINS查看构建情况", taskId, taskScheduling, null,"0小时0分0秒",buildResult.toString(),restartstatus); MailSendInitialization.sendMailInitialization(jobname, "构建项目过程中失败自动化测试自动退出请前去JENKINS查看构建情况", taskId, taskScheduling, null,"0小时0分0秒",buildResult.toString(),restartstatus);

View File

@ -41,7 +41,7 @@ public class CaseLocalDebug{
List<ProjectCaseParams> pcplist=GetServerApi.cgetParamsByProjectid(String.valueOf(testcase.getProjectId())); List<ProjectCaseParams> pcplist=GetServerApi.cgetParamsByProjectid(String.valueOf(testcase.getProjectId()));
LogUtil.APP.info("开始执行用例:【{}】......",testCaseExternalId); LogUtil.APP.info("开始执行用例:【{}】......",testCaseExternalId);
List<ProjectCaseSteps> steps=GetServerApi.getStepsbycaseid(testcase.getCaseId()); List<ProjectCaseSteps> steps=GetServerApi.getStepsbycaseid(testcase.getCaseId());
AndroidCaseExecution.caseExcution(testcase, steps, "888888", appium, caselog, pcplist); AndroidCaseExecution.caseExcution(testcase, steps, "888888", null,appium, caselog, pcplist);
LogUtil.APP.info("当前用例:【{}】执行完成......进入下一条",testcase.getCaseSign()); LogUtil.APP.info("当前用例:【{}】执行完成......进入下一条",testcase.getCaseSign());
} catch (Exception e) { } catch (Exception e) {
LogUtil.APP.error("用户执行过程中抛出异常!", e); LogUtil.APP.error("用户执行过程中抛出异常!", e);

View File

@ -64,7 +64,7 @@ public class AndroidBatchExecute {
// 删除旧的日志 // 删除旧的日志
serverOperation.deleteTaskCaseLog(testcase.getCaseId(), taskid); serverOperation.deleteTaskCaseLog(testcase.getCaseId(), taskid);
try { try {
AndroidCaseExecution.caseExcution(testcase, steps, taskid, ad, caselog, pcplist); AndroidCaseExecution.caseExcution(testcase, steps, taskid,null, ad, caselog, pcplist);
} catch (Exception e) { } catch (Exception e) {
LogUtil.APP.error("用户执行过程中抛出异常!", e); LogUtil.APP.error("用户执行过程中抛出异常!", e);
} }
@ -77,7 +77,7 @@ public class AndroidBatchExecute {
// 删除旧的日志 // 删除旧的日志
serverOperation.deleteTaskCaseLog(testcase.getCaseId(), taskid); serverOperation.deleteTaskCaseLog(testcase.getCaseId(), taskid);
try { try {
AndroidCaseExecution.caseExcution(testcase, steps, taskid, ad, caselog, pcplist); AndroidCaseExecution.caseExcution(testcase, steps, taskid,null, ad, caselog, pcplist);
} catch (Exception e) { } catch (Exception e) {
LogUtil.APP.error("用户执行过程中抛出异常!", e); LogUtil.APP.error("用户执行过程中抛出异常!", e);
} }

View File

@ -36,8 +36,8 @@ public class AndroidCaseExecution{
static Map<String, String> variable = new HashMap<>(); static Map<String, String> variable = new HashMap<>();
private static String casenote = "备注初始化"; private static String casenote = "备注初始化";
public static void caseExcution(ProjectCase testcase, List<ProjectCaseSteps> steps,String taskid, AndroidDriver<AndroidElement> appium,serverOperation caselog,List<ProjectCaseParams> pcplist) { public static void caseExcution(ProjectCase testcase, List<ProjectCaseSteps> steps,String taskid,Integer planId, AndroidDriver<AndroidElement> appium,serverOperation caselog,List<ProjectCaseParams> pcplist) {
caselog.updateTaskCaseExecuteStatus(taskid, testcase.getCaseId(), 3); caselog.updateTaskCaseExecuteStatus(taskid,planId, testcase.getCaseId(), 3);
// 把公共参数加入到MAP中 // 把公共参数加入到MAP中
for (ProjectCaseParams pcp : pcplist) { for (ProjectCaseParams pcp : pcplist) {
variable.put(pcp.getParamsName(), pcp.getParamsValue()); variable.put(pcp.getParamsName(), pcp.getParamsValue());
@ -106,7 +106,7 @@ public class AndroidCaseExecution{
} }
variable.clear(); variable.clear();
caselog.updateTaskCaseExecuteStatus(taskid, testcase.getCaseId(), setcaseresult); caselog.updateTaskCaseExecuteStatus(taskid, planId,testcase.getCaseId(), setcaseresult);
if(setcaseresult==0){ if(setcaseresult==0){
LogUtil.APP.info("用例【{}】全部步骤执行结果成功...",testcase.getCaseSign()); LogUtil.APP.info("用例【{}】全部步骤执行结果成功...",testcase.getCaseSign());
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "用例全部步骤执行结果成功","info", "ending",""); caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "用例全部步骤执行结果成功","info", "ending","");

View File

@ -38,7 +38,7 @@ public class AndroidCaseLocalDebug {
.cgetParamsByProjectid(String.valueOf(testcase.getProjectId())); .cgetParamsByProjectid(String.valueOf(testcase.getProjectId()));
LogUtil.APP.info("开始执行用例:【{}】......",testCaseExternalId); LogUtil.APP.info("开始执行用例:【{}】......",testCaseExternalId);
List<ProjectCaseSteps> steps = GetServerApi.getStepsbycaseid(testcase.getCaseId()); List<ProjectCaseSteps> steps = GetServerApi.getStepsbycaseid(testcase.getCaseId());
AndroidCaseExecution.caseExcution(testcase, steps, "888888", androiddriver, caselog, pcplist); AndroidCaseExecution.caseExcution(testcase, steps, "888888",null, androiddriver, caselog, pcplist);
LogUtil.APP.info("当前用例:【{}】执行完成......进入下一条",testcase.getCaseSign()); LogUtil.APP.info("当前用例:【{}】执行完成......进入下一条",testcase.getCaseSign());
} catch (Exception e) { } catch (Exception e) {

View File

@ -58,7 +58,7 @@ public class AndroidOneCaseExecute {
LogUtil.APP.info("开始执行用例:【{}】......",testcase.getCaseSign()); LogUtil.APP.info("开始执行用例:【{}】......",testcase.getCaseSign());
try { try {
List<ProjectCaseSteps> steps = GetServerApi.getStepsbycaseid(testcase.getCaseId()); List<ProjectCaseSteps> steps = GetServerApi.getStepsbycaseid(testcase.getCaseId());
AndroidCaseExecution.caseExcution(testcase, steps, taskid, ad, caselog, pcplist); AndroidCaseExecution.caseExcution(testcase, steps, taskid,null, ad, caselog, pcplist);
LogUtil.APP.info("当前用例:【{}】执行完成......进入下一条",testcase.getCaseSign()); LogUtil.APP.info("当前用例:【{}】执行完成......进入下一条",testcase.getCaseSign());
} catch (Exception e) { } catch (Exception e) {
LogUtil.APP.error("用户执行过程中抛出异常!", e); LogUtil.APP.error("用户执行过程中抛出异常!", e);

View File

@ -63,7 +63,7 @@ public class IosBatchExecute {
// 删除旧的日志 // 删除旧的日志
serverOperation.deleteTaskCaseLog(testcase.getCaseId(), taskid); serverOperation.deleteTaskCaseLog(testcase.getCaseId(), taskid);
try { try {
IosCaseExecution.caseExcution(testcase, steps, taskid, iosd, caselog, pcplist); IosCaseExecution.caseExcution(testcase, steps, taskid,null, iosd, caselog, pcplist);
} catch (Exception e) { } catch (Exception e) {
LogUtil.APP.error("用户执行过程中抛出异常!", e); LogUtil.APP.error("用户执行过程中抛出异常!", e);
} }
@ -76,7 +76,7 @@ public class IosBatchExecute {
// 删除旧的日志 // 删除旧的日志
serverOperation.deleteTaskCaseLog(testcase.getCaseId(), taskid); serverOperation.deleteTaskCaseLog(testcase.getCaseId(), taskid);
try { try {
IosCaseExecution.caseExcution(testcase, steps, taskid, iosd, caselog, pcplist); IosCaseExecution.caseExcution(testcase, steps, taskid,null, iosd, caselog, pcplist);
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
LogUtil.APP.error("用户执行过程中抛出异常!", e); LogUtil.APP.error("用户执行过程中抛出异常!", e);

View File

@ -37,8 +37,8 @@ public class IosCaseExecution{
static Map<String, String> variable = new HashMap<>(); static Map<String, String> variable = new HashMap<>();
private static String casenote = "备注初始化"; private static String casenote = "备注初始化";
public static void caseExcution(ProjectCase testcase, List<ProjectCaseSteps> steps,String taskid, IOSDriver<IOSElement> appium,serverOperation caselog,List<ProjectCaseParams> pcplist) { public static void caseExcution(ProjectCase testcase, List<ProjectCaseSteps> steps,String taskid,Integer planId, IOSDriver<IOSElement> appium,serverOperation caselog,List<ProjectCaseParams> pcplist) {
caselog.updateTaskCaseExecuteStatus(taskid, testcase.getCaseId(), 3); caselog.updateTaskCaseExecuteStatus(taskid,planId, testcase.getCaseId(), 3);
// 把公共参数加入到MAP中 // 把公共参数加入到MAP中
for (ProjectCaseParams pcp : pcplist) { for (ProjectCaseParams pcp : pcplist) {
variable.put(pcp.getParamsName(), pcp.getParamsValue()); variable.put(pcp.getParamsName(), pcp.getParamsValue());
@ -109,7 +109,7 @@ public class IosCaseExecution{
} }
variable.clear(); variable.clear();
caselog.updateTaskCaseExecuteStatus(taskid, testcase.getCaseId(), setcaseresult); caselog.updateTaskCaseExecuteStatus(taskid, planId,testcase.getCaseId(), setcaseresult);
if(setcaseresult==0){ if(setcaseresult==0){
LogUtil.APP.info("用例【{}】全部步骤执行结果成功...",testcase.getCaseSign()); LogUtil.APP.info("用例【{}】全部步骤执行结果成功...",testcase.getCaseSign());
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "用例全部步骤执行结果成功","info", "ending",""); caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "用例全部步骤执行结果成功","info", "ending","");

View File

@ -34,7 +34,7 @@ public class IosCaseLocalDebug {
.cgetParamsByProjectid(String.valueOf(testcase.getProjectId())); .cgetParamsByProjectid(String.valueOf(testcase.getProjectId()));
LogUtil.APP.info("开始执行用例:【{}】......",testCaseExternalId); LogUtil.APP.info("开始执行用例:【{}】......",testCaseExternalId);
List<ProjectCaseSteps> steps = GetServerApi.getStepsbycaseid(testcase.getCaseId()); List<ProjectCaseSteps> steps = GetServerApi.getStepsbycaseid(testcase.getCaseId());
IosCaseExecution.caseExcution(testcase, steps, "888888", iosdriver, caselog, pcplist); IosCaseExecution.caseExcution(testcase, steps, "888888",null, iosdriver, caselog, pcplist);
LogUtil.APP.info("当前用例:【{}】执行完成......进入下一条",testcase.getCaseSign()); LogUtil.APP.info("当前用例:【{}】执行完成......进入下一条",testcase.getCaseSign());
} catch (Exception e) { } catch (Exception e) {

View File

@ -57,7 +57,7 @@ public class IosOneCaseExecute {
LogUtil.APP.info("开始执行用例:【{}】......",testcase.getCaseSign()); LogUtil.APP.info("开始执行用例:【{}】......",testcase.getCaseSign());
try { try {
List<ProjectCaseSteps> steps = GetServerApi.getStepsbycaseid(testcase.getCaseId()); List<ProjectCaseSteps> steps = GetServerApi.getStepsbycaseid(testcase.getCaseId());
IosCaseExecution.caseExcution(testcase, steps, taskid, iosd, caselog, pcplist); IosCaseExecution.caseExcution(testcase, steps, taskid,null, iosd, caselog, pcplist);
LogUtil.APP.info("当前用例:【{}】执行完成......进入下一条",testcase.getCaseSign()); LogUtil.APP.info("当前用例:【{}】执行完成......进入下一条",testcase.getCaseSign());
} catch (Exception e) { } catch (Exception e) {
LogUtil.APP.error("用户执行过程中抛出异常!", e); LogUtil.APP.error("用户执行过程中抛出异常!", e);

View File

@ -29,6 +29,9 @@ public class ParamsManageForSteps {
* @date 2019年1月15日 * @date 2019年1月15日
*/ */
public static String paramsManage(String params) { public static String paramsManage(String params) {
if(null==params){
return params;
}
ParamsManageForSteps pmfs = new ParamsManageForSteps(); ParamsManageForSteps pmfs = new ParamsManageForSteps();
params = pmfs.replaceRandomInt(params); params = pmfs.replaceRandomInt(params);
params = pmfs.replaceTimeNow(params); params = pmfs.replaceTimeNow(params);

View File

@ -10,11 +10,7 @@ import com.offbytwo.jenkins.model.BuildResult;
import luckyclient.remote.api.GetServerApi; import luckyclient.remote.api.GetServerApi;
import luckyclient.remote.api.serverOperation; import luckyclient.remote.api.serverOperation;
import luckyclient.remote.entity.ProjectCase; import luckyclient.remote.entity.*;
import luckyclient.remote.entity.ProjectCaseParams;
import luckyclient.remote.entity.ProjectCaseSteps;
import luckyclient.remote.entity.TaskExecute;
import luckyclient.remote.entity.TaskScheduling;
import luckyclient.tool.jenkins.BuildingInitialization; import luckyclient.tool.jenkins.BuildingInitialization;
import luckyclient.tool.mail.HtmlMail; import luckyclient.tool.mail.HtmlMail;
import luckyclient.tool.mail.MailSendInitialization; import luckyclient.tool.mail.MailSendInitialization;
@ -64,7 +60,7 @@ public class TestControl {
continue; continue;
} }
THREAD_COUNT++; // 多线程计数++用于检测线程是否全部执行完 THREAD_COUNT++; // 多线程计数++用于检测线程是否全部执行完
threadExecute.execute(new ThreadForExecuteCase(testcase, steps, taskid, pcplist, caselog)); threadExecute.execute(new ThreadForExecuteCase(testcase, steps, taskid,null, pcplist, caselog));
} }
// 多线程计数用于检测线程是否全部执行完 // 多线程计数用于检测线程是否全部执行完
int i = 0; int i = 0;
@ -105,15 +101,37 @@ public class TestControl {
ThreadPoolExecutor threadExecute = new ThreadPoolExecutor(threadcount, 20, 3, TimeUnit.SECONDS, ThreadPoolExecutor threadExecute = new ThreadPoolExecutor(threadcount, 20, 3, TimeUnit.SECONDS,
new ArrayBlockingQueue<>(1000), new ThreadPoolExecutor.CallerRunsPolicy()); new ArrayBlockingQueue<>(1000), new ThreadPoolExecutor.CallerRunsPolicy());
List<ProjectCase> cases = GetServerApi.getCasesbyplanId(taskScheduling.getPlanId()); List<ProjectPlan> plans=new ArrayList<>();
LogUtil.APP.info("当前测试任务 {} 中共有【{}】条待测试用例...",task.getTaskName(),cases.size());
serverOperation.updateTaskExecuteStatusIng(taskid, cases.size()); // 单计划执行
if(taskScheduling.getPlanType()==1){
ProjectPlan projectPlan=new ProjectPlan();
projectPlan.setPlanId(taskScheduling.getPlanId());
plans.add(projectPlan);
}
// 聚合多计划执行
else if(taskScheduling.getPlanType()==2){
plans.addAll(GetServerApi.getPlansbysuiteId(taskScheduling.getSuiteId()));
}
LogUtil.APP.info("当前测试任务 {} 中共有【{}】条测试计划...",task.getTaskName(),plans.size());
int caseCount=0;
int taskStatus = 2;
for(ProjectPlan pp:plans){
List<ProjectCase> cases = GetServerApi.getCasesbyplanId(pp.getPlanId());
caseCount+=cases.size();
}
for(ProjectPlan pp:plans) {
List<ProjectCase> cases = GetServerApi.getCasesbyplanId(pp.getPlanId());
LogUtil.APP.info("当前测试计划 {} 中共有【{}】条待测试用例...", pp.getPlanName(), cases.size());
serverOperation.updateTaskExecuteStatusIng(taskid, caseCount);
int casepriority = 0; int casepriority = 0;
for (int j = 0; j < cases.size(); j++) { for (int j = 0; j < cases.size(); j++) {
ProjectCase projectcase = cases.get(j); ProjectCase projectcase = cases.get(j);
List<ProjectCaseSteps> steps = GetServerApi.getStepsbycaseid(projectcase.getCaseId()); List<ProjectCaseSteps> steps = GetServerApi.getStepsbycaseid(projectcase.getCaseId());
if (steps.size() == 0) { if (steps.size() == 0) {
caselog.insertTaskCaseExecute(taskid, taskScheduling.getProjectId(),projectcase.getCaseId(),projectcase.getCaseSign(), projectcase.getCaseName(), 2); caselog.insertTaskCaseExecute(taskid, taskScheduling.getProjectId(),pp.getPlanId(), projectcase.getCaseId(), projectcase.getCaseSign(), projectcase.getCaseName(), 2);
LogUtil.APP.warn("用例【{}】没有找到步骤,直接跳过,请检查!", projectcase.getCaseSign()); LogUtil.APP.warn("用例【{}】没有找到步骤,直接跳过,请检查!", projectcase.getCaseSign());
caselog.insertTaskCaseLog(taskid, projectcase.getCaseId(), "在用例中没有找到步骤,请检查", "error", "1", ""); caselog.insertTaskCaseLog(taskid, projectcase.getCaseId(), "在用例中没有找到步骤,请检查", "error", "1", "");
continue; continue;
@ -134,11 +152,10 @@ public class TestControl {
casepriority = projectcase.getPriority(); casepriority = projectcase.getPriority();
THREAD_COUNT++; // 多线程计数++用于检测线程是否全部执行完 THREAD_COUNT++; // 多线程计数++用于检测线程是否全部执行完
LogUtil.APP.info("开始执行当前测试任务 {} 的第【{}】条测试用例...", task.getTaskName(), j + 1); LogUtil.APP.info("开始执行当前测试任务 {} 的第【{}】条测试用例...", task.getTaskName(), j + 1);
threadExecute.execute(new ThreadForExecuteCase(projectcase, steps, taskid, pcplist, caselog)); threadExecute.execute(new ThreadForExecuteCase(projectcase, steps, taskid,pp.getPlanId(), pcplist, caselog));
} }
// 多线程计数用于检测线程是否全部执行完 // 多线程计数用于检测线程是否全部执行完
int i = 0; int i = 0;
int taskStatus=2;
while (THREAD_COUNT != 0) { while (THREAD_COUNT != 0) {
i++; i++;
if (i > timeout * 10) { if (i > timeout * 10) {
@ -148,7 +165,8 @@ public class TestControl {
} }
Thread.sleep(6000); Thread.sleep(6000);
} }
tastcount = serverOperation.updateTaskExecuteData(taskid, cases.size(),taskStatus); }
tastcount = serverOperation.updateTaskExecuteData(taskid, caseCount,taskStatus);
String testtime = serverOperation.getTestTime(taskid); String testtime = serverOperation.getTestTime(taskid);
MailSendInitialization.sendMailInitialization(HtmlMail.htmlSubjectFormat(jobname), MailSendInitialization.sendMailInitialization(HtmlMail.htmlSubjectFormat(jobname),

View File

@ -36,17 +36,19 @@ public class ThreadForExecuteCase extends Thread {
private String caseSign; private String caseSign;
private ProjectCase testcase; private ProjectCase testcase;
private String taskid; private String taskid;
private Integer planId;
private Integer projectId; private Integer projectId;
private List<ProjectCaseSteps> steps; private List<ProjectCaseSteps> steps;
private List<ProjectCaseParams> pcplist; private List<ProjectCaseParams> pcplist;
private serverOperation caselog; private serverOperation caselog;
public ThreadForExecuteCase(ProjectCase projectcase, List<ProjectCaseSteps> steps, String taskid, List<ProjectCaseParams> pcplist, serverOperation caselog) { public ThreadForExecuteCase(ProjectCase projectcase, List<ProjectCaseSteps> steps, String taskid,Integer planId, List<ProjectCaseParams> pcplist, serverOperation caselog) {
this.caseId = projectcase.getCaseId(); this.caseId = projectcase.getCaseId();
this.testcase = projectcase; this.testcase = projectcase;
this.projectId = projectcase.getProjectId(); this.projectId = projectcase.getProjectId();
this.caseSign = projectcase.getCaseSign(); this.caseSign = projectcase.getCaseSign();
this.taskid = taskid; this.taskid = taskid;
this.planId=planId;
this.steps = steps; this.steps = steps;
this.pcplist = pcplist; this.pcplist = pcplist;
this.caselog = caselog; this.caselog = caselog;
@ -71,7 +73,7 @@ public class ThreadForExecuteCase extends Thread {
int stepJumpNo=0; int stepJumpNo=0;
// 进入循环解析单个用例所有步骤 // 进入循环解析单个用例所有步骤
// 插入开始执行的用例 // 插入开始执行的用例
caselog.insertTaskCaseExecute(taskid, projectId, caseId, caseSign, testcase.getCaseName(), 3); caselog.insertTaskCaseExecute(taskid, projectId, planId,caseId, caseSign, testcase.getCaseName(), 3);
for (int i = 0; i < steps.size(); i++) { for (int i = 0; i < steps.size(); i++) {
//处理步骤跳转语法 //处理步骤跳转语法
if(stepJumpNo!=0&&setcaseresult!=0){ if(stepJumpNo!=0&&setcaseresult!=0){
@ -274,7 +276,7 @@ public class ThreadForExecuteCase extends Thread {
caselog.insertTaskCaseLog(taskid, caseId, "设置执行结果为锁定,请参考错误日志查找锁定用例的原因.....", "error", "SETCASERESULT...", ""); caselog.insertTaskCaseLog(taskid, caseId, "设置执行结果为锁定,请参考错误日志查找锁定用例的原因.....", "error", "SETCASERESULT...", "");
setcaseresult = 2; setcaseresult = 2;
} }
caselog.updateTaskCaseExecuteStatus(taskid, caseId, setcaseresult); caselog.updateTaskCaseExecuteStatus(taskid, planId,caseId, setcaseresult);
if (0 == setcaseresult) { if (0 == setcaseresult) {
LogUtil.APP.info("用例:{}执行结果成功......",testcase.getCaseSign()); LogUtil.APP.info("用例:{}执行结果成功......",testcase.getCaseSign());
caselog.insertTaskCaseLog(taskid, caseId, "用例步骤执行全部成功......", "info", "ending", ""); caselog.insertTaskCaseLog(taskid, caseId, "用例步骤执行全部成功......", "info", "ending", "");

View File

@ -41,7 +41,7 @@ public class CaseLocalDebug{
List<ProjectCaseParams> pcplist=GetServerApi.cgetParamsByProjectid(String.valueOf(testcase.getProjectId())); List<ProjectCaseParams> pcplist=GetServerApi.cgetParamsByProjectid(String.valueOf(testcase.getProjectId()));
LogUtil.APP.info("开始执行用例:【{}】......",testCaseExternalId); LogUtil.APP.info("开始执行用例:【{}】......",testCaseExternalId);
List<ProjectCaseSteps> steps=GetServerApi.getStepsbycaseid(testcase.getCaseId()); List<ProjectCaseSteps> steps=GetServerApi.getStepsbycaseid(testcase.getCaseId());
WebCaseExecution.caseExcution(testcase,steps, "888888",wd,caselog,pcplist); WebCaseExecution.caseExcution(testcase,steps, "888888",null,wd,caselog,pcplist);
LogUtil.APP.info("当前用例:【{}】执行完成......进入下一条",testcase.getCaseSign()); LogUtil.APP.info("当前用例:【{}】执行完成......进入下一条",testcase.getCaseSign());
} catch (Exception e) { } catch (Exception e) {
LogUtil.APP.error("用户执行过程中抛出异常!", e); LogUtil.APP.error("用户执行过程中抛出异常!", e);

View File

@ -1,28 +1,22 @@
package luckyclient.execution.webdriver; package luckyclient.execution.webdriver;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverException;
import com.offbytwo.jenkins.model.BuildResult; import com.offbytwo.jenkins.model.BuildResult;
import luckyclient.execution.httpinterface.TestControl; import luckyclient.execution.httpinterface.TestControl;
import luckyclient.execution.webdriver.ex.WebCaseExecution; import luckyclient.execution.webdriver.ex.WebCaseExecution;
import luckyclient.remote.api.GetServerApi; import luckyclient.remote.api.GetServerApi;
import luckyclient.remote.api.serverOperation; import luckyclient.remote.api.serverOperation;
import luckyclient.remote.entity.ProjectCase; import luckyclient.remote.entity.*;
import luckyclient.remote.entity.ProjectCaseParams;
import luckyclient.remote.entity.ProjectCaseSteps;
import luckyclient.remote.entity.TaskExecute;
import luckyclient.remote.entity.TaskScheduling;
import luckyclient.tool.jenkins.BuildingInitialization; import luckyclient.tool.jenkins.BuildingInitialization;
import luckyclient.tool.mail.HtmlMail; import luckyclient.tool.mail.HtmlMail;
import luckyclient.tool.mail.MailSendInitialization; import luckyclient.tool.mail.MailSendInitialization;
import luckyclient.tool.shell.RestartServerInitialization; import luckyclient.tool.shell.RestartServerInitialization;
import luckyclient.utils.LogUtil; import luckyclient.utils.LogUtil;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/** /**
* ================================================================= * =================================================================
@ -68,7 +62,7 @@ public class WebTestControl {
i++; i++;
LogUtil.APP.info("开始执行第{}条用例:【{}】......",i,testcase.getCaseSign()); LogUtil.APP.info("开始执行第{}条用例:【{}】......",i,testcase.getCaseSign());
try { try {
WebCaseExecution.caseExcution(testcase, steps, taskid, wd, caselog, pcplist); WebCaseExecution.caseExcution(testcase, steps, taskid, null,wd, caselog, pcplist);
} catch (Exception e) { } catch (Exception e) {
LogUtil.APP.error("用户执行过程中抛出异常!", e); LogUtil.APP.error("用户执行过程中抛出异常!", e);
} }
@ -87,17 +81,38 @@ public class WebTestControl {
TestControl.TASKID = taskid; TestControl.TASKID = taskid;
String restartstatus = RestartServerInitialization.restartServerRun(taskid); String restartstatus = RestartServerInitialization.restartServerRun(taskid);
BuildResult buildResult = BuildingInitialization.buildingRun(taskid); BuildResult buildResult = BuildingInitialization.buildingRun(taskid);
List<ProjectCaseParams> pcplist = GetServerApi.cgetParamsByProjectid(task.getProjectId().toString());
TaskScheduling taskScheduling = GetServerApi.cGetTaskSchedulingByTaskId(task.getTaskId()); TaskScheduling taskScheduling = GetServerApi.cGetTaskSchedulingByTaskId(task.getTaskId());
List<ProjectCaseParams> pcplist = GetServerApi.cgetParamsByProjectid(task.getProjectId().toString());
String projectname = taskScheduling.getProject().getProjectName(); String projectname = taskScheduling.getProject().getProjectName();
task = GetServerApi.cgetTaskbyid(Integer.parseInt(taskid)); task = GetServerApi.cgetTaskbyid(Integer.parseInt(taskid));
String jobname = taskScheduling.getSchedulingName(); String jobname = taskScheduling.getSchedulingName();
int drivertype = serverOperation.querydrivertype(taskid); int drivertype = serverOperation.querydrivertype(taskid);
int[] tastcount; int[] tastcount=new int[5];
// 判断是否要自动重启TOMCAT // 判断是否要自动重启TOMCAT
if (restartstatus.contains("Status:true")) { if (restartstatus.contains("Status:true")) {
// 判断是否构建是否成功 // 判断是否构建是否成功
if (BuildResult.SUCCESS.equals(buildResult)) { if (BuildResult.SUCCESS.equals(buildResult)) {
List<ProjectPlan> plans=new ArrayList<>();
// 单计划执行
if(taskScheduling.getPlanType()==1){
ProjectPlan projectPlan=new ProjectPlan();
projectPlan.setPlanId(taskScheduling.getPlanId());
plans.add(projectPlan);
}
// 聚合多计划执行
else if(taskScheduling.getPlanType()==2){
plans.addAll(GetServerApi.getPlansbysuiteId(taskScheduling.getSuiteId()));
}
LogUtil.APP.info("当前测试任务 {} 中共有【{}】条测试计划...",task.getTaskName(),plans.size());
int caseCount=0;
for(ProjectPlan pp:plans){
List<ProjectCase> cases = GetServerApi.getCasesbyplanId(pp.getPlanId());
caseCount+=cases.size();
}
for(ProjectPlan pp:plans){
WebDriver wd = null; WebDriver wd = null;
try { try {
wd = WebDriverInitialization.setWebDriverForTask(drivertype); wd = WebDriverInitialization.setWebDriverForTask(drivertype);
@ -106,11 +121,12 @@ public class WebTestControl {
} catch (IOException e2) { } catch (IOException e2) {
LogUtil.APP.error("初始化WebDriver出错 IOException", e2); LogUtil.APP.error("初始化WebDriver出错 IOException", e2);
} }
serverOperation caselog = new serverOperation();
List<ProjectCase> cases = GetServerApi.getCasesbyplanId(taskScheduling.getPlanId()); serverOperation caselog = new serverOperation();
LogUtil.APP.info("当前测试任务 {} 中共有【{}】条待测试用例...",task.getTaskName(),cases.size()); List<ProjectCase> cases = GetServerApi.getCasesbyplanId(pp.getPlanId());
serverOperation.updateTaskExecuteStatusIng(taskid, cases.size()); LogUtil.APP.info("当前测试计划 {} 中共有【{}】条待测试用例...",pp.getPlanName(),cases.size());
LogUtil.APP.info("开始执行当前测试计划 {} ......",pp.getPlanName());
serverOperation.updateTaskExecuteStatusIng(taskid, caseCount);
int i = 0; int i = 0;
for (ProjectCase testcase : cases) { for (ProjectCase testcase : cases) {
i++; i++;
@ -121,24 +137,26 @@ public class WebTestControl {
} }
try { try {
// 插入开始执行的用例 // 插入开始执行的用例
caselog.insertTaskCaseExecute(taskid, taskScheduling.getProjectId(),testcase.getCaseId(),testcase.getCaseSign(), testcase.getCaseName(), 4); caselog.insertTaskCaseExecute(taskid, taskScheduling.getProjectId(),pp.getPlanId(),testcase.getCaseId(),testcase.getCaseSign(), testcase.getCaseName(), 4);
WebCaseExecution.caseExcution(testcase, steps, taskid, wd, caselog, pcplist); WebCaseExecution.caseExcution(testcase, steps, taskid,pp.getPlanId(),wd, caselog, pcplist);
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
LogUtil.APP.error("用户执行过程中抛出异常!", e); LogUtil.APP.error("用户执行过程中抛出异常!", e);
} }
LogUtil.APP.info("当前用例:【{}】执行完成......进入下一条",testcase.getCaseSign()); LogUtil.APP.info("当前用例:【{}】执行完成......进入下一条",testcase.getCaseSign());
} }
tastcount = serverOperation.updateTaskExecuteData(taskid, cases.size(),2); LogUtil.APP.info("当前【{}】测试计划中的用例已经全部执行完成...",pp.getPlanName());
assert wd != null;
wd.quit();
}
tastcount = serverOperation.updateTaskExecuteData(taskid, caseCount,2);
tastcount[0]=caseCount;
String testtime = serverOperation.getTestTime(taskid); String testtime = serverOperation.getTestTime(taskid);
LogUtil.APP.info("当前项目【{}】测试计划中的用例已经全部执行完成...",projectname); LogUtil.APP.info("当前项目【{}】测试计划中的用例已经全部执行完成...",projectname);
MailSendInitialization.sendMailInitialization(HtmlMail.htmlSubjectFormat(jobname), MailSendInitialization.sendMailInitialization(HtmlMail.htmlSubjectFormat(jobname),
HtmlMail.htmlContentFormat(tastcount, taskid, buildResult.toString(), restartstatus, testtime, jobname), HtmlMail.htmlContentFormat(tastcount, taskid, buildResult.toString(), restartstatus, testtime, jobname),
taskid, taskScheduling, tastcount,testtime,buildResult.toString(),restartstatus); taskid, taskScheduling, tastcount,testtime,buildResult.toString(),restartstatus);
// 关闭浏览器
assert wd != null;
wd.quit();
} else { } else {
LogUtil.APP.warn("项目构建失败自动化测试自动退出请前往JENKINS中检查项目构建情况。"); LogUtil.APP.warn("项目构建失败自动化测试自动退出请前往JENKINS中检查项目构建情况。");
MailSendInitialization.sendMailInitialization(jobname, "构建项目过程中失败自动化测试自动退出请前去JENKINS查看构建情况", taskid, MailSendInitialization.sendMailInitialization(jobname, "构建项目过程中失败自动化测试自动退出请前去JENKINS查看构建情况", taskid,

View File

@ -52,7 +52,7 @@ public class WebBatchExecute{
//删除旧的日志 //删除旧的日志
serverOperation.deleteTaskCaseLog(testcase.getCaseId(), taskid); serverOperation.deleteTaskCaseLog(testcase.getCaseId(), taskid);
try { try {
WebCaseExecution.caseExcution(testcase, steps, taskid, wd, caselog, pcplist); WebCaseExecution.caseExcution(testcase, steps, taskid,null, wd, caselog, pcplist);
} catch (Exception e) { } catch (Exception e) {
LogUtil.APP.error("用户执行过程中抛出异常!", e); LogUtil.APP.error("用户执行过程中抛出异常!", e);
} }
@ -65,7 +65,7 @@ public class WebBatchExecute{
//删除旧的日志 //删除旧的日志
serverOperation.deleteTaskCaseLog(testcase.getCaseId(), taskid); serverOperation.deleteTaskCaseLog(testcase.getCaseId(), taskid);
try { try {
WebCaseExecution.caseExcution(testcase, steps, taskid, wd, caselog, pcplist); WebCaseExecution.caseExcution(testcase, steps, taskid,null, wd, caselog, pcplist);
} catch (Exception e) { } catch (Exception e) {
LogUtil.APP.error("用户执行过程中抛出异常!", e); LogUtil.APP.error("用户执行过程中抛出异常!", e);
} }

View File

@ -39,8 +39,8 @@ public class WebCaseExecution{
private static Map<String, String> variable = new HashMap<>(); private static Map<String, String> variable = new HashMap<>();
private static String casenote = "备注初始化"; private static String casenote = "备注初始化";
public static void caseExcution(ProjectCase testcase, List<ProjectCaseSteps> steps, String taskid, WebDriver wd, serverOperation caselog, List<ProjectCaseParams> pcplist) { public static void caseExcution(ProjectCase testcase, List<ProjectCaseSteps> steps, String taskid,Integer planId, WebDriver wd, serverOperation caselog, List<ProjectCaseParams> pcplist) {
caselog.updateTaskCaseExecuteStatus(taskid, testcase.getCaseId(), 3); caselog.updateTaskCaseExecuteStatus(taskid,planId, testcase.getCaseId(), 3);
// 把公共参数加入到MAP中 // 把公共参数加入到MAP中
for (ProjectCaseParams pcp : pcplist) { for (ProjectCaseParams pcp : pcplist) {
variable.put(pcp.getParamsName(), pcp.getParamsValue()); variable.put(pcp.getParamsName(), pcp.getParamsValue());
@ -109,7 +109,7 @@ public class WebCaseExecution{
} }
variable.clear(); variable.clear();
caselog.updateTaskCaseExecuteStatus(taskid, testcase.getCaseId(), setcaseresult); caselog.updateTaskCaseExecuteStatus(taskid,planId, testcase.getCaseId(), setcaseresult);
if (setcaseresult == 0) { if (setcaseresult == 0) {
LogUtil.APP.info("用例【{}】全部步骤执行结果成功...",testcase.getCaseSign()); LogUtil.APP.info("用例【{}】全部步骤执行结果成功...",testcase.getCaseSign());
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "用例全部步骤执行结果成功", "info", "ending", ""); caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "用例全部步骤执行结果成功", "info", "ending", "");

View File

@ -47,7 +47,7 @@ public class WebOneCaseExecute{
LogUtil.APP.info("开始执行用例:【{}】......",testcase.getCaseSign()); LogUtil.APP.info("开始执行用例:【{}】......",testcase.getCaseSign());
try { try {
List<ProjectCaseSteps> steps=GetServerApi.getStepsbycaseid(testcase.getCaseId()); List<ProjectCaseSteps> steps=GetServerApi.getStepsbycaseid(testcase.getCaseId());
WebCaseExecution.caseExcution(testcase, steps, taskid,wd,caselog,pcplist); WebCaseExecution.caseExcution(testcase, steps, taskid,null,wd,caselog,pcplist);
LogUtil.APP.info("当前用例:【{}】执行完成......进入下一条",testcase.getCaseSign()); LogUtil.APP.info("当前用例:【{}】执行完成......进入下一条",testcase.getCaseSign());
} catch (Exception e) { } catch (Exception e) {
LogUtil.APP.error("用户执行过程中抛出异常!", e); LogUtil.APP.error("用户执行过程中抛出异常!", e);

View File

@ -34,6 +34,16 @@ public class GetServerApi {
return JSONObject.parseArray(result, ProjectCase.class); return JSONObject.parseArray(result, ProjectCase.class);
} }
/**
* 通过计划ID获取测试用例对象集
* @param suiteId 测试计划ID
* @return 返回用例List
*/
public static List<ProjectPlan> getPlansbysuiteId(int suiteId) {
String result = HttpRequest.loadJSON(PREFIX+"/clientGetPlanListBySuiteId.do?suiteId=" + suiteId);
return JSONObject.parseArray(result, ProjectPlan.class);
}
/** /**
* 通过计划名称获取测试用例对象集 * 通过计划名称获取测试用例对象集
* @param name 测试计划名称 * @param name 测试计划名称

View File

@ -64,6 +64,19 @@ public class PostServerApi {
HttpRequest.httpClientPostJson(PREFIX+"/clientPostTaskCaseExecute", JSONObject.toJSONString(taskCaseExecute)); HttpRequest.httpClientPostJson(PREFIX+"/clientPostTaskCaseExecute", JSONObject.toJSONString(taskCaseExecute));
} }
public static void clientPostInsertTaskCaseExecute(Integer taskId, Integer projectId,Integer planId, Integer caseId, String caseSign, String caseName, Integer caseStatus){
TaskCaseExecute taskCaseExecute = new TaskCaseExecute();
taskCaseExecute.setTaskId(taskId);
taskCaseExecute.setPlanId(planId);
taskCaseExecute.setProjectId(projectId);
taskCaseExecute.setCaseId(caseId);
taskCaseExecute.setCaseSign(caseSign);
taskCaseExecute.setCaseName(caseName);
taskCaseExecute.setCaseStatus(caseStatus);
HttpRequest.httpClientPostJson(PREFIX+"/clientPostTaskCaseExecute", JSONObject.toJSONString(taskCaseExecute));
}
/** /**
* 修改用例执行状态 * 修改用例执行状态
* @param taskId 任务ID * @param taskId 任务ID
@ -81,6 +94,16 @@ public class PostServerApi {
HttpRequest.httpClientPostJson(PREFIX+"/clientUpdateTaskCaseExecuteStatus", JSONObject.toJSONString(taskCaseExecute)); HttpRequest.httpClientPostJson(PREFIX+"/clientUpdateTaskCaseExecuteStatus", JSONObject.toJSONString(taskCaseExecute));
} }
public static void clientUpdateTaskCaseExecuteStatus(Integer taskId,Integer planId, Integer caseId, Integer caseStatus){
TaskCaseExecute taskCaseExecute = new TaskCaseExecute();
taskCaseExecute.setTaskId(taskId);
taskCaseExecute.setPlanId(planId);
taskCaseExecute.setCaseId(caseId);
taskCaseExecute.setCaseStatus(caseStatus);
HttpRequest.httpClientPostJson(PREFIX+"/clientUpdateTaskCaseExecuteStatus", JSONObject.toJSONString(taskCaseExecute));
}
/** /**
* 插入用例执行明细到数据库 * 插入用例执行明细到数据库
* @param taskId 任务ID * @param taskId 任务ID

View File

@ -35,6 +35,16 @@ public class serverOperation {
} }
} }
/**
* 插入用例执行状态 0通过 1失败 2锁定 3执行中 4未执行
*/
public void insertTaskCaseExecute(String taskIdStr, Integer projectId,Integer planId,Integer caseId, String caseSign,String caseName, Integer caseStatus) {
if (0 == exetype) {
Integer taskId=Integer.valueOf(taskIdStr);
PostServerApi.clientPostInsertTaskCaseExecute(taskId, projectId,planId, caseId, caseSign, caseName, caseStatus);
}
}
/** /**
* 更新用例执行状态 0通过 1失败 2锁定 3执行中 4未执行 * 更新用例执行状态 0通过 1失败 2锁定 3执行中 4未执行
*/ */
@ -45,6 +55,15 @@ public class serverOperation {
} }
} }
public void updateTaskCaseExecuteStatus(String taskIdStr,Integer planId, Integer caseId, Integer caseStatus) {
if (0 == exetype) {
Integer taskId=Integer.valueOf(taskIdStr);
PostServerApi.clientUpdateTaskCaseExecuteStatus(taskId,planId, caseId, caseStatus);
}
}
/** /**
* 插入用例执行日志 * 插入用例执行日志
*/ */

View File

@ -0,0 +1,129 @@
package luckyclient.remote.entity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.Date;
public class ProjectSuite extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 聚合计划ID */
private Integer suiteId;
/** 聚合计划名称 */
private String suiteName;
/** 聚合中的计划总数 */
private Integer suitePlanCount;
/** 项目ID */
private Integer projectId;
/** 创建者 */
private String createBy;
/** 创建时间 */
private Date createTime;
/** 更新者 */
private String updateBy;
/** 更新时间 */
private Date updateTime;
/** 备注 */
private String remark;
/** 关联项目实体 */
private Project project;
public Integer getSuiteId() {
return suiteId;
}
public void setSuiteId(Integer suiteId) {
this.suiteId = suiteId;
}
public String getSuiteName() {
return suiteName;
}
public void setSuiteName(String suiteName) {
this.suiteName = suiteName;
}
public Integer getSuitePlanCount() {
return suitePlanCount;
}
public void setSuitePlanCount(Integer suitePlanCount) {
this.suitePlanCount = suitePlanCount;
}
public Integer getProjectId() {
return projectId;
}
public void setProjectId(Integer projectId) {
this.projectId = projectId;
}
public String getCreateBy() {
return createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getUpdateBy() {
return updateBy;
}
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public Project getProject() {
return project;
}
public void setProject(Project project) {
this.project = project;
}
public String toString(){
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("suiteId", getSuiteId())
.append("suiteName", getSuiteName())
.append("suitePlanCount", getSuitePlanCount())
.append("projectId", getProjectId())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.append("project", getProject())
.toString();
}
}

View File

@ -19,6 +19,8 @@ public class TaskCaseExecute extends BaseEntity
private Integer taskCaseId; private Integer taskCaseId;
/** 任务ID */ /** 任务ID */
private Integer taskId; private Integer taskId;
/** ¼Æ»®ID */
private Integer planId;
/** 项目ID */ /** 项目ID */
private Integer projectId; private Integer projectId;
/** 用例ID */ /** 用例ID */
@ -58,6 +60,13 @@ public class TaskCaseExecute extends BaseEntity
{ {
return taskId; return taskId;
} }
public Integer getPlanId() {
return planId;
}
public void setPlanId(Integer planId) {
this.planId = planId;
}
public void setProjectId(Integer projectId) public void setProjectId(Integer projectId)
{ {
this.projectId = projectId; this.projectId = projectId;

View File

@ -26,6 +26,8 @@ public class TaskScheduling extends BaseEntity
private Integer projectId; private Integer projectId;
/** 测试计划ID */ /** 测试计划ID */
private Integer planId; private Integer planId;
/** 聚合计划ID */
private Integer suiteId;
/** 客户端ID */ /** 客户端ID */
private Integer clientId; private Integer clientId;
/** 环境 */ /** 环境 */
@ -46,6 +48,8 @@ public class TaskScheduling extends BaseEntity
private Integer taskType; private Integer taskType;
/** UI自动化浏览器类型 0 IE 1 火狐 2 谷歌 3 Edge */ /** UI自动化浏览器类型 0 IE 1 火狐 2 谷歌 3 Edge */
private Integer browserType; private Integer browserType;
/** 计划类型 1 单计划 2 聚合计划 */
private Integer planType;
/** 任务超时时间(分钟) */ /** 任务超时时间(分钟) */
private Integer taskTimeout; private Integer taskTimeout;
/** 客户端测试驱动桩路径 */ /** 客户端测试驱动桩路径 */
@ -54,6 +58,8 @@ public class TaskScheduling extends BaseEntity
private Project project; private Project project;
/** 关联项目计划 */ /** 关联项目计划 */
private ProjectPlan projectPlan; private ProjectPlan projectPlan;
/** 关联聚合计划 */
private ProjectSuite projectSuite;
/** 任务名称 */ /** 任务名称 */
private String jobName; private String jobName;
/** cron执行表达式 */ /** cron执行表达式 */
@ -61,6 +67,14 @@ public class TaskScheduling extends BaseEntity
/** 任务状态0正常 1暂停 */ /** 任务状态0正常 1暂停 */
private String status; private String status;
public Integer getSchedulingId() {
return schedulingId;
}
public void setSchedulingId(Integer schedulingId) {
this.schedulingId = schedulingId;
}
public String getSchedulingName() { public String getSchedulingName() {
return schedulingName; return schedulingName;
} }
@ -69,6 +83,166 @@ public class TaskScheduling extends BaseEntity
this.schedulingName = schedulingName; this.schedulingName = schedulingName;
} }
public Integer getJobId() {
return jobId;
}
public void setJobId(Integer jobId) {
this.jobId = jobId;
}
public Integer getProjectId() {
return projectId;
}
public void setProjectId(Integer projectId) {
this.projectId = projectId;
}
public Integer getPlanId() {
return planId;
}
public void setPlanId(Integer planId) {
this.planId = planId;
}
public Integer getSuiteId() {
return suiteId;
}
public void setSuiteId(Integer suiteId) {
this.suiteId = suiteId;
}
public Integer getClientId() {
return clientId;
}
public void setClientId(Integer clientId) {
this.clientId = clientId;
}
public String getEnvName() {
return envName;
}
public void setEnvName(String envName) {
this.envName = envName;
}
public String getEmailAddress() {
return emailAddress;
}
public void setEmailAddress(String emailAddress) {
this.emailAddress = emailAddress;
}
public String getPushUrl() {
return pushUrl;
}
public void setPushUrl(String pushUrl) {
this.pushUrl = pushUrl;
}
public Integer getEmailSendCondition() {
return emailSendCondition;
}
public void setEmailSendCondition(Integer emailSendCondition) {
this.emailSendCondition = emailSendCondition;
}
public String getBuildingLink() {
return buildingLink;
}
public void setBuildingLink(String buildingLink) {
this.buildingLink = buildingLink;
}
public String getRemoteShell() {
return remoteShell;
}
public void setRemoteShell(String remoteShell) {
this.remoteShell = remoteShell;
}
public Integer getExThreadCount() {
return exThreadCount;
}
public void setExThreadCount(Integer exThreadCount) {
this.exThreadCount = exThreadCount;
}
public Integer getTaskType() {
return taskType;
}
public void setTaskType(Integer taskType) {
this.taskType = taskType;
}
public Integer getBrowserType() {
return browserType;
}
public void setBrowserType(Integer browserType) {
this.browserType = browserType;
}
public Integer getPlanType() {
return planType;
}
public void setPlanType(Integer planType) {
this.planType = planType;
}
public Integer getTaskTimeout() {
return taskTimeout;
}
public void setTaskTimeout(Integer taskTimeout) {
this.taskTimeout = taskTimeout;
}
public String getClientDriverPath() {
return clientDriverPath;
}
public void setClientDriverPath(String clientDriverPath) {
this.clientDriverPath = clientDriverPath;
}
public Project getProject() {
return project;
}
public void setProject(Project project) {
this.project = project;
}
public ProjectPlan getProjectPlan() {
return projectPlan;
}
public void setProjectPlan(ProjectPlan projectPlan) {
this.projectPlan = projectPlan;
}
public ProjectSuite getProjectSuite() {
return projectSuite;
}
public void setProjectSuite(ProjectSuite projectSuite) {
this.projectSuite = projectSuite;
}
public String getJobName() { public String getJobName() {
return jobName; return jobName;
} }
@ -93,166 +267,6 @@ public class TaskScheduling extends BaseEntity
this.status = status; this.status = status;
} }
public ProjectPlan getProjectPlan() {
return projectPlan;
}
public void setProjectPlan(ProjectPlan projectPlan) {
this.projectPlan = projectPlan;
}
public Project getProject() {
return project;
}
public void setProject(Project project) {
this.project = project;
}
public void setSchedulingId(Integer schedulingId)
{
this.schedulingId = schedulingId;
}
public Integer getSchedulingId()
{
return schedulingId;
}
public void setJobId(Integer jobId)
{
this.jobId = jobId;
}
public Integer getJobId()
{
return jobId;
}
public void setProjectId(Integer projectId)
{
this.projectId = projectId;
}
public Integer getProjectId()
{
return projectId;
}
public void setPlanId(Integer planId)
{
this.planId = planId;
}
public Integer getPlanId()
{
return planId;
}
public void setClientId(Integer clientId)
{
this.clientId = clientId;
}
public Integer getClientId()
{
return clientId;
}
public void setEmailAddress(String emailAddress)
{
this.emailAddress = emailAddress;
}
public String getEnvName() {
return envName;
}
public void setEnvName(String envName) {
this.envName = envName;
}
public String getEmailAddress()
{
return emailAddress;
}
public void setPushUrl(String pushUrl)
{
this.pushUrl = pushUrl;
}
public String getPushUrl()
{
return pushUrl;
}
public void setEmailSendCondition(Integer emailSendCondition)
{
this.emailSendCondition = emailSendCondition;
}
public Integer getEmailSendCondition()
{
return emailSendCondition;
}
public void setBuildingLink(String buildingLink)
{
this.buildingLink = buildingLink;
}
public String getBuildingLink()
{
return buildingLink;
}
public void setRemoteShell(String remoteShell)
{
this.remoteShell = remoteShell;
}
public String getRemoteShell()
{
return remoteShell;
}
public void setExThreadCount(Integer exThreadCount)
{
this.exThreadCount = exThreadCount;
}
public Integer getExThreadCount()
{
return exThreadCount;
}
public void setTaskType(Integer taskType)
{
this.taskType = taskType;
}
public Integer getTaskType()
{
return taskType;
}
public void setBrowserType(Integer browserType)
{
this.browserType = browserType;
}
public Integer getBrowserType()
{
return browserType;
}
public void setTaskTimeout(Integer taskTimeout)
{
this.taskTimeout = taskTimeout;
}
public Integer getTaskTimeout()
{
return taskTimeout;
}
public void setClientDriverPath(String clientDriverPath)
{
this.clientDriverPath = clientDriverPath;
}
public String getClientDriverPath()
{
return clientDriverPath;
}
@Override @Override
public String toString() { public String toString() {
@ -261,6 +275,7 @@ public class TaskScheduling extends BaseEntity
.append("jobId", getJobId()) .append("jobId", getJobId())
.append("projectId", getProjectId()) .append("projectId", getProjectId())
.append("planId", getPlanId()) .append("planId", getPlanId())
.append("suiteId", getSuiteId())
.append("clientId", getClientId()) .append("clientId", getClientId())
.append("envName", getEnvName()) .append("envName", getEnvName())
.append("emailAddress", getEmailAddress()) .append("emailAddress", getEmailAddress())
@ -270,6 +285,7 @@ public class TaskScheduling extends BaseEntity
.append("remoteShell", getRemoteShell()) .append("remoteShell", getRemoteShell())
.append("exThreadCount", getExThreadCount()) .append("exThreadCount", getExThreadCount())
.append("taskType", getTaskType()) .append("taskType", getTaskType())
.append("planType", getPlanType())
.append("browserType", getBrowserType()) .append("browserType", getBrowserType())
.append("taskTimeout", getTaskTimeout()) .append("taskTimeout", getTaskTimeout())
.append("clientDriverPath", getClientDriverPath()) .append("clientDriverPath", getClientDriverPath())