优化远程接口

This commit is contained in:
seagull 2019-04-23 14:53:15 +08:00
parent 9dbeaa8a95
commit 4092e3413a
21 changed files with 153 additions and 356 deletions

View File

@ -37,8 +37,7 @@ public class OneCaseExecute extends TestControl {
TaskScheduling taskScheduling = GetServerAPI.cGetTaskSchedulingByTaskId(Integer.valueOf(taskid)); TaskScheduling taskScheduling = GetServerAPI.cGetTaskSchedulingByTaskId(Integer.valueOf(taskid));
if (taskScheduling.getTaskType() == 0) { if (taskScheduling.getTaskType() == 0) {
// ½Ó¿Ú²âÊÔ // ½Ó¿Ú²âÊÔ
TestCaseExecution.oneCaseExecuteForTast(taskScheduling.getProject().getProjectName(), testCaseExternalId, version, TestCaseExecution.oneCaseExecuteForTask(taskScheduling.getProject().getProjectName(), testCaseExternalId, String.valueOf(task.getTaskId()));
String.valueOf(task.getTaskId()));
} else if (taskScheduling.getTaskType() == 1) { } else if (taskScheduling.getTaskType() == 1) {
WebOneCaseExecute.oneCaseExecuteForTast(taskScheduling.getProject().getProjectName(), testCaseExternalId, version, WebOneCaseExecute.oneCaseExecuteForTast(taskScheduling.getProject().getProjectName(), testCaseExternalId, version,

View File

@ -143,7 +143,7 @@ public class AppTestControl {
LogOperation caselog = new LogOperation(); LogOperation caselog = new LogOperation();
List<ProjectCase> cases = GetServerAPI.getCasesbyplanId(taskScheduling.getPlanId()); List<ProjectCase> cases = GetServerAPI.getCasesbyplanId(taskScheduling.getPlanId());
luckyclient.publicclass.LogUtil.APP.info("当前计划中读取到用例共 " + cases.size() + ""); luckyclient.publicclass.LogUtil.APP.info("当前计划中读取到用例共 " + cases.size() + "");
LogOperation.updateTastStatus(taskId, cases.size()); LogOperation.updateTaskExecuteStatus(taskId, cases.size());
for (ProjectCase testcase : cases) { for (ProjectCase testcase : cases) {
List<ProjectCaseSteps> steps = GetServerAPI.getStepsbycaseid(testcase.getCaseId()); List<ProjectCaseSteps> steps = GetServerAPI.getStepsbycaseid(testcase.getCaseId());
@ -166,7 +166,7 @@ public class AppTestControl {
} }
luckyclient.publicclass.LogUtil.APP.info("当前用例:【" + testcase.getCaseSign() + "】执行完成......进入下一条"); luckyclient.publicclass.LogUtil.APP.info("当前用例:【" + testcase.getCaseSign() + "】执行完成......进入下一条");
} }
tastcount = LogOperation.updateTastdetail(taskId, cases.size()); tastcount = LogOperation.updateTaskExecuteData(taskId, cases.size());
String testtime = LogOperation.getTestTime(taskId); String testtime = LogOperation.getTestTime(taskId);
luckyclient.publicclass.LogUtil.APP.info("当前项目【" + projectname + "】测试计划中的用例已经全部执行完成..."); luckyclient.publicclass.LogUtil.APP.info("当前项目【" + projectname + "】测试计划中的用例已经全部执行完成...");
MailSendInitialization.sendMailInitialization(HtmlMail.htmlSubjectFormat(jobname), MailSendInitialization.sendMailInitialization(HtmlMail.htmlSubjectFormat(jobname),

View File

@ -1,7 +1,6 @@
package luckyclient.caserun.exappium; package luckyclient.caserun.exappium;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.util.Properties; import java.util.Properties;
import io.appium.java_client.service.local.AppiumDriverLocalService; import io.appium.java_client.service.local.AppiumDriverLocalService;

View File

@ -57,14 +57,12 @@ public class AndroidBatchExecute {
.cgetParamsByProjectid(task.getProjectId().toString()); .cgetParamsByProjectid(task.getProjectId().toString());
// 执行全部非成功状态用例 // 执行全部非成功状态用例
if (batchcase.indexOf("ALLFAIL") > -1) { if (batchcase.indexOf("ALLFAIL") > -1) {
String casemore = caselog.unSucCaseUpdate(taskid); List<Integer> caseIdList = caselog.getCaseListForUnSucByTaskId(taskid);
String[] temp = casemore.split("\\#", -1); for (int i = 0; i < caseIdList.size(); i++) {
for (int i = 0; i < temp.length; i++) { ProjectCase testcase = GetServerAPI.cGetCaseByCaseId(caseIdList.get(i));
String testCaseExternalId = temp[i].substring(0, temp[i].indexOf("%"));
ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId);
List<ProjectCaseSteps> steps = GetServerAPI.getStepsbycaseid(testcase.getCaseId()); List<ProjectCaseSteps> steps = GetServerAPI.getStepsbycaseid(testcase.getCaseId());
// 删除旧的日志 // 删除旧的日志
LogOperation.deleteCaseLogDetail(testCaseExternalId, taskid); LogOperation.deleteTaskCaseLog(testcase.getCaseId(), taskid);
try { try {
AndroidCaseExecution.caseExcution(testcase, steps, taskid, ad, caselog, pcplist); AndroidCaseExecution.caseExcution(testcase, steps, taskid, ad, caselog, pcplist);
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -82,7 +80,7 @@ public class AndroidBatchExecute {
ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId); ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId);
List<ProjectCaseSteps> steps = GetServerAPI.getStepsbycaseid(testcase.getCaseId()); List<ProjectCaseSteps> steps = GetServerAPI.getStepsbycaseid(testcase.getCaseId());
// 删除旧的日志 // 删除旧的日志
LogOperation.deleteCaseLogDetail(testCaseExternalId, taskid); LogOperation.deleteTaskCaseLog(testcase.getCaseId(), taskid);
try { try {
AndroidCaseExecution.caseExcution(testcase, steps, taskid, ad, caselog, pcplist); AndroidCaseExecution.caseExcution(testcase, steps, taskid, ad, caselog, pcplist);
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -92,7 +90,7 @@ public class AndroidBatchExecute {
} }
} }
} }
LogOperation.updateTastdetail(taskid, 0); LogOperation.updateTaskExecuteData(taskid, 0);
ad.closeApp(); ad.closeApp();
//关闭Appium服务的线程 //关闭Appium服务的线程
if(as!=null){ if(as!=null){

View File

@ -52,8 +52,8 @@ public class AndroidOneCaseExecute {
} }
LogOperation caselog = new LogOperation(); LogOperation caselog = new LogOperation();
// 删除旧的日志 // 删除旧的日志
LogOperation.deleteCaseLogDetail(testCaseExternalId, taskid);
ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId); ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId);
LogOperation.deleteTaskCaseLog(testcase.getCaseId(), taskid);
List<ProjectCaseParams> pcplist = GetServerAPI.cgetParamsByProjectid(String.valueOf(testcase.getProjectId())); List<ProjectCaseParams> pcplist = GetServerAPI.cgetParamsByProjectid(String.valueOf(testcase.getProjectId()));
luckyclient.publicclass.LogUtil.APP.info("开始执行用例:【" + testCaseExternalId + "】......"); luckyclient.publicclass.LogUtil.APP.info("开始执行用例:【" + testCaseExternalId + "】......");
try { try {
@ -64,7 +64,7 @@ public class AndroidOneCaseExecute {
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e); luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
e.printStackTrace(); e.printStackTrace();
} }
LogOperation.updateTastdetail(taskid, 0); LogOperation.updateTaskExecuteData(taskid, 0);
ad.closeApp(); ad.closeApp();
//关闭Appium服务的线程 //关闭Appium服务的线程
if(as!=null){ if(as!=null){

View File

@ -57,14 +57,12 @@ public class IosBatchExecute {
.cgetParamsByProjectid(task.getProjectId().toString()); .cgetParamsByProjectid(task.getProjectId().toString());
// 执行全部非成功状态用例 // 执行全部非成功状态用例
if (batchcase.indexOf("ALLFAIL") > -1) { if (batchcase.indexOf("ALLFAIL") > -1) {
String casemore = caselog.unSucCaseUpdate(taskid); List<Integer> caseIdList = caselog.getCaseListForUnSucByTaskId(taskid);
String[] temp = casemore.split("\\#", -1); for (int i = 0; i < caseIdList.size(); i++) {
for (int i = 0; i < temp.length; i++) { ProjectCase testcase = GetServerAPI.cGetCaseByCaseId(caseIdList.get(i));
String testCaseExternalId = temp[i].substring(0, temp[i].indexOf("%"));
ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId);
List<ProjectCaseSteps> steps = GetServerAPI.getStepsbycaseid(testcase.getCaseId()); List<ProjectCaseSteps> steps = GetServerAPI.getStepsbycaseid(testcase.getCaseId());
// 删除旧的日志 // 删除旧的日志
LogOperation.deleteCaseLogDetail(testCaseExternalId, taskid); LogOperation.deleteTaskCaseLog(testcase.getCaseId(), taskid);
try { try {
IosCaseExecution.caseExcution(testcase, steps, taskid, iosd, caselog, pcplist); IosCaseExecution.caseExcution(testcase, steps, taskid, iosd, caselog, pcplist);
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -82,7 +80,7 @@ public class IosBatchExecute {
ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId); ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId);
List<ProjectCaseSteps> steps = GetServerAPI.getStepsbycaseid(testcase.getCaseId()); List<ProjectCaseSteps> steps = GetServerAPI.getStepsbycaseid(testcase.getCaseId());
// 删除旧的日志 // 删除旧的日志
LogOperation.deleteCaseLogDetail(testCaseExternalId, taskid); LogOperation.deleteTaskCaseLog(testcase.getCaseId(), taskid);
try { try {
IosCaseExecution.caseExcution(testcase, steps, taskid, iosd, caselog, pcplist); IosCaseExecution.caseExcution(testcase, steps, taskid, iosd, caselog, pcplist);
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -92,7 +90,7 @@ public class IosBatchExecute {
} }
} }
} }
LogOperation.updateTastdetail(taskid, 0); LogOperation.updateTaskExecuteData(taskid, 0);
iosd.closeApp(); iosd.closeApp();
//关闭Appium服务的线程 //关闭Appium服务的线程
if(as!=null){ if(as!=null){

View File

@ -51,9 +51,10 @@ public class IosOneCaseExecute {
e1.printStackTrace(); e1.printStackTrace();
} }
LogOperation caselog = new LogOperation(); LogOperation caselog = new LogOperation();
// 删除旧的日志
LogOperation.deleteCaseLogDetail(testCaseExternalId, taskid);
ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId); ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId);
// 删除旧的日志
LogOperation.deleteTaskCaseLog(testcase.getCaseId(), taskid);
List<ProjectCaseParams> pcplist = GetServerAPI.cgetParamsByProjectid(String.valueOf(testcase.getProjectId())); List<ProjectCaseParams> pcplist = GetServerAPI.cgetParamsByProjectid(String.valueOf(testcase.getProjectId()));
luckyclient.publicclass.LogUtil.APP.info("开始执行用例:【" + testCaseExternalId + "】......"); luckyclient.publicclass.LogUtil.APP.info("开始执行用例:【" + testCaseExternalId + "】......");
try { try {
@ -64,7 +65,7 @@ public class IosOneCaseExecute {
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e); luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
e.printStackTrace(); e.printStackTrace();
} }
LogOperation.updateTastdetail(taskid, 0); LogOperation.updateTaskExecuteData(taskid, 0);
iosd.closeApp(); iosd.closeApp();
//关闭Appium服务的线程 //关闭Appium服务的线程
if(as!=null){ if(as!=null){

View File

@ -10,7 +10,6 @@ import br.eti.kinoshita.testlinkjavaapi.util.TestLinkAPIException;
import luckyclient.caserun.exinterface.analyticsteps.InterfaceAnalyticCase; import luckyclient.caserun.exinterface.analyticsteps.InterfaceAnalyticCase;
import luckyclient.caserun.publicdispose.ActionManageForSteps; import luckyclient.caserun.publicdispose.ActionManageForSteps;
import luckyclient.caserun.publicdispose.ChangString; import luckyclient.caserun.publicdispose.ChangString;
import luckyclient.dblog.LogOperation;
import luckyclient.publicclass.InvokeMethod; import luckyclient.publicclass.InvokeMethod;
import luckyclient.publicclass.remoterinterface.HttpRequest; import luckyclient.publicclass.remoterinterface.HttpRequest;
import luckyclient.serverapi.api.GetServerAPI; import luckyclient.serverapi.api.GetServerAPI;
@ -226,22 +225,6 @@ public class ApiTestCaseDebug {
} }
} }
/**
* 获取指定任务名称以及用例号报错日志中的执行预期结果 casestatus说明 pass:0 fail:1 lock:2 unexcute:4
*/
public static String getLogDetailExpectresult(String taskname, String caseno, int casestatus) {
int taskid = LogOperation.getTaskExcuteTaskid(taskname);
return LogOperation.getLogDetailExpectResult(taskid, caseno, casestatus);
}
/**
* 获取指定任务名称以及用例号报错日志中的执行测试结果 casestatus说明 pass:0 fail:1 lock:2 unexcute:4
*/
public static String getLogDetailRunresult(String taskname, String caseno, int casestatus) {
int taskid = LogOperation.getTaskExcuteTaskid(taskname);
return LogOperation.getLogDetailTestResult(taskid, caseno, casestatus);
}
/** /**
* 更新系统中用例指定步骤的预期结果 * 更新系统中用例指定步骤的预期结果
*/ */

View File

@ -1,12 +1,13 @@
package luckyclient.caserun.exinterface; package luckyclient.caserun.exinterface;
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import luckyclient.dblog.LogOperation; import luckyclient.dblog.LogOperation;
import luckyclient.serverapi.api.GetServerAPI; import luckyclient.serverapi.api.GetServerAPI;
import luckyclient.serverapi.entity.TaskExecute; import luckyclient.serverapi.entity.ProjectCase;
/** /**
* ================================================================= * =================================================================
@ -36,21 +37,18 @@ public class BatchTestCaseExecution {
if(batchcase.indexOf("ALLFAIL")>-1){ if(batchcase.indexOf("ALLFAIL")>-1){
//初始化写用例结果以及日志模块 //初始化写用例结果以及日志模块
LogOperation caselog = new LogOperation(); LogOperation caselog = new LogOperation();
String casemore = caselog.unSucCaseUpdate(taskid); List<Integer> caseIdList = caselog.getCaseListForUnSucByTaskId(taskid);
String[] temp=casemore.split("\\#",-1); for(int i=0;i<caseIdList.size();i++){
for(int i=0;i<temp.length;i++){ ProjectCase testcase = GetServerAPI.cGetCaseByCaseId(caseIdList.get(i));
String testCaseExternalId = temp[i].substring(0, temp[i].indexOf("%"));
int version = Integer.parseInt(temp[i].substring(temp[i].indexOf("%")+1,temp[i].length()-1));
TestControl.THREAD_COUNT++; //多线程计数++用于检测线程是否全部执行完 TestControl.THREAD_COUNT++; //多线程计数++用于检测线程是否全部执行完
threadExecute.execute(new ThreadForBatchCase(projectname,testCaseExternalId,version,taskid)); threadExecute.execute(new ThreadForBatchCase(projectname,testcase.getCaseSign(),taskid));
} }
}else{ //批量执行用例 }else{ //批量执行用例
String[] temp=batchcase.split("\\#",-1); String[] temp=batchcase.split("\\#",-1);
for(int i=0;i<temp.length-1;i++){ for(int i=0;i<temp.length-1;i++){
String testCaseExternalId = temp[i].substring(0, temp[i].indexOf("%")); String testCaseExternalId = temp[i].substring(0, temp[i].indexOf("%"));
int version = Integer.parseInt(temp[i].substring(temp[i].indexOf("%")+1,temp[i].length()));
TestControl.THREAD_COUNT++; //多线程计数++用于检测线程是否全部执行完 TestControl.THREAD_COUNT++; //多线程计数++用于检测线程是否全部执行完
threadExecute.execute(new ThreadForBatchCase(projectname,testCaseExternalId,version,taskid)); threadExecute.execute(new ThreadForBatchCase(projectname,testCaseExternalId,taskid));
} }
} }
//多线程计数用于检测线程是否全部执行完 //多线程计数用于检测线程是否全部执行完

View File

@ -53,7 +53,7 @@ public class TestCaseExecution {
* @param version 用例版本号 * @param version 用例版本号
* 用于单条用例调试并通过日志框架写日志到UTP上用做UTP上单条用例运行 * 用于单条用例调试并通过日志框架写日志到UTP上用做UTP上单条用例运行
*/ */
public static void oneCaseExecuteForTast(String projectname, String testCaseExternalId, int version, String taskid) { public static void oneCaseExecuteForTask(String projectname, String testCaseExternalId, String taskid) {
TestControl.TASKID = taskid; TestControl.TASKID = taskid;
DbLink.exetype = 0; DbLink.exetype = 0;
// 初始化写用例结果以及日志模块 // 初始化写用例结果以及日志模块
@ -65,9 +65,10 @@ public class TestCaseExecution {
Object[] getParameterValues = null; Object[] getParameterValues = null;
String testnote = "初始化测试结果"; String testnote = "初始化测试结果";
int k = 0; int k = 0;
// 删除旧的日志
LogOperation.deleteCaseLogDetail(testCaseExternalId, taskid);
ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId); ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId);
// 删除旧的日志
LogOperation.deleteTaskCaseLog(testcase.getCaseId(), taskid);
List<ProjectCaseParams> pcplist = GetServerAPI.cgetParamsByProjectid(String.valueOf(testcase.getProjectId())); List<ProjectCaseParams> pcplist = GetServerAPI.cgetParamsByProjectid(String.valueOf(testcase.getProjectId()));
// 把公共参数加入到MAP中 // 把公共参数加入到MAP中
for (ProjectCaseParams pcp : pcplist) { for (ProjectCaseParams pcp : pcplist) {
@ -178,7 +179,7 @@ public class TestCaseExecution {
luckyclient.publicclass.LogUtil.APP.error("用例 " + testCaseExternalId + "在执行过程中失败,请检查日志!"); luckyclient.publicclass.LogUtil.APP.error("用例 " + testCaseExternalId + "在执行过程中失败,请检查日志!");
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "在执行过程中失败,请检查日志!", "error", "EXECUTECASESUC...", ""); caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "在执行过程中失败,请检查日志!", "error", "EXECUTECASESUC...", "");
} }
LogOperation.updateTastdetail(taskid, 0); LogOperation.updateTaskExecuteData(taskid, 0);
} }
/** /**

View File

@ -108,7 +108,7 @@ public class TestControl {
new ArrayBlockingQueue<Runnable>(1000), new ThreadPoolExecutor.CallerRunsPolicy()); new ArrayBlockingQueue<Runnable>(1000), new ThreadPoolExecutor.CallerRunsPolicy());
List<ProjectCase> cases = GetServerAPI.getCasesbyplanId(taskScheduling.getPlanId()); List<ProjectCase> cases = GetServerAPI.getCasesbyplanId(taskScheduling.getPlanId());
LogOperation.updateTastStatus(taskid, cases.size()); LogOperation.updateTaskExecuteStatus(taskid, cases.size());
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);
@ -146,7 +146,7 @@ public class TestControl {
} }
Thread.sleep(6000); Thread.sleep(6000);
} }
tastcount = LogOperation.updateTastdetail(taskid, cases.size()); tastcount = LogOperation.updateTaskExecuteData(taskid, cases.size());
String testtime = LogOperation.getTestTime(taskid); String testtime = LogOperation.getTestTime(taskid);
MailSendInitialization.sendMailInitialization(HtmlMail.htmlSubjectFormat(jobname), MailSendInitialization.sendMailInitialization(HtmlMail.htmlSubjectFormat(jobname),

View File

@ -15,19 +15,17 @@ public class ThreadForBatchCase extends Thread{
private String projectname; private String projectname;
private String testCaseExternalId; private String testCaseExternalId;
private int version; private String taskid;
private String tastid;
public ThreadForBatchCase(String projectname,String testCaseExternalId,int version,String tastid){ public ThreadForBatchCase(String projectname,String testCaseExternalId,String taskid){
this.projectname = projectname; this.projectname = projectname;
this.testCaseExternalId = testCaseExternalId; this.testCaseExternalId = testCaseExternalId;
this.version = version; this.taskid = taskid;
this.tastid = tastid;
} }
@Override @Override
public void run(){ public void run(){
TestCaseExecution.oneCaseExecuteForTast(projectname, testCaseExternalId, version, tastid); TestCaseExecution.oneCaseExecuteForTask(projectname, testCaseExternalId, taskid);
TestControl.THREAD_COUNT--; //多线程计数--用于检测线程是否全部执行完 TestControl.THREAD_COUNT--; //多线程计数--用于检测线程是否全部执行完
} }

View File

@ -1,35 +1,13 @@
package luckyclient.caserun.exwebdriver; package luckyclient.caserun.exwebdriver;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
public class TestGoogle { public class TestGoogle {
public static void main(String[] args) throws InterruptedException, IOException { public static void main(String[] args) throws InterruptedException, IOException {
// TODO Auto-generated method stub // TODO Auto-generated method stub
WebDriver driver = WebDriverInitialization.setWebDriverForLocal();
driver.get("http://10.213.23.35:8080/ysuser_manager/login.do?method=login");
driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
Thread.sleep(20000);
driver.findElement(By.xpath(".//*[@id='tt1']/li[1]/ul/li[2]/div/span[4]/a/span")).click();
WebElement we = driver.findElement(By.xpath(".//*[@src='/ysuser_manager/login.do?method=geturl&limitid=2014020511&homepath=http:']"));
driver.switchTo().frame(we);
// driver.switchTo().frame("mainForm");
WebElement element1 = driver.findElement(By.xpath(".//*[@id='mercId']"));
element1.sendKeys("m00000000000329");
WebElement element2 = driver.findElement(By.xpath("html/body/table[1]/tbody/tr/td[2]"));
String aaa = element2.getText();
String aaaa = element2.getTagName();
element2.getLocation();
/* driver.findElement(By.xpath("html/body/div[1]/div/span[2]/select")).click();
Select select = new Select(driver.findElement(By.xpath("html/body/div[1]/div/span[2]/select")));
List<WebElement> we= select.getAllSelectedOptions();
select.selectByIndex(2);*/
} }
} }

View File

@ -114,7 +114,7 @@ public class WebTestControl {
List<ProjectCase> cases = GetServerAPI.getCasesbyplanId(taskScheduling.getPlanId()); List<ProjectCase> cases = GetServerAPI.getCasesbyplanId(taskScheduling.getPlanId());
luckyclient.publicclass.LogUtil.APP.info("当前计划中读取到用例共 " + cases.size() + ""); luckyclient.publicclass.LogUtil.APP.info("当前计划中读取到用例共 " + cases.size() + "");
LogOperation.updateTastStatus(taskid, cases.size()); LogOperation.updateTaskExecuteStatus(taskid, cases.size());
for (ProjectCase testcase : cases) { for (ProjectCase testcase : cases) {
List<ProjectCaseSteps> steps = GetServerAPI.getStepsbycaseid(testcase.getCaseId()); List<ProjectCaseSteps> steps = GetServerAPI.getStepsbycaseid(testcase.getCaseId());
@ -133,7 +133,7 @@ public class WebTestControl {
} }
luckyclient.publicclass.LogUtil.APP.info("当前用例:【" + testcase.getCaseSign() + "】执行完成......进入下一条"); luckyclient.publicclass.LogUtil.APP.info("当前用例:【" + testcase.getCaseSign() + "】执行完成......进入下一条");
} }
tastcount = LogOperation.updateTastdetail(taskid, cases.size()); tastcount = LogOperation.updateTaskExecuteData(taskid, cases.size());
String testtime = LogOperation.getTestTime(taskid); String testtime = LogOperation.getTestTime(taskid);
luckyclient.publicclass.LogUtil.APP.info("当前项目【" + projectname + "】测试计划中的用例已经全部执行完成..."); luckyclient.publicclass.LogUtil.APP.info("当前项目【" + projectname + "】测试计划中的用例已经全部执行完成...");

View File

@ -46,15 +46,12 @@ public class WebBatchExecute{
List<ProjectCaseParams> pcplist=GetServerAPI.cgetParamsByProjectid(task.getProjectId().toString()); List<ProjectCaseParams> pcplist=GetServerAPI.cgetParamsByProjectid(task.getProjectId().toString());
//执行全部非成功状态用例 //执行全部非成功状态用例
if(batchcase.indexOf("ALLFAIL")>-1){ if(batchcase.indexOf("ALLFAIL")>-1){
String casemore = caselog.unSucCaseUpdate(taskid); List<Integer> caseIdList = caselog.getCaseListForUnSucByTaskId(taskid);
String[] temp=casemore.split("\\#",-1); for(int i=0;i<caseIdList.size();i++){
for(int i=0;i<temp.length;i++){ ProjectCase testcase = GetServerAPI.cGetCaseByCaseId(caseIdList.get(i));
String testCaseExternalId = temp[i].substring(0, temp[i].indexOf("%"));
//int version = Integer.parseInt(temp[i].substring(temp[i].indexOf("%")+1,temp[i].length()-1));
ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId);
List<ProjectCaseSteps> steps=GetServerAPI.getStepsbycaseid(testcase.getCaseId()); List<ProjectCaseSteps> steps=GetServerAPI.getStepsbycaseid(testcase.getCaseId());
//删除旧的日志 //删除旧的日志
LogOperation.deleteCaseLogDetail(testCaseExternalId, taskid); LogOperation.deleteTaskCaseLog(testcase.getCaseId(), taskid);
try { try {
WebCaseExecution.caseExcution(testcase, steps, taskid,wd,caselog,pcplist); WebCaseExecution.caseExcution(testcase, steps, taskid,wd,caselog,pcplist);
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -71,7 +68,7 @@ public class WebBatchExecute{
ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId); ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId);
List<ProjectCaseSteps> steps=GetServerAPI.getStepsbycaseid(testcase.getCaseId()); List<ProjectCaseSteps> steps=GetServerAPI.getStepsbycaseid(testcase.getCaseId());
//删除旧的日志 //删除旧的日志
LogOperation.deleteCaseLogDetail(testCaseExternalId, taskid); LogOperation.deleteTaskCaseLog(testcase.getCaseId(), taskid);
try { try {
WebCaseExecution.caseExcution(testcase, steps,taskid,wd,caselog,pcplist); WebCaseExecution.caseExcution(testcase, steps,taskid,wd,caselog,pcplist);
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -81,7 +78,7 @@ public class WebBatchExecute{
} }
} }
} }
LogOperation.updateTastdetail(taskid, 0); LogOperation.updateTaskExecuteData(taskid, 0);
//关闭浏览器 //关闭浏览器
wd.quit(); wd.quit();
} }

View File

@ -40,9 +40,10 @@ public class WebOneCaseExecute{
e1.printStackTrace(); e1.printStackTrace();
} }
LogOperation caselog = new LogOperation(); LogOperation caselog = new LogOperation();
//删除旧的日志
LogOperation.deleteCaseLogDetail(testCaseExternalId, taskid);
ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId); ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId);
//删除旧的日志
LogOperation.deleteTaskCaseLog(testcase.getCaseId(), taskid);
List<ProjectCaseParams> pcplist=GetServerAPI.cgetParamsByProjectid(String.valueOf(testcase.getProjectId())); List<ProjectCaseParams> pcplist=GetServerAPI.cgetParamsByProjectid(String.valueOf(testcase.getProjectId()));
luckyclient.publicclass.LogUtil.APP.info("开始执行用例:【"+testCaseExternalId+"】......"); luckyclient.publicclass.LogUtil.APP.info("开始执行用例:【"+testCaseExternalId+"】......");
try { try {
@ -53,7 +54,7 @@ public class WebOneCaseExecute{
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e); luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
e.printStackTrace(); e.printStackTrace();
} }
LogOperation.updateTastdetail(taskid, 0); LogOperation.updateTaskExecuteData(taskid, 0);
//关闭浏览器 //关闭浏览器
wd.quit(); wd.quit();
} }

View File

@ -1,12 +1,15 @@
package luckyclient.dblog; package luckyclient.dblog;
import luckyclient.publicclass.DBOperation;
import luckyclient.serverapi.api.PostServerAPI;
import org.apache.commons.lang3.StringUtils;
import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.List;
import com.alibaba.fastjson.JSONObject;
import luckyclient.publicclass.DBOperation;
import luckyclient.serverapi.api.GetServerAPI;
import luckyclient.serverapi.api.PostServerAPI;
import luckyclient.serverapi.entity.TaskExecute;
import luckyclient.serverapi.entity.TaskScheduling;
/** /**
* ================================================================= * =================================================================
@ -62,139 +65,66 @@ public class LogOperation {
/** /**
* 更新本次任务的执行统计情况 * 更新本次任务的执行统计情况
* 状态 0未执行 1执行中 2执行完成 3执行失败 4唤起客户端失败
*/ */
public static int[] updateTastdetail(String taskid, int casecount) { public static int[] updateTaskExecuteData(String taskIdStr, int caseCount) {
int[] taskcount = null; int[] taskcount = null;
if (0 == exetype) { if (0 == exetype) {
try { Integer taskId = Integer.parseInt(taskIdStr);
int id = Integer.parseInt(taskid); String str = PostServerAPI.clientUpdateTaskExecuteData(taskId, caseCount,2);
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); JSONObject jsonObject = JSONObject.parseObject(str);
String casesucsql = dbt.executeQuery( // 返回本次任务执行情况
"select count(*) from test_casedetail where taskid = " + id + " and casestatus = 0"); taskcount = new int[5];
String casefailsql = dbt.executeQuery( taskcount[0] = jsonObject.getInteger("caseCount");
"select count(*) from test_casedetail where taskid = " + id + " and casestatus = 1"); taskcount[1] = jsonObject.getInteger("caseSuc");
String caselocksql = dbt.executeQuery( taskcount[2] = jsonObject.getInteger("caseFail");
"select count(*) from test_casedetail where taskid = " + id + " and casestatus = 2"); taskcount[3] = jsonObject.getInteger("caseLock");
String casenoexesql = dbt.executeQuery( taskcount[4] = jsonObject.getInteger("caseNoExec");
"select count(*) from test_casedetail where taskid = " + id + " and casestatus = 4");
int casesuc = Integer.parseInt(casesucsql.substring(0, casesucsql.indexOf("%")));
int casefail = Integer.parseInt(casefailsql.substring(0, casefailsql.indexOf("%")));
int caselock = Integer.parseInt(caselocksql.substring(0, caselocksql.indexOf("%")));
int casenoexec = Integer.parseInt(casenoexesql.substring(0, casenoexesql.indexOf("%")));
if (casecount == 0) {
casecount = casesuc + casefail + caselock + casenoexec;
}
// 返回本次任务执行情况
taskcount = new int[5];
taskcount[0] = casecount;
taskcount[1] = casesuc;
taskcount[2] = casefail;
taskcount[3] = caselock;
taskcount[4] = casenoexec;
String sql = "update test_taskexcute set casetotal_count = " + casecount + ",casesucc_count = "
+ casesuc + ",casefail_count = " + casefail + ",caselock_count = " + caselock
+ ",casenoexec_count = " + casenoexec + ",finishtime = str_to_date('" + df.format(new Date())
+ "','%Y-%m-%d %T'), " + "taskStatus = 2 where id = " + id;
dbt.executeSql(sql);
} catch (Exception e) {
// TODO Auto-generated catch block
luckyclient.publicclass.LogUtil.APP.error("执行更新本次任务执行统计情况SQL出现异常请确认数据库链接是否正常", e);
e.printStackTrace();
}
} }
return taskcount; return taskcount;
} }
/** /**
* 更新本次任务的执行状态 * 更新本次任务的执行状态
* 状态 0未执行 1执行中 2执行完成 3执行失败 4唤起客户端失败
*/ */
public static void updateTastStatus(String taskid, int casecount) { public static void updateTaskExecuteStatus(String taskIdStr, int caseCount) {
if (0 == exetype) { if (0 == exetype) {
try { Integer taskId = Integer.parseInt(taskIdStr);
int id = Integer.parseInt(taskid); PostServerAPI.clientUpdateTaskExecuteData(taskId, caseCount,1);
String sql = "update test_taskexcute set casetotal_count= " + casecount + ",taskStatus = 1 where id = "
+ id;
dbt.executeSql(sql);
} catch (Exception e) {
// TODO Auto-generated catch block
luckyclient.publicclass.LogUtil.APP.error("执行更新本次任务的执行状态SQL出现异常请确认数据库链接是否正常", e);
e.printStackTrace();
}
} }
} }
/** /**
* 删除单次任务指定的用例日志明细 * 删除单次任务指定的用例日志明细
*/ */
public static void deleteCaseLogDetail(String caseno, String taskid) { public static void deleteTaskCaseLog(Integer caseId, String taskIdStr) {
int inttaskid = Integer.parseInt(taskid); Integer taskId = Integer.parseInt(taskIdStr);
String casesidsql; PostServerAPI.clientDeleteTaskCaseLog(taskId, caseId);
try {
casesidsql = dbt.executeQuery(
"select id from test_casedetail t where caseno = '" + caseno + "' and taskid = " + inttaskid);
int casesid = Integer.parseInt(casesidsql.substring(0, casesidsql.lastIndexOf("%")));
// 删除原来的日志
dbt.executeSql("delete from test_logdetail where caseid = " + casesid + " and taskid = " + inttaskid);
} catch (Exception e) {
// TODO Auto-generated catch block
luckyclient.publicclass.LogUtil.APP.error("执行删除单次任务指定的用例日志明细SQL出现异常请确认数据库链接是否正常", e);
e.printStackTrace();
}
} }
/** /**
* 删除单次任务指定的用例明细 * 取出指定任务ID中的不属于成功状态的用例ID
*/ */
public static void deleteCaseDetail(String caseno, String taskid) { public List<Integer> getCaseListForUnSucByTaskId(String taskIdStr) {
int inttaskid = Integer.parseInt(taskid); int taskId = Integer.parseInt(taskIdStr);
try { return GetServerAPI.clientGetCaseListForUnSucByTaskId(taskId);
// 删除原来的用例
dbt.executeSql("delete from test_casedetail where caseno = '" + caseno + "' and taskid = " + inttaskid);
} catch (Exception e) {
// TODO Auto-generated catch block
luckyclient.publicclass.LogUtil.APP.error("执行删除单次任务指定的用例明细SQL出现异常请确认数据库链接是否正常", e);
e.printStackTrace();
}
} }
/** /**
* 取出指定任务ID中的不属于成功状态的用例编写以及版本号 * 取出指定任务ID中所属的调度是否要发送邮件状态及收件人地址 发送邮件通知时的具体逻辑, -1-不通知 0-全部1-成功2-失败
*/
public String unSucCaseUpdate(String taskid) {
int inttaskid = Integer.parseInt(taskid);
String casesidsql = null;
try {
casesidsql = dbt.executeQuery("select caseno,caseversion from test_casedetail t where t.taskid = "
+ inttaskid + " and t.casestatus <> 0");
} catch (Exception e) {
// TODO Auto-generated catch block
luckyclient.publicclass.LogUtil.APP.error("执行取出指定任务ID中的不属于成功状态的用例编写以及版本号SQL出现异常请确认数据库链接是否正常", e);
e.printStackTrace();
}
return casesidsql;
}
/**
* 取出指定任务ID中所属的调度是否要发送邮件状态及收件人地址 isSendMail varchar(1) default(0); --0 不发送 1
* 发送 eMailer varchar(100) ; --收件人 * 发送 eMailer varchar(100) ; --收件人
*/ */
public static String[] getEmailAddress(String taskid) { public static String[] getEmailAddress(String taskIdStr) {
int inttaskid = Integer.parseInt(taskid); Integer taskId = Integer.parseInt(taskIdStr);
String casesidsql = null;
String[] address = null; String[] address = null;
try { try {
casesidsql = dbt.executeQuery( TaskScheduling taskScheduling = GetServerAPI.cGetTaskSchedulingByTaskId(taskId);
"select t.issendmail,t.emailer from test_jobs t where id in (select jobid from test_taskexcute t where t.id = " if (taskScheduling.getEmailSendCondition()!=-1) {
+ inttaskid + ")"); String temp = taskScheduling.getEmailAddress();
String status = casesidsql.substring(0, casesidsql.indexOf("%"));
if ("1".equals(status)) {
String temp = casesidsql.substring(casesidsql.indexOf("%") + 1, casesidsql.length() - 1);
// 清除最后一个; // 清除最后一个;
if (temp.indexOf(";") > -1 && temp.substring(temp.length() - 1, temp.length()).indexOf(";") > -1) { if (temp.indexOf(";") > -1 && temp.substring(temp.length() - 1, temp.length()).indexOf(";") > -1) {
temp = temp.substring(0, temp.length() - 1); temp = temp.substring(0, temp.length() - 1);
@ -210,7 +140,6 @@ public class LogOperation {
} }
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
luckyclient.publicclass.LogUtil.APP.error("执行取出指定任务ID中所属的调度是否要发送邮件状态及收件人地址SQL出现异常请确认数据库链接是否正常", e);
e.printStackTrace(); e.printStackTrace();
return address; return address;
} }
@ -218,23 +147,17 @@ public class LogOperation {
} }
/** /**
* 取出指定任务ID中所属的调度是否要自动构建以及构建的项目名称 isBuilding varchar(1) default(0); --0 * 取出指定任务ID中所属的调度是否要自动构建以及构建的项目名称 为空时不构建
* 不自动构建 1 自动构建 BuildName varchar(100) ; --构建项目名称
*/ */
public static String[] getBuildName(String taskid) { public static String[] getBuildName(String taskIdStr) {
int inttaskid = Integer.parseInt(taskid); Integer taskId = Integer.parseInt(taskIdStr);
String casesidsql = null;
String[] buildname = null; String[] buildname = null;
try { try {
casesidsql = dbt.executeQuery( TaskScheduling taskScheduling = GetServerAPI.cGetTaskSchedulingByTaskId(taskId);
"select t.isbuilding,t.buildname from test_jobs t where id in (select jobid from test_taskexcute t where t.id = " if (null == taskScheduling.getBuildingLink() || "".equals(taskScheduling.getBuildingLink())) {
+ inttaskid + ")");
if (null == casesidsql || "".equals(casesidsql)) {
return buildname; return buildname;
} }else{
String status = casesidsql.substring(0, casesidsql.indexOf("%")); String temp = taskScheduling.getBuildingLink();
if ("1".equals(status)) {
String temp = casesidsql.substring(casesidsql.indexOf("%") + 1, casesidsql.length() - 1);
// 清除最后一个; // 清除最后一个;
if (temp.indexOf(";") > -1 && temp.substring(temp.length() - 1, temp.length()).indexOf(";") > -1) { if (temp.indexOf(";") > -1 && temp.substring(temp.length() - 1, temp.length()).indexOf(";") > -1) {
temp = temp.substring(0, temp.length() - 1); temp = temp.substring(0, temp.length() - 1);
@ -250,7 +173,6 @@ public class LogOperation {
} }
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
luckyclient.publicclass.LogUtil.APP.error("执行取出指定任务ID中所属的调度是否要自动构建以及构建的项目名称SQL出现异常请确认数据库链接是否正常", e);
e.printStackTrace(); e.printStackTrace();
return buildname; return buildname;
} }
@ -258,26 +180,21 @@ public class LogOperation {
} }
/** /**
* 取出指定任务ID中所属的调度是否要自动重启TOMCAT isrestart varchar(1) default(0); --0 不自动重启 1 * 取出指定任务ID中所属的调度是否要自动重启TOMCAT
* 自动重启 restartcomm varchar(200) ; -- 格式服务器IP;服务器用户名;服务器密码;ssh端口;Shell命令; * 自动重启 restartcomm varchar(200) ; -- 格式服务器IP;服务器用户名;服务器密码;ssh端口;Shell命令;
* 192.168.222.22;pospsettle;pospsettle;22;cd * 192.168.222.22;pospsettle;pospsettle;22;cd
* /home/pospsettle/tomcat-7.0-7080/bin&&./restart.sh; * /home/pospsettle/tomcat-7.0-7080/bin&&./restart.sh;
*/ */
public static String[] getrestartcomm(String taskid) { public static String[] getRestartComm(String taskIdStr) {
int inttaskid = Integer.parseInt(taskid); Integer taskId = Integer.parseInt(taskIdStr);
String casesidsql = null;
String[] command = null; String[] command = null;
try { try {
casesidsql = dbt.executeQuery( TaskScheduling taskScheduling = GetServerAPI.cGetTaskSchedulingByTaskId(taskId);
"select t.isrestart,t.restartcomm from test_jobs t where id in (select jobid from test_taskexcute t where t.id = " if (null == taskScheduling.getRemoteShell() || "".equals(taskScheduling.getRemoteShell())) {
+ inttaskid + ")");
if (null == casesidsql || "".equals(casesidsql)) {
return command; return command;
} }else{
String status = casesidsql.substring(0, casesidsql.indexOf("%")); String temp = taskScheduling.getRemoteShell();
if ("1".equals(status)) {
String temp = casesidsql.substring(casesidsql.indexOf("%") + 1, casesidsql.length() - 1);
// 清除最后一个; // 清除最后一个;
if (temp.indexOf(";") > -1 && temp.substring(temp.length() - 1, temp.length()).indexOf(";") > -1) { if (temp.indexOf(";") > -1 && temp.substring(temp.length() - 1, temp.length()).indexOf(";") > -1) {
temp = temp.substring(0, temp.length() - 1); temp = temp.substring(0, temp.length() - 1);
@ -293,7 +210,6 @@ public class LogOperation {
} }
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
luckyclient.publicclass.LogUtil.APP.error("执行取出指定任务ID中所属的调度是否要自动重启TOMCAT SQL出现异常请确认数据库链接是否正常", e);
e.printStackTrace(); e.printStackTrace();
return command; return command;
} }
@ -301,42 +217,17 @@ public class LogOperation {
} }
/**
* 获取测试计划名称
*/
public static String getTestPlanName(String taskid) {
int inttaskid = Integer.parseInt(taskid);
String testplanname = "NULL";
try {
String sql = dbt.executeQuery(
"select t.testlinkname from test_jobs t where id in (select jobid from test_taskexcute t where t.id = "
+ inttaskid + ")");
testplanname = sql.substring(0, sql.lastIndexOf("%"));
} catch (Exception e) {
// TODO Auto-generated catch block
luckyclient.publicclass.LogUtil.APP.error("执行获取测试计划名称SQL出现异常请确认数据库链接是否正常", e);
e.printStackTrace();
return testplanname;
}
return testplanname;
}
/** /**
* 获取任务测试时长 * 获取任务测试时长
*/ */
public static String getTestTime(String taskid) { public static String getTestTime(String taskIdStr) {
int inttaskid = Integer.parseInt(taskid); Integer taskId = Integer.parseInt(taskIdStr);
String desTime = "计算测试时长出错!"; String desTime = "计算测试时长出错!";
try { try {
String sql = dbt.executeQuery( TaskExecute taskExecute = GetServerAPI.cgetTaskbyid(taskId);
"select date_format(t.createtime,'%Y-%m-%d %T'),date_format(t.finishtime,'%Y-%m-%d %T') from test_taskexcute t where t.id= " Date start = taskExecute.getCreateTime();
+ inttaskid); if (null!= taskExecute.getFinishTime()) {
String starttime = sql.substring(0, sql.indexOf("%")); Date finish = taskExecute.getFinishTime();
String finishtime = sql.substring(sql.indexOf("%") + 1, sql.length() - 1);
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date start = df.parse(starttime);
if (StringUtils.isNotBlank(finishtime) && !StringUtils.equalsIgnoreCase(finishtime, "null")) {
Date finish = df.parse(finishtime);
long l = finish.getTime() - start.getTime(); long l = finish.getTime() - start.getTime();
long day = l / (24 * 60 * 60 * 1000); long day = l / (24 * 60 * 60 * 1000);
long hour = (l / (60 * 60 * 1000) - day * 24); long hour = (l / (60 * 60 * 1000) - day * 24);
@ -347,7 +238,6 @@ public class LogOperation {
} }
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
luckyclient.publicclass.LogUtil.APP.error("执行获取任务测试时长SQL出现异常请确认数据库链接是否正常", e);
e.printStackTrace(); e.printStackTrace();
return desTime; return desTime;
} }
@ -355,88 +245,20 @@ public class LogOperation {
} }
/** /**
* 查询web执行浏览器类型 * 查询web执行浏览器类型 UI自动化浏览器类型 0 IE 1 火狐 2 谷歌 3 Edge
*/ */
public static int querydrivertype(String taskid) { public static int querydrivertype(String taskIdStr) {
int taskidtoint = Integer.parseInt(taskid); Integer taskId = Integer.parseInt(taskIdStr);
int drivertype = 0; Integer driverType = 0;
try { try {
String sqlresult = dbt.executeQuery( TaskScheduling taskScheduling = GetServerAPI.cGetTaskSchedulingByTaskId(taskId);
"select browsertype from test_jobs where id = (select jobid from test_taskexcute where id = " driverType = taskScheduling.getBrowserType();
+ taskidtoint + ")");
drivertype = Integer.parseInt(sqlresult.substring(0, sqlresult.lastIndexOf("%")));
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
luckyclient.publicclass.LogUtil.APP.error("执行查询web执行浏览器类型SQL出现异常请确认数据库链接是否正常", e);
e.printStackTrace(); e.printStackTrace();
return drivertype; return driverType;
} }
return drivertype; return driverType;
}
/**
* 查询任务中用例步骤日志执行实际结果
*/
public static String getLogDetailTestResult(int taskid, String caseno, int casestatus) {
String sqlresult = "";
try {
sqlresult = dbt.executeQuery(
"select detail from test_logdetail where logid=(select MIN(logid) from test_logdetail "
+ "where loggrade='error' and taskid=" + taskid
+ " and caseid=(select id from test_casedetail where taskid=" + taskid + " and caseno='"
+ caseno + "' and casestatus='" + casestatus + "'))");
if (sqlresult.indexOf("测试结果:") <= 0 || sqlresult.indexOf("%") <= 0) {
return sqlresult;
}
sqlresult = sqlresult.substring(sqlresult.indexOf("测试结果:") + 5, sqlresult.lastIndexOf("%"));
} catch (Exception e) {
// TODO Auto-generated catch block
luckyclient.publicclass.LogUtil.APP.error("执行查询任务中用例步骤日志执行实际结果SQL出现异常请确认数据库链接是否正常", e);
e.printStackTrace();
return sqlresult;
}
return sqlresult;
}
/**
* 根据任务名称查询任务ID
*/
public static int getTaskExcuteTaskid(String taskname) {
String sqlresult = "";
try {
sqlresult = dbt.executeQuery("select id from test_taskexcute t where t.taskid='" + taskname + "'");
sqlresult = sqlresult.substring(0, sqlresult.lastIndexOf("%"));
} catch (Exception e) {
// TODO Auto-generated catch block
luckyclient.publicclass.LogUtil.APP.error("执行根据任务名称查询任务ID SQL出现异常请确认数据库链接是否正常", e);
e.printStackTrace();
return Integer.parseInt(sqlresult);
}
return Integer.parseInt(sqlresult);
}
/**
* 查询任务中用例步骤日志预期结果 2017-09-16
*/
public static String getLogDetailExpectResult(int taskid, String caseno, int casestatus) {
String sqlresult = "";
try {
sqlresult = dbt.executeQuery(
"select detail from test_logdetail where logid=(select MIN(logid) from test_logdetail "
+ "where loggrade='error' and taskid=" + taskid
+ " and caseid=(select id from test_casedetail where taskid=" + taskid + " and caseno='"
+ caseno + "' and casestatus='" + casestatus + "'))");
if (sqlresult.indexOf("预期结果:") <= 0 || sqlresult.indexOf("%") <= 0) {
return sqlresult;
}
sqlresult = sqlresult.substring(sqlresult.indexOf("预期结果:") + 5, sqlresult.lastIndexOf("测试结果:") - 1);
} catch (Exception e) {
// TODO Auto-generated catch block
luckyclient.publicclass.LogUtil.APP.error("执行查询任务中用例步骤日志预期结果 SQL出现异常请确认数据库链接是否正常", e);
e.printStackTrace();
return sqlresult;
}
return sqlresult;
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {

View File

@ -15,11 +15,10 @@ import luckyclient.dblog.LogOperation;
*/ */
public class RestartServerInitialization { public class RestartServerInitialization {
@SuppressWarnings("finally")
public static String restartServerRun(String tastid){ public static String restartServerRun(String tastid){
String result = "Status:true"+" 重启命令执行成功!"; String result = "Status:true"+" 重启命令执行成功!";
try{ try{
String[] command = LogOperation.getrestartcomm(tastid); String[] command = LogOperation.getRestartComm(tastid);
if(command!=null){ if(command!=null){
luckyclient.publicclass.LogUtil.APP.info("准备重启指定的TOMCAT请稍等。。。参数个数"+command.length); luckyclient.publicclass.LogUtil.APP.info("准备重启指定的TOMCAT请稍等。。。参数个数"+command.length);
if(command.length==5){ if(command.length==5){

View File

@ -2,6 +2,7 @@ package luckyclient.publicclass;
import java.io.File; import java.io.File;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.jar.JarFile;
/** /**
* ================================================================= * =================================================================
@ -42,7 +43,7 @@ public class JarClassFind {
} else { } else {
if (filelist[i].endsWith("jar")) { if (filelist[i].endsWith("jar")) {
try { try {
java.util.jar.JarFile jarfile = new java.util.jar.JarFile(path + filelist[i]); JarFile jarfile = new java.util.jar.JarFile(path + filelist[i]);
for (Enumeration e = jarfile.entries(); e.hasMoreElements();) { for (Enumeration e = jarfile.entries(); e.hasMoreElements();) {
String name = e.nextElement().toString(); String name = e.nextElement().toString();
if (name.equals(classname) || name.indexOf(classname) > -1) { if (name.equals(classname) || name.indexOf(classname) > -1) {

View File

@ -110,20 +110,20 @@ public class GetServerAPI {
* @return * @return
*/ */
public static List<ProjectCaseParams> cgetParamsByProjectid(String projectid) { public static List<ProjectCaseParams> cgetParamsByProjectid(String projectid) {
String result = HttpRequest.loadJSON(prefix+"/cgetParamsByProjectid.do?projectId="+projectid); String result = HttpRequest.loadJSON(prefix+"/clientUpdateTaskExecuteData.do?projectId="+projectid);
List<ProjectCaseParams> paramsList = JSONObject.parseArray(result, ProjectCaseParams.class); List<ProjectCaseParams> paramsList = JSONObject.parseArray(result, ProjectCaseParams.class);
return paramsList; return paramsList;
} }
/** /**
* 供其他系统远程调用调度任务启动执行 * 通过计划ID获取测试用例对象集
* @param jobid * @param planid
* @return * @return
* @throws UnsupportedEncodingException
*/ */
public static String cRunJobForId(String jobid) throws UnsupportedEncodingException { public static List<Integer> clientGetCaseListForUnSucByTaskId(Integer taskId) {
String result = HttpRequest.loadJSON("/testJobs/runJobForInterface.do?jobid=" + jobid); String result = HttpRequest.loadJSON(prefix+"/clientGetCaseListForUnSucByTaskId.do?taskId=" + taskId);
return new String(result.getBytes("GBK"), "UTF-8"); List<Integer> caseIdList = JSONObject.parseArray(result, Integer.class);
return caseIdList;
} }
public static void main(String[] args) throws UnsupportedEncodingException { public static void main(String[] args) throws UnsupportedEncodingException {

View File

@ -111,6 +111,30 @@ public class PostServerAPI {
HttpRequest.httpClientPostJson(prefix+"/clientPostTaskCaseLog", JSONObject.toJSONString(taskCaseLog)); HttpRequest.httpClientPostJson(prefix+"/clientPostTaskCaseLog", JSONObject.toJSONString(taskCaseLog));
} }
/**
* 更新任务执行数据
* @param taskId
* @param casecount
* @author Seagull
* @date 2019年4月22日
*/
public static String clientUpdateTaskExecuteData(Integer taskId, Integer caseCount, Integer taskStatus){
String str = "{\"taskId\":"+taskId+",\"caseCount\":"+caseCount+",\"taskStatus\":"+taskStatus+"}";
return HttpRequest.httpClientPostJson(prefix+"/clientUpdateTaskExecuteData", JSONObject.toJSONString(str));
}
/**
* 更新任务执行数据
* @param taskId
* @param casecount
* @author Seagull
* @date 2019年4月22日
*/
public static String clientDeleteTaskCaseLog(Integer taskId, Integer caseId){
String str = "{\"taskId\":"+taskId+",\"caseId\":"+caseId+"}";
return HttpRequest.httpClientPostJson(prefix+"/clientDeleteTaskCaseLog", JSONObject.toJSONString(str));
}
public static void main(String[] args) throws UnsupportedEncodingException { public static void main(String[] args) throws UnsupportedEncodingException {
cPostDebugLog(3, 1, "info", "js a查%颗蜡&配电脑明显==人fdsa人",0); cPostDebugLog(3, 1, "info", "js a查%颗蜡&配电脑明显==人fdsa人",0);
} }