commit
f3b3c57517
133
pom.xml
133
pom.xml
|
@ -61,7 +61,6 @@
|
|||
<exclude>**/TestDriven/*</exclude>
|
||||
<exclude>appium_config.properties</exclude>
|
||||
<exclude>sys_config.properties</exclude>
|
||||
<exclude>testlinkjavaapi.properties</exclude>
|
||||
</excludes>
|
||||
<archive>
|
||||
<manifest>
|
||||
|
@ -126,22 +125,22 @@
|
|||
<properties>
|
||||
<project.build.sourceEncoding>GBK</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>maven-ali</id>
|
||||
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
<checksumPolicy>fail</checksumPolicy>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>maven-ali</id>
|
||||
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
<checksumPolicy>fail</checksumPolicy>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
@ -211,12 +210,12 @@
|
|||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.6</version>
|
||||
|
@ -226,42 +225,29 @@
|
|||
<artifactId>commons-logging</artifactId>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-math</artifactId>
|
||||
<version>2.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<dependency>
|
||||
<groupId>commons-net</groupId>
|
||||
<artifactId>commons-net</artifactId>
|
||||
<version>3.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.17</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId>
|
||||
<version>1.2.17</version> </dependency> -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-log4j</artifactId>
|
||||
<version>1.3.8.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.xmlrpc</groupId>
|
||||
<artifactId>xmlrpc-client</artifactId>
|
||||
<version>3.1.3</version>
|
||||
<version>1.7.26</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.xmlrpc</groupId>
|
||||
<artifactId>xmlrpc-common</artifactId>
|
||||
<version>3.1.3</version>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-log4j</artifactId>
|
||||
<version>1.3.8.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<dependency>
|
||||
<groupId>org.seleniumhq.selenium</groupId>
|
||||
<artifactId>selenium-java</artifactId>
|
||||
</dependency>
|
||||
|
@ -273,48 +259,15 @@
|
|||
<groupId>xml-apis</groupId>
|
||||
<artifactId>xml-apis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.11</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.appium</groupId>
|
||||
<artifactId>java-client</artifactId>
|
||||
<version>6.0.0-BETA2</version>
|
||||
</dependency>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.freemarker</groupId>
|
||||
<artifactId>freemarker</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>br.eti.kinoshita</groupId>
|
||||
<artifactId>testlink-java-api</artifactId>
|
||||
<version>1.9.16-0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-configuration2</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-httpclient</artifactId>
|
||||
<groupId>commons-httpclient</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpmime</artifactId>
|
||||
|
@ -322,27 +275,29 @@
|
|||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.47</version>
|
||||
<version>1.2.58</version>
|
||||
</dependency>
|
||||
<!-- 获取系统信息 -->
|
||||
<dependency>
|
||||
<groupId>com.github.oshi</groupId>
|
||||
<artifactId>oshi-core</artifactId>
|
||||
<version>3.9.1</version>
|
||||
</dependency>
|
||||
<!-- 获取系统信息 -->
|
||||
<dependency>
|
||||
<groupId>com.github.oshi</groupId>
|
||||
<artifactId>oshi-core</artifactId>
|
||||
<version>3.9.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- <dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency> -->
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -17,9 +17,9 @@ appiumsever=0.0.0.0:4723
|
|||
autoRunAppiumService=False
|
||||
#APPIUM main.js路径,需要自动启动Appium服务(autoRunAppiumService=True)时用到
|
||||
mainjsPath=C:\\Users\\联想笔记本\\AppData\\Roaming\\npm\\node_modules\\appium\\build\\lib\\main.js
|
||||
#Android应用的包名
|
||||
#Android应用的包名,IOS无需填写
|
||||
appPackage=com.XXX.XXX
|
||||
#启动Android Activity
|
||||
#启动Android Activity,IOS无需填写
|
||||
appActivity=com.XXX.XXX.XXX
|
||||
#支持中文输入,会自动安装Unicode输入
|
||||
unicodeKeyboard=True
|
||||
|
|
|
@ -7,7 +7,4 @@
|
|||
## \____/\__,_|\___|_|\_\\__, \/ |_| \__,_|_| |_| |_|\___| ##
|
||||
## |___/ ##
|
||||
## ##
|
||||
## +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+ ##
|
||||
## |V|2|.|7|.|2| |B|e|t|a| ##
|
||||
## +-+-+-+-+ +-+-+-+-+ +-+-+-+-+-+-+ ##
|
||||
##################################################################
|
|
@ -1,12 +1,9 @@
|
|||
log4j.rootLogger=INFO,stdout,app,error
|
||||
log4j.rootLogger=INFO,stdout,info,warn,error
|
||||
|
||||
log4j.logger.app=info,error
|
||||
log4j.logger.info=info
|
||||
log4j.logger.warn=warn
|
||||
log4j.logger.error=error
|
||||
|
||||
log4j.additivity.msg=false
|
||||
log4j.additivity.monitor=false
|
||||
log4j.additivity.error=false
|
||||
|
||||
log4j.logger.org.springframework=warn
|
||||
log4j.logger.org.apache=info,error
|
||||
log4j.logger.org.aspectj.weaver=warn
|
||||
|
@ -23,25 +20,36 @@ log4j.logger.java.sql.PreparedStatement=info
|
|||
#log4j.logger.org.apache.commons.httpclient.Wire=off
|
||||
|
||||
|
||||
################
|
||||
################打印到控制台
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern = %d{yyyy-MM-dd HH\:mm\:ss\:SSS}\:%l - \n%p\: %m%n
|
||||
|
||||
################
|
||||
log4j.appender.app=org.apache.log4j.DailyRollingFileAppender
|
||||
log4j.appender.app.File=bootlog/APP.log
|
||||
log4j.appender.app.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.app.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss:SSS}:%p %l - %m%n
|
||||
log4j.appender.app.DatePattern = '.'yyyy-MM-dd
|
||||
log4j.appender.app.encoding=UTF-8
|
||||
#log4j.appender.app.encoding=UTF-8
|
||||
################记录系统日志,监控客户端运行情况
|
||||
log4j.appender.info=org.apache.log4j.DailyRollingFileAppender
|
||||
log4j.appender.info.File=bootlog/INFO.log
|
||||
log4j.appender.info.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.info.Threshold = INFO
|
||||
log4j.appender.info.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss:SSS}:%p %l - %m%n
|
||||
log4j.appender.info.DatePattern = '.'yyyy-MM-dd
|
||||
log4j.appender.info.encoding=UTF-8
|
||||
################
|
||||
|
||||
################error
|
||||
################记录系统告警日志
|
||||
log4j.appender.warn=org.apache.log4j.DailyRollingFileAppender
|
||||
log4j.appender.warn.File=bootlog/WARN.log
|
||||
log4j.appender.warn.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.warn.Threshold = WARN
|
||||
log4j.appender.warn.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss:SSS}:%p %l - %m%n
|
||||
log4j.appender.warn.DatePattern = '.'yyyy-MM-dd
|
||||
log4j.appender.warn.encoding=UTF-8
|
||||
################
|
||||
|
||||
################记录系统错误,监控程序是否出错
|
||||
log4j.appender.error=org.apache.log4j.DailyRollingFileAppender
|
||||
log4j.appender.error.File=bootlog/ERROR.log
|
||||
log4j.appender.error.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.error.Threshold = ERROR
|
||||
log4j.appender.error.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss:SSS}:%p %l - %m%n
|
||||
log4j.appender.error.DatePattern = '.'yyyy-MM-dd
|
||||
log4j.appender.error.encoding=UTF-8
|
||||
|
|
|
@ -24,7 +24,7 @@ a {
|
|||
<table width="620" border="0" align="center" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td height="92" style="background-color:rgba(51,204,255,0.6);">
|
||||
<a href="http://www.luckyframe.cn" title="LuckyFrame" target="_blank"><img src="http://${webip}:${webport}/pic/maillogo.png" alt="LuckyFrame" width="300" height="92" border="0" /></a></td>
|
||||
<a href="http://www.luckyframe.cn" title="LuckyFrame" target="_blank"><img src="http://${webip}:${webport}/img/maillogo.png" alt="LuckyFrame" width="300" height="92" border="0" /></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="1" colspan="2"><hr style="border-bottom:5px solid #f1f1f1; display:block;" /></td>
|
||||
|
@ -44,12 +44,9 @@ a {
|
|||
<p><b>用例执行失败: </b> 【<font color='#FF0000'>${casefail}</font>】</p>
|
||||
<p><b>用例有可能由于脚本原因未成功解析被锁定:</b> 【<font color='#AE57A4'>${caselock}</font>】</p>
|
||||
<p><b>用例由于长时间未收到接口Response未执行完成:</b> 【<font color='#FFAD86'>${caseunex}</font>】</p>
|
||||
<br>
|
||||
<p><b>具体详情请点击: </b><a href='http://${webip}:${webport}/caseDetail/load.do?taskId=${taskid}' target='任务查询'>查询本次自动化任务执行结果明细</a></p>
|
||||
<p><b>查看全部项目请点击: </b><a href='http://${webip}:${webport}/autoTestChar/chart.do'>查看全部项目执行情况</a></p>
|
||||
<p> </p>
|
||||
<p> 此为自动化平台LuckyFrame的系统邮件,请勿回复</p>
|
||||
<p> 请及时前往平台查看您的任务执行的更多细节</p>
|
||||
<p> 请及时前往<a href='http://${webip}:${webport}'>LuckyFrame平台</a>查看您的任务执行的更多细节</p>
|
||||
<p>
|
||||
</div>
|
||||
</td>
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
log4j.rootLogger=INFO,stdout,app,error
|
||||
log4j.rootLogger=INFO,stdout,info,warn,error
|
||||
|
||||
log4j.logger.app=info,error
|
||||
log4j.logger.info=info
|
||||
log4j.logger.warn=warn
|
||||
log4j.logger.error=error
|
||||
|
||||
log4j.additivity.msg=false
|
||||
log4j.additivity.monitor=false
|
||||
log4j.additivity.error=false
|
||||
|
||||
log4j.logger.org.springframework=warn
|
||||
log4j.logger.org.apache=info,error
|
||||
log4j.logger.org.aspectj.weaver=warn
|
||||
|
@ -23,25 +20,36 @@ log4j.logger.java.sql.PreparedStatement=info
|
|||
#log4j.logger.org.apache.commons.httpclient.Wire=off
|
||||
|
||||
|
||||
################
|
||||
################打印到控制台
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern = %d{yyyy-MM-dd HH\:mm\:ss\:SSS}\:%l - \n%p\: %m%n
|
||||
|
||||
################
|
||||
log4j.appender.app=org.apache.log4j.DailyRollingFileAppender
|
||||
log4j.appender.app.File=log/APP.log
|
||||
log4j.appender.app.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.app.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss:SSS}:%p %l - %m%n
|
||||
log4j.appender.app.DatePattern = '.'yyyy-MM-dd
|
||||
log4j.appender.app.encoding=UTF-8
|
||||
#log4j.appender.app.encoding=UTF-8
|
||||
################记录系统日志,监控客户端运行情况
|
||||
log4j.appender.info=org.apache.log4j.DailyRollingFileAppender
|
||||
log4j.appender.info.File=log/INFO.log
|
||||
log4j.appender.info.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.info.Threshold = INFO
|
||||
log4j.appender.info.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss:SSS}:%p %l - %m%n
|
||||
log4j.appender.info.DatePattern = '.'yyyy-MM-dd
|
||||
log4j.appender.info.encoding=UTF-8
|
||||
################
|
||||
|
||||
################error
|
||||
################记录系统告警日志
|
||||
log4j.appender.warn=org.apache.log4j.DailyRollingFileAppender
|
||||
log4j.appender.warn.File=log/WARN.log
|
||||
log4j.appender.warn.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.warn.Threshold = WARN
|
||||
log4j.appender.warn.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss:SSS}:%p %l - %m%n
|
||||
log4j.appender.warn.DatePattern = '.'yyyy-MM-dd
|
||||
log4j.appender.warn.encoding=UTF-8
|
||||
################
|
||||
|
||||
################记录系统错误,监控程序是否出错
|
||||
log4j.appender.error=org.apache.log4j.DailyRollingFileAppender
|
||||
log4j.appender.error.File=log/ERROR.log
|
||||
log4j.appender.error.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.error.Threshold = ERROR
|
||||
log4j.appender.error.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss:SSS}:%p %l - %m%n
|
||||
log4j.appender.error.DatePattern = '.'yyyy-MM-dd
|
||||
log4j.appender.error.encoding=UTF-8
|
||||
|
|
|
@ -1,23 +1,7 @@
|
|||
#===============================系统配置=====================================
|
||||
client.verison=3.0_beta
|
||||
client.verison=3.0 Beta
|
||||
server.web.ip=localhost
|
||||
server.web.port=8080
|
||||
#===============================TestLink=====================================
|
||||
#TestLink URL地址
|
||||
testlink.api.ip=localhost
|
||||
#TestLink DEVKEY密钥
|
||||
testlink.api.devkey=40ad3f1eb4cac155a5e0704e9c5280d2
|
||||
#================================数据库=============================================
|
||||
#数据库地址
|
||||
mysql.db.ip=localhost
|
||||
#数据库端口
|
||||
mysql.db.port=3306
|
||||
#数据库名
|
||||
mysql.db.dbname=luckyframedb
|
||||
#数据库链接用户名
|
||||
mysql.db.username=luckyframe
|
||||
#数据库链接密码
|
||||
mysql.db.userpwd=luckyframe
|
||||
server.web.port=80
|
||||
#==================================邮件============================================
|
||||
#smtp邮件IP 例:smtp.qq.com
|
||||
mail.smtp.ip=smtp.qq.com
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
xmlrpc.connectionTimeout=60000
|
||||
xmlrpc.contentLengthOptional=false
|
||||
xmlrpc.basicEncoding=GBK
|
||||
xmlrpc.enabledForExceptions=false
|
||||
xmlrpc.gzipCompression=false
|
||||
xmlrpc.gzipRequesting=false
|
||||
xmlrpc.replyTimeout=60000
|
||||
xmlrpc.userAgent=admin
|
|
@ -9,11 +9,11 @@ import luckyclient.caserun.exappium.androidex.AndroidBatchExecute;
|
|||
import luckyclient.caserun.exappium.iosex.IosBatchExecute;
|
||||
import luckyclient.caserun.exinterface.BatchTestCaseExecution;
|
||||
import luckyclient.caserun.exinterface.TestControl;
|
||||
import luckyclient.caserun.exinterface.testlink.BatchTestLinkCaseExecution;
|
||||
import luckyclient.caserun.exwebdriver.ex.WebBatchExecute;
|
||||
import luckyclient.caserun.exwebdriver.extestlink.WebBatchExecuteTestLink;
|
||||
import luckyclient.planapi.api.GetServerAPI;
|
||||
import luckyclient.planapi.entity.TestTaskexcute;
|
||||
import luckyclient.publicclass.AppiumConfig;
|
||||
import luckyclient.serverapi.api.GetServerAPI;
|
||||
import luckyclient.serverapi.entity.TaskExecute;
|
||||
import luckyclient.serverapi.entity.TaskScheduling;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
@ -34,36 +34,25 @@ public class BatchCaseExecute extends TestControl {
|
|||
PropertyConfigurator.configure(System.getProperty("user.dir") + File.separator + "log4j.conf");
|
||||
String taskid = args[0];
|
||||
String batchcase = args[1];
|
||||
TestTaskexcute task = GetServerAPI.cgetTaskbyid(Integer.valueOf(taskid));
|
||||
if (task.getTestJob().getExtype() == 0) {
|
||||
if (task.getTestJob().getProjecttype() == 1) {
|
||||
// ½Ó¿Ú²âÊÔ
|
||||
BatchTestLinkCaseExecution.batchCaseExecuteForTast(task.getTestJob().getPlanproj(),
|
||||
String.valueOf(task.getId()), batchcase);
|
||||
} else if (task.getTestJob().getProjecttype() == 0) {
|
||||
BatchTestCaseExecution.batchCaseExecuteForTast(task.getTestJob().getPlanproj(),
|
||||
String.valueOf(task.getId()), batchcase);
|
||||
}
|
||||
} else if (task.getTestJob().getExtype() == 1) {
|
||||
if (task.getTestJob().getProjecttype() == 1) {
|
||||
TaskExecute task = GetServerAPI.cgetTaskbyid(Integer.valueOf(taskid));
|
||||
TaskScheduling taskScheduling = GetServerAPI.cGetTaskSchedulingByTaskId(Integer.valueOf(taskid));
|
||||
if (taskScheduling.getTaskType() == 0) {
|
||||
BatchTestCaseExecution.batchCaseExecuteForTast(taskScheduling.getProject().getProjectName(),
|
||||
String.valueOf(task.getTaskId()), batchcase);
|
||||
} else if (taskScheduling.getTaskType() == 1) {
|
||||
// UI²âÊÔ
|
||||
WebBatchExecuteTestLink.batchCaseExecuteForTast(task.getTestJob().getPlanproj(),
|
||||
String.valueOf(task.getId()), batchcase);
|
||||
} else if (task.getTestJob().getProjecttype() == 0) {
|
||||
// UI²âÊÔ
|
||||
WebBatchExecute.batchCaseExecuteForTast(task.getTestJob().getPlanproj(),
|
||||
String.valueOf(task.getId()), batchcase);
|
||||
}
|
||||
WebBatchExecute.batchCaseExecuteForTast(taskScheduling.getProject().getProjectName(),
|
||||
String.valueOf(task.getTaskId()), batchcase);
|
||||
|
||||
} else if (task.getTestJob().getExtype() == 2) {
|
||||
Properties properties = luckyclient.publicclass.AppiumConfig.getConfiguration();
|
||||
} else if (taskScheduling.getTaskType() == 2) {
|
||||
Properties properties = AppiumConfig.getConfiguration();
|
||||
|
||||
if ("Android".equals(properties.getProperty("platformName"))) {
|
||||
AndroidBatchExecute.batchCaseExecuteForTast(task.getTestJob().getPlanproj(),
|
||||
String.valueOf(task.getId()), batchcase);
|
||||
AndroidBatchExecute.batchCaseExecuteForTast(taskScheduling.getProject().getProjectName(),
|
||||
String.valueOf(task.getTaskId()), batchcase);
|
||||
} else if ("IOS".equals(properties.getProperty("platformName"))) {
|
||||
IosBatchExecute.batchCaseExecuteForTast(task.getTestJob().getPlanproj(),
|
||||
String.valueOf(task.getId()), batchcase);
|
||||
IosBatchExecute.batchCaseExecuteForTast(taskScheduling.getProject().getProjectName(),
|
||||
String.valueOf(task.getTaskId()), batchcase);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,11 +9,11 @@ import luckyclient.caserun.exappium.androidex.AndroidOneCaseExecute;
|
|||
import luckyclient.caserun.exappium.iosex.IosOneCaseExecute;
|
||||
import luckyclient.caserun.exinterface.TestCaseExecution;
|
||||
import luckyclient.caserun.exinterface.TestControl;
|
||||
import luckyclient.caserun.exinterface.testlink.TestLinkCaseExecution;
|
||||
import luckyclient.caserun.exwebdriver.ex.WebOneCaseExecute;
|
||||
import luckyclient.caserun.exwebdriver.extestlink.WebOneCaseExecuteTestLink;
|
||||
import luckyclient.planapi.api.GetServerAPI;
|
||||
import luckyclient.planapi.entity.TestTaskexcute;
|
||||
import luckyclient.publicclass.AppiumConfig;
|
||||
import luckyclient.serverapi.api.GetServerAPI;
|
||||
import luckyclient.serverapi.entity.TaskExecute;
|
||||
import luckyclient.serverapi.entity.TaskScheduling;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
@ -31,40 +31,28 @@ public class OneCaseExecute extends TestControl {
|
|||
public static void main(String[] args) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
PropertyConfigurator.configure(System.getProperty("user.dir")+ File.separator +"log4j.conf");
|
||||
String taskid = args[0];
|
||||
String testCaseExternalId = args[1];
|
||||
String taskId = args[0];
|
||||
String caseId = args[1];
|
||||
int version = Integer.parseInt(args[2]);
|
||||
TestTaskexcute task = GetServerAPI.cgetTaskbyid(Integer.valueOf(taskid));
|
||||
if (task.getTestJob().getExtype() == 0) {
|
||||
if (task.getTestJob().getProjecttype() == 1) {
|
||||
// testlink½Ó¿Ú²âÊÔ
|
||||
TestLinkCaseExecution.oneCaseExecuteForTast(task.getTestJob().getPlanproj(), testCaseExternalId,
|
||||
version, String.valueOf(task.getId()));
|
||||
} else if (task.getTestJob().getProjecttype() == 0) {
|
||||
TaskExecute task = GetServerAPI.cgetTaskbyid(Integer.valueOf(taskId));
|
||||
TaskScheduling taskScheduling = GetServerAPI.cGetTaskSchedulingByTaskId(Integer.valueOf(taskId));
|
||||
if (taskScheduling.getTaskType() == 0) {
|
||||
// ½Ó¿Ú²âÊÔ
|
||||
TestCaseExecution.oneCaseExecuteForTast(task.getTestJob().getPlanproj(), testCaseExternalId, version,
|
||||
String.valueOf(task.getId()));
|
||||
}
|
||||
TestCaseExecution.oneCaseExecuteForTask(taskScheduling.getProject().getProjectName(), Integer.valueOf(caseId), String.valueOf(task.getTaskId()));
|
||||
|
||||
} else if (task.getTestJob().getExtype() == 1) {
|
||||
if (task.getTestJob().getProjecttype() == 1) {
|
||||
// UI²âÊÔ
|
||||
WebOneCaseExecuteTestLink.oneCaseExecuteForTast(task.getTestJob().getPlanproj(), testCaseExternalId,
|
||||
version, String.valueOf(task.getId()));
|
||||
} else if (task.getTestJob().getProjecttype() == 0) {
|
||||
WebOneCaseExecute.oneCaseExecuteForTast(task.getTestJob().getPlanproj(), testCaseExternalId, version,
|
||||
String.valueOf(task.getId()));
|
||||
}
|
||||
} else if (taskScheduling.getTaskType() == 1) {
|
||||
WebOneCaseExecute.oneCaseExecuteForTast(taskScheduling.getProject().getProjectName(), Integer.valueOf(caseId), version,
|
||||
String.valueOf(task.getTaskId()));
|
||||
|
||||
} else if (task.getTestJob().getExtype() == 2) {
|
||||
Properties properties = luckyclient.publicclass.AppiumConfig.getConfiguration();
|
||||
} else if (taskScheduling.getTaskType() == 2) {
|
||||
Properties properties = AppiumConfig.getConfiguration();
|
||||
|
||||
if ("Android".equals(properties.getProperty("platformName"))) {
|
||||
AndroidOneCaseExecute.oneCaseExecuteForTast(task.getTestJob().getPlanproj(), testCaseExternalId,
|
||||
version, String.valueOf(task.getId()));
|
||||
AndroidOneCaseExecute.oneCaseExecuteForTast(taskScheduling.getProject().getProjectName(), Integer.valueOf(caseId),
|
||||
version, String.valueOf(task.getTaskId()));
|
||||
} else if ("IOS".equals(properties.getProperty("platformName"))) {
|
||||
IosOneCaseExecute.oneCaseExecuteForTast(task.getTestJob().getPlanproj(), testCaseExternalId, version,
|
||||
String.valueOf(task.getId()));
|
||||
IosOneCaseExecute.oneCaseExecuteForTast(taskScheduling.getProject().getProjectName(), Integer.valueOf(caseId), version,
|
||||
String.valueOf(task.getTaskId()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,8 +7,9 @@ import org.apache.log4j.PropertyConfigurator;
|
|||
import luckyclient.caserun.exappium.AppTestControl;
|
||||
import luckyclient.caserun.exinterface.TestControl;
|
||||
import luckyclient.caserun.exwebdriver.WebTestControl;
|
||||
import luckyclient.planapi.api.GetServerAPI;
|
||||
import luckyclient.planapi.entity.TestTaskexcute;
|
||||
import luckyclient.serverapi.api.GetServerAPI;
|
||||
import luckyclient.serverapi.entity.TaskExecute;
|
||||
import luckyclient.serverapi.entity.TaskScheduling;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
@ -27,16 +28,16 @@ public class RunAutomationTest extends TestControl {
|
|||
try {
|
||||
PropertyConfigurator.configure(System.getProperty("user.dir") + File.separator + "log4j.conf");
|
||||
String taskid = args[0];
|
||||
TestTaskexcute task = GetServerAPI.cgetTaskbyid(Integer.valueOf(taskid));
|
||||
|
||||
if (task.getTestJob().getExtype() == 0) {
|
||||
TaskExecute task = GetServerAPI.cgetTaskbyid(Integer.valueOf(taskid));
|
||||
TaskScheduling taskScheduling = GetServerAPI.cGetTaskSchedulingByTaskId(Integer.valueOf(taskid));
|
||||
if (taskScheduling.getTaskType() == 0) {
|
||||
// ½Ó¿Ú²âÊÔ
|
||||
TestControl.taskExecutionPlan(taskid, task);
|
||||
} else if (task.getTestJob().getExtype() == 1) {
|
||||
TestControl.taskExecutionPlan(task);
|
||||
} else if (taskScheduling.getTaskType() == 1) {
|
||||
// UI²âÊÔ
|
||||
WebTestControl.taskExecutionPlan(taskid, task);
|
||||
} else if (task.getTestJob().getExtype() == 2) {
|
||||
AppTestControl.taskExecutionPlan(taskid, task);
|
||||
WebTestControl.taskExecutionPlan(task);
|
||||
} else if (taskScheduling.getTaskType() == 2) {
|
||||
AppTestControl.taskExecutionPlan(task);
|
||||
}
|
||||
System.exit(0);
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -23,9 +23,9 @@ public class WebDebugExecute extends TestControl{
|
|||
public static void main(String[] args) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
PropertyConfigurator.configure(System.getProperty("user.dir") + File.separator + "log4j.conf");
|
||||
String sign = args[0];
|
||||
String executor = args[1];
|
||||
WebTestCaseDebug.oneCaseDebug(sign,executor);
|
||||
String caseIdStr = args[0];
|
||||
String userIdStr = args[1];
|
||||
WebTestCaseDebug.oneCaseDebug(caseIdStr, userIdStr);
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,8 +6,9 @@ import java.util.regex.Matcher;
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
import luckyclient.dblog.LogOperation;
|
||||
import luckyclient.planapi.entity.ProjectCase;
|
||||
import luckyclient.planapi.entity.ProjectCasesteps;
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
import luckyclient.serverapi.entity.ProjectCase;
|
||||
import luckyclient.serverapi.entity.ProjectCaseSteps;
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
|
@ -33,29 +34,29 @@ public class AppDriverAnalyticCase {
|
|||
* @author Seagull
|
||||
* @date 2019年1月17日
|
||||
*/
|
||||
public static Map<String,String> analyticCaseStep(ProjectCase projectcase,ProjectCasesteps step,String taskid,LogOperation caselog){
|
||||
public static Map<String,String> analyticCaseStep(ProjectCase projectcase,ProjectCaseSteps step,String taskid,LogOperation caselog){
|
||||
Map<String,String> params = new HashMap<String,String>(0);
|
||||
|
||||
String resultstr = null;
|
||||
try {
|
||||
if(null!=step.getPath()&&step.getPath().indexOf("=")>-1){
|
||||
String property = step.getPath().substring(0, step.getPath().indexOf("="));
|
||||
String propertyValue = step.getPath().substring(step.getPath().indexOf("=")+1, step.getPath().length());
|
||||
if(null!=step.getStepPath()&&step.getStepPath().indexOf("=")>-1){
|
||||
String property = step.getStepPath().substring(0, step.getStepPath().indexOf("="));
|
||||
String propertyValue = step.getStepPath().substring(step.getStepPath().indexOf("=")+1, step.getStepPath().length());
|
||||
//set属性
|
||||
params.put("property", property.trim().toLowerCase());
|
||||
//set属性值
|
||||
params.put("property_value", propertyValue.trim());
|
||||
luckyclient.publicclass.LogUtil.APP.info("对象属性解析结果:property:"+property.trim()+"; property_value:"+propertyValue.trim());
|
||||
LogUtil.APP.info("对象属性解析结果:property:"+property.trim()+"; property_value:"+propertyValue.trim());
|
||||
}
|
||||
//set操作方法
|
||||
params.put("operation", step.getOperation().toLowerCase());
|
||||
if(null!=step.getParameters()&&!"".equals(step.getParameters())){
|
||||
params.put("operation", step.getStepOperation().toLowerCase());
|
||||
if(null!=step.getStepParameters()&&!"".equals(step.getStepParameters())){
|
||||
//set属性值
|
||||
params.put("operation_value", step.getParameters());
|
||||
params.put("operation_value", step.getStepParameters());
|
||||
}
|
||||
luckyclient.publicclass.LogUtil.APP.info("对象操作解析结果:operation:"+step.getOperation().toLowerCase()+"; operation_value:"+step.getParameters());
|
||||
LogUtil.APP.info("对象操作解析结果:operation:"+step.getStepOperation().toLowerCase()+"; operation_value:"+step.getStepParameters());
|
||||
//获取预期结果字符串
|
||||
resultstr = step.getExpectedresult();
|
||||
resultstr = step.getExpectedResult();
|
||||
|
||||
//set预期结果
|
||||
if(null==resultstr||"".equals(resultstr)){
|
||||
|
@ -69,20 +70,19 @@ public class AppDriverAnalyticCase {
|
|||
params.put("checkproperty_value", expectedResults.substring(expectedResults.indexOf("=")+1, expectedResults.lastIndexOf(")")));
|
||||
}
|
||||
params.put("ExpectedResults", expectedResults);
|
||||
luckyclient.publicclass.LogUtil.APP.info("预期结果解析:ExpectedResults:"+expectedResults);
|
||||
LogUtil.APP.info("预期结果解析:ExpectedResults:"+expectedResults);
|
||||
}
|
||||
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例编号:"+projectcase.getSign()+" 步骤编号:"+step.getStepnum()+" 解析自动化用例步骤脚本完成!");
|
||||
LogUtil.APP.info("用例编号:"+projectcase.getCaseSign()+" 步骤编号:"+step.getStepSerialNumber()+" 解析自动化用例步骤脚本完成!");
|
||||
if(null!=caselog){
|
||||
caselog.caseLogDetail(taskid, projectcase.getSign(),"步骤编号:"+step.getStepnum()+" 解析自动化用例步骤脚本完成!","info",String.valueOf(step.getStepnum()),"");
|
||||
caselog.insertTaskCaseLog(taskid, projectcase.getCaseId(),"步骤编号:"+step.getStepSerialNumber()+" 解析自动化用例步骤脚本完成!","info",String.valueOf(step.getStepSerialNumber()),"");
|
||||
}
|
||||
}catch(Exception e) {
|
||||
luckyclient.publicclass.LogUtil.ERROR.error("用例编号:"+projectcase.getSign()+" 步骤编号:"+step.getStepnum()+" 解析自动化用例步骤脚本出错!");
|
||||
if(null!=caselog){
|
||||
caselog.caseLogDetail(taskid, projectcase.getSign(),"步骤编号:"+step.getStepnum()+" 解析自动化用例步骤脚本出错!","error",String.valueOf(step.getStepnum()),"");
|
||||
caselog.insertTaskCaseLog(taskid, projectcase.getCaseId(),"步骤编号:"+step.getStepSerialNumber()+" 解析自动化用例步骤脚本出错!","error",String.valueOf(step.getStepSerialNumber()),"");
|
||||
}
|
||||
luckyclient.publicclass.LogUtil.ERROR.error(e,e);
|
||||
params.put("exception","用例编号:"+projectcase.getSign()+"|解析异常,用例步骤为空或是用例脚本错误!");
|
||||
LogUtil.APP.error("用例编号:"+projectcase.getCaseSign()+" 步骤编号:"+step.getStepSerialNumber()+" 解析自动化用例步骤脚本出错!",e);
|
||||
params.put("exception","用例编号:"+projectcase.getCaseSign()+"|解析异常,用例步骤为空或是用例脚本错误!");
|
||||
return params;
|
||||
}
|
||||
return params;
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
package luckyclient.caserun.exappium;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import io.appium.java_client.android.AndroidDriver;
|
||||
import io.appium.java_client.android.AndroidElement;
|
||||
import io.appium.java_client.ios.IOSDriver;
|
||||
|
@ -13,13 +18,14 @@ import luckyclient.jenkinsapi.BuildingInitialization;
|
|||
import luckyclient.jenkinsapi.RestartServerInitialization;
|
||||
import luckyclient.mail.HtmlMail;
|
||||
import luckyclient.mail.MailSendInitialization;
|
||||
import luckyclient.planapi.api.GetServerAPI;
|
||||
import luckyclient.planapi.entity.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import luckyclient.publicclass.AppiumConfig;
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
import luckyclient.serverapi.api.GetServerAPI;
|
||||
import luckyclient.serverapi.entity.ProjectCase;
|
||||
import luckyclient.serverapi.entity.ProjectCaseParams;
|
||||
import luckyclient.serverapi.entity.ProjectCaseSteps;
|
||||
import luckyclient.serverapi.entity.TaskExecute;
|
||||
import luckyclient.serverapi.entity.TaskScheduling;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
@ -46,7 +52,7 @@ public class AppTestControl {
|
|||
String taskid = "888888";
|
||||
AndroidDriver<AndroidElement> androiddriver = null;
|
||||
IOSDriver<IOSElement> iosdriver = null;
|
||||
Properties properties = luckyclient.publicclass.AppiumConfig.getConfiguration();
|
||||
Properties properties = AppiumConfig.getConfiguration();
|
||||
try {
|
||||
if ("Android".equals(properties.getProperty("platformName"))) {
|
||||
androiddriver = AppiumInitialization.setAndroidAppium(properties);
|
||||
|
@ -60,22 +66,20 @@ public class AppTestControl {
|
|||
}
|
||||
LogOperation caselog = new LogOperation();
|
||||
List<ProjectCase> testCases = GetServerAPI.getCasesbyplanname(planname);
|
||||
List<PublicCaseParams> pcplist = new ArrayList<PublicCaseParams>();
|
||||
List<ProjectCaseParams> pcplist = new ArrayList<ProjectCaseParams>();
|
||||
if (testCases.size() != 0) {
|
||||
pcplist = GetServerAPI.cgetParamsByProjectid(String.valueOf(testCases.get(0).getProjectid()));
|
||||
pcplist = GetServerAPI.cgetParamsByProjectid(String.valueOf(testCases.get(0).getProjectId()));
|
||||
}
|
||||
luckyclient.publicclass.LogUtil.APP.info("当前计划中读取到用例共 " + testCases.size() + " 个");
|
||||
LogUtil.APP.info("当前计划中读取到用例共 " + testCases.size() + " 个");
|
||||
int i = 0;
|
||||
for (ProjectCase testcase : testCases) {
|
||||
List<ProjectCasesteps> steps = GetServerAPI.getStepsbycaseid(testcase.getId());
|
||||
List<ProjectCaseSteps> steps = GetServerAPI.getStepsbycaseid(testcase.getCaseId());
|
||||
if (steps.size() == 0) {
|
||||
continue;
|
||||
}
|
||||
i++;
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始执行第" + i + "条用例:【" + testcase.getSign() + "】......");
|
||||
LogUtil.APP.info("开始执行第" + i + "条用例:【" + testcase.getCaseSign() + "】......");
|
||||
try {
|
||||
//插入开始执行的用例
|
||||
caselog.addCaseDetail(taskid, testcase.getSign(), "1", testcase.getName(), 4);
|
||||
if ("Android".equals(properties.getProperty("platformName"))) {
|
||||
AndroidCaseExecution.caseExcution(testcase, steps, taskid, androiddriver, caselog, pcplist);
|
||||
} else if ("IOS".equals(properties.getProperty("platformName"))) {
|
||||
|
@ -83,15 +87,15 @@ public class AppTestControl {
|
|||
}
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||
e.printStackTrace();
|
||||
LogUtil.APP.error("用户执行过程中抛出InterruptedException异常!", e);
|
||||
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
LogUtil.APP.error("用户执行过程中抛出IOException异常!", e);
|
||||
}
|
||||
luckyclient.publicclass.LogUtil.APP.info("当前用例:【" + testcase.getSign() + "】执行完成......进入下一条");
|
||||
LogUtil.APP.info("当前用例:【" + testcase.getCaseSign() + "】执行完成......进入下一条");
|
||||
}
|
||||
luckyclient.publicclass.LogUtil.APP.info("当前项目测试计划中的用例已经全部执行完成...");
|
||||
LogUtil.APP.info("当前项目测试计划中的用例已经全部执行完成...");
|
||||
// 关闭APP以及appium会话
|
||||
if ("Android".equals(properties.getProperty("platformName"))) {
|
||||
androiddriver.closeApp();
|
||||
|
@ -100,13 +104,14 @@ public class AppTestControl {
|
|||
}
|
||||
}
|
||||
|
||||
public static void taskExecutionPlan(String taskid, TestTaskexcute task) throws InterruptedException {
|
||||
public static void taskExecutionPlan(TaskExecute task) throws InterruptedException {
|
||||
// 记录日志到数据库
|
||||
String taskId=task.getTaskId().toString();
|
||||
DbLink.exetype = 0;
|
||||
TestControl.TASKID = taskid;
|
||||
TestControl.TASKID = taskId;
|
||||
AndroidDriver<AndroidElement> androiddriver = null;
|
||||
IOSDriver<IOSElement> iosdriver = null;
|
||||
Properties properties = luckyclient.publicclass.AppiumConfig.getConfiguration();
|
||||
Properties properties = AppiumConfig.getConfiguration();
|
||||
AppiumService as=null;
|
||||
//根据配置自动启动Appiume服务
|
||||
if(Boolean.valueOf(properties.getProperty("autoRunAppiumService"))){
|
||||
|
@ -114,15 +119,13 @@ public class AppTestControl {
|
|||
as.start();
|
||||
Thread.sleep(10000);
|
||||
}
|
||||
|
||||
String restartstatus = RestartServerInitialization.restartServerRun(taskid);
|
||||
String buildstatus = BuildingInitialization.buildingRun(taskid);
|
||||
List<PublicCaseParams> pcplist = GetServerAPI
|
||||
.cgetParamsByProjectid(task.getTestJob().getProjectid().toString());
|
||||
String projectname = task.getTestJob().getPlanproj();
|
||||
task = GetServerAPI.cgetTaskbyid(Integer.valueOf(taskid));
|
||||
TestJobs testJob = task.getTestJob();
|
||||
String jobname = task.getTestJob().getTaskName();
|
||||
TaskScheduling taskScheduling = GetServerAPI.cGetTaskSchedulingByTaskId(task.getTaskId());
|
||||
String restartstatus = RestartServerInitialization.restartServerRun(taskId);
|
||||
String buildstatus = BuildingInitialization.buildingRun(taskId);
|
||||
List<ProjectCaseParams> pcplist = GetServerAPI
|
||||
.cgetParamsByProjectid(task.getProjectId().toString());
|
||||
String projectname = task.getProject().getProjectName();
|
||||
String jobname = GetServerAPI.cGetTaskSchedulingByTaskId(task.getTaskId()).getSchedulingName();
|
||||
int[] tastcount = null;
|
||||
// 判断是否要自动重启TOMCAT
|
||||
if (restartstatus.indexOf("Status:true") > -1) {
|
||||
|
@ -131,50 +134,48 @@ public class AppTestControl {
|
|||
try {
|
||||
if ("Android".equals(properties.getProperty("platformName"))) {
|
||||
androiddriver = AppiumInitialization.setAndroidAppium(properties);
|
||||
luckyclient.publicclass.LogUtil.APP.info("完成AndroidDriver初始化动作...APPIUM Server【http://"
|
||||
LogUtil.APP.info("完成AndroidDriver初始化动作...APPIUM Server【http://"
|
||||
+ properties.getProperty("appiumsever") + "/wd/hub】");
|
||||
} else if ("IOS".equals(properties.getProperty("platformName"))) {
|
||||
iosdriver = AppiumInitialization.setIosAppium(properties);
|
||||
luckyclient.publicclass.LogUtil.APP.info("完成IOSDriver初始化动作...APPIUM Server【http://"
|
||||
LogUtil.APP.info("完成IOSDriver初始化动作...APPIUM Server【http://"
|
||||
+ properties.getProperty("appiumsever") + "/wd/hub】");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("初始化AppiumDriver出错 !APPIUM Server【http://"
|
||||
LogUtil.APP.error("初始化AppiumDriver出错 !APPIUM Server【http://"
|
||||
+ properties.getProperty("appiumsever") + "/wd/hub】", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
LogOperation caselog = new LogOperation();
|
||||
List<ProjectCase> cases = GetServerAPI.getCasesbyplanid(task.getTestJob().getPlanid());
|
||||
luckyclient.publicclass.LogUtil.APP.info("当前计划中读取到用例共 " + cases.size() + " 个");
|
||||
LogOperation.updateTastStatus(taskid, cases.size());
|
||||
List<ProjectCase> cases = GetServerAPI.getCasesbyplanId(taskScheduling.getPlanId());
|
||||
LogUtil.APP.info("当前计划中读取到用例共 " + cases.size() + " 个");
|
||||
LogOperation.updateTaskExecuteStatus(taskId, cases.size());
|
||||
|
||||
for (ProjectCase testcase : cases) {
|
||||
List<ProjectCasesteps> steps = GetServerAPI.getStepsbycaseid(testcase.getId());
|
||||
List<ProjectCaseSteps> steps = GetServerAPI.getStepsbycaseid(testcase.getCaseId());
|
||||
if (steps.size() == 0) {
|
||||
continue;
|
||||
}
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始执行用例:【" + testcase.getSign() + "】......");
|
||||
LogUtil.APP.info("开始执行用例:【" + testcase.getCaseSign() + "】......");
|
||||
try {
|
||||
//插入开始执行的用例
|
||||
caselog.addCaseDetail(taskid, testcase.getSign(), "1", testcase.getName(), 4);
|
||||
caselog.insertTaskCaseExecute(taskId, taskScheduling.getProjectId(),testcase.getCaseId(),testcase.getCaseSign(), testcase.getCaseName(), 4);
|
||||
if ("Android".equals(properties.getProperty("platformName"))) {
|
||||
AndroidCaseExecution.caseExcution(testcase, steps, taskid, androiddriver, caselog, pcplist);
|
||||
AndroidCaseExecution.caseExcution(testcase, steps, taskId, androiddriver, caselog, pcplist);
|
||||
} else if ("IOS".equals(properties.getProperty("platformName"))) {
|
||||
IosCaseExecution.caseExcution(testcase, steps, taskid, iosdriver, caselog, pcplist);
|
||||
IosCaseExecution.caseExcution(testcase, steps, taskId, iosdriver, caselog, pcplist);
|
||||
}
|
||||
} catch (InterruptedException | IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||
e.printStackTrace();
|
||||
LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||
}
|
||||
luckyclient.publicclass.LogUtil.APP.info("当前用例:【" + testcase.getSign() + "】执行完成......进入下一条");
|
||||
LogUtil.APP.info("当前用例:【" + testcase.getCaseSign() + "】执行完成......进入下一条");
|
||||
}
|
||||
tastcount = LogOperation.updateTastdetail(taskid, cases.size());
|
||||
String testtime = LogOperation.getTestTime(taskid);
|
||||
luckyclient.publicclass.LogUtil.APP.info("当前项目【" + projectname + "】测试计划中的用例已经全部执行完成...");
|
||||
tastcount = LogOperation.updateTaskExecuteData(taskId, cases.size());
|
||||
String testtime = LogOperation.getTestTime(taskId);
|
||||
LogUtil.APP.info("当前项目【" + projectname + "】测试计划中的用例已经全部执行完成...");
|
||||
MailSendInitialization.sendMailInitialization(HtmlMail.htmlSubjectFormat(jobname),
|
||||
HtmlMail.htmlContentFormat(tastcount, taskid, buildstatus, restartstatus, testtime, jobname),
|
||||
taskid, testJob, tastcount);
|
||||
HtmlMail.htmlContentFormat(tastcount, taskId, buildstatus, restartstatus, testtime, jobname),
|
||||
taskId, taskScheduling, tastcount);
|
||||
// 关闭APP以及appium会话
|
||||
if ("Android".equals(properties.getProperty("platformName"))) {
|
||||
androiddriver.closeApp();
|
||||
|
@ -182,12 +183,12 @@ public class AppTestControl {
|
|||
iosdriver.closeApp();
|
||||
}
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("项目构建失败,自动化测试自动退出!请前往JENKINS中检查项目构建情况。");
|
||||
MailSendInitialization.sendMailInitialization(jobname, "构建项目过程中失败,自动化测试自动退出!请前去JENKINS查看构建情况!", taskid, testJob, tastcount);
|
||||
LogUtil.APP.warn("项目构建失败,自动化测试自动退出!请前往JENKINS中检查项目构建情况。");
|
||||
MailSendInitialization.sendMailInitialization(jobname, "构建项目过程中失败,自动化测试自动退出!请前去JENKINS查看构建情况!", taskId, taskScheduling, tastcount);
|
||||
}
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("项目TOMCAT重启失败,自动化测试自动退出!请检查项目TOMCAT运行情况。");
|
||||
MailSendInitialization.sendMailInitialization(jobname, "项目TOMCAT重启失败,自动化测试自动退出!请检查项目TOMCAT运行情况!", taskid, testJob, tastcount);
|
||||
LogUtil.APP.warn("项目TOMCAT重启失败,自动化测试自动退出!请检查项目TOMCAT运行情况。");
|
||||
MailSendInitialization.sendMailInitialization(jobname, "项目TOMCAT重启失败,自动化测试自动退出!请检查项目TOMCAT运行情况!", taskId, taskScheduling, tastcount);
|
||||
}
|
||||
//关闭Appium服务的线程
|
||||
if(as!=null){
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
package luckyclient.caserun.exappium;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
import io.appium.java_client.service.local.AppiumDriverLocalService;
|
||||
import io.appium.java_client.service.local.AppiumServiceBuilder;
|
||||
import io.appium.java_client.service.local.flags.GeneralServerFlag;
|
||||
import luckyclient.publicclass.AppiumConfig;
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
|
||||
public class AppiumService extends Thread{
|
||||
|
||||
public void run(){
|
||||
try{
|
||||
Properties properties = luckyclient.publicclass.AppiumConfig.getConfiguration();
|
||||
Properties properties = AppiumConfig.getConfiguration();
|
||||
File mainjsFile = new File(properties.getProperty("mainjsPath"));
|
||||
String ip=properties.getProperty("appiumsever");
|
||||
AppiumServiceBuilder builder =
|
||||
|
@ -25,12 +26,12 @@ public class AppiumService extends Thread{
|
|||
service.start();
|
||||
|
||||
if (service == null || !service.isRunning()){
|
||||
luckyclient.publicclass.LogUtil.APP.error("自动启动Appium服务失败,请检查!");
|
||||
LogUtil.APP.warn("自动启动Appium服务失败,请检查!");
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.info("自动启动Appium服务成功,监听IP:"+ip.split(":")[0].trim()+" 监听端口:"+ip.split(":")[1].trim());
|
||||
LogUtil.APP.info("自动启动Appium服务成功,监听IP:"+ip.split(":")[0].trim()+" 监听端口:"+ip.split(":")[1].trim());
|
||||
}
|
||||
}catch(Exception e){
|
||||
luckyclient.publicclass.LogUtil.APP.error("自动启动Appium服务抛出异常,请检查!",e);
|
||||
LogUtil.APP.error("自动启动Appium服务抛出异常,请检查!",e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ import io.appium.java_client.android.AndroidElement;
|
|||
import io.appium.java_client.android.AndroidTouchAction;
|
||||
import io.appium.java_client.touch.WaitOptions;
|
||||
import io.appium.java_client.touch.offset.PointOption;
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
@ -32,15 +33,17 @@ public class AndroidBaseAppium {
|
|||
|
||||
/**
|
||||
* 安卓手机报错截图
|
||||
*
|
||||
* @param appium
|
||||
* @param imagname
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void screenShot(AndroidDriver<AndroidElement> appium, String imagname){
|
||||
public static void screenShot(AndroidDriver<AndroidElement> appium, String imagname) {
|
||||
imagname = imagname + ".png";
|
||||
String relativelyPath = System.getProperty("user.dir");
|
||||
String pngpath=relativelyPath +File.separator+ "log"+File.separator+"ScreenShot" +File.separator+ imagname;
|
||||
|
||||
String pngpath = relativelyPath + File.separator + "log" + File.separator + "ScreenShot" + File.separator
|
||||
+ imagname;
|
||||
|
||||
try {
|
||||
try {
|
||||
Thread.sleep(3000);
|
||||
|
@ -52,13 +55,12 @@ public class AndroidBaseAppium {
|
|||
File screenFile = new File(pngpath);
|
||||
FileUtils.copyFile(imageFile, screenFile);
|
||||
imageFile.deleteOnExit();
|
||||
luckyclient.publicclass.LogUtil.APP
|
||||
.info("已对当前界面进行截图操作,可通过用例执行界面的日志明细查看,也可以前往客户端上查看...【" + pngpath + "】");
|
||||
LogUtil.APP.info("已对当前界面进行截图操作,可通过用例执行界面的日志明细查看,也可以前往客户端上查看...【" + pngpath + "】");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param args
|
||||
* @throws IOException
|
||||
|
@ -72,10 +74,10 @@ public class AndroidBaseAppium {
|
|||
|
||||
/**
|
||||
* @param args
|
||||
* js webview 支持4.1~4.4
|
||||
* js webview 支持4.1~4.4
|
||||
*/
|
||||
public static void webViewSwipe(AndroidDriver<AndroidElement> appium, Double sX, Double sY, Double eX, Double eY, Double duration)
|
||||
throws Exception {
|
||||
public static void webViewSwipe(AndroidDriver<AndroidElement> appium, Double sX, Double sY, Double eX, Double eY,
|
||||
Double duration) throws Exception {
|
||||
JavascriptExecutor js;
|
||||
HashMap<String, Double> swipeObject;
|
||||
try {
|
||||
|
@ -100,9 +102,10 @@ public class AndroidBaseAppium {
|
|||
|
||||
/**
|
||||
* @param args
|
||||
* 调用 ADB直接滑动 支持4.1~4.4
|
||||
* 调用 ADB直接滑动 支持4.1~4.4
|
||||
*/
|
||||
public static void adbSwipe(AndroidDriver<AndroidElement> appium, Double sX, Double sY, Double eX, Double eY) throws Exception {
|
||||
public static void adbSwipe(AndroidDriver<AndroidElement> appium, Double sX, Double sY, Double eX, Double eY)
|
||||
throws Exception {
|
||||
int xLine;
|
||||
int yLine;
|
||||
int sX2;
|
||||
|
@ -143,12 +146,15 @@ public class AndroidBaseAppium {
|
|||
tapObject.put("duration", duration);
|
||||
js.executeScript("mobile: tap", tapObject);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 拖住页面按屏幕比例向上滑动(手指向下,页面向上)
|
||||
*
|
||||
* @param driver
|
||||
* @param second 持续时间
|
||||
* @param num 滚动次数
|
||||
* @param second
|
||||
* 持续时间
|
||||
* @param num
|
||||
* 滚动次数
|
||||
*/
|
||||
public static void swipePageUp(AndroidDriver<AndroidElement> driver, Double second, int num) {
|
||||
int nanos = (int) (second * 1000);
|
||||
|
@ -156,7 +162,7 @@ public class AndroidBaseAppium {
|
|||
int width = driver.manage().window().getSize().width;
|
||||
int height = driver.manage().window().getSize().height;
|
||||
AndroidTouchAction action = new AndroidTouchAction(driver);
|
||||
|
||||
|
||||
for (int i = 0; i <= num; i++) {
|
||||
action.press(PointOption.point(width / 2, height / 4)).waitAction(WaitOptions.waitOptions(duration))
|
||||
.moveTo(PointOption.point(width / 2, height / 2)).release().perform();
|
||||
|
@ -165,11 +171,12 @@ public class AndroidBaseAppium {
|
|||
|
||||
/**
|
||||
* 拖住页面按屏幕比例向下滑动(手指向上,页面向下)
|
||||
*
|
||||
* @param driver
|
||||
* @param second
|
||||
* @param num
|
||||
*/
|
||||
public static void swipePageDown(AndroidDriver<AndroidElement> driver,Double second,int num){
|
||||
public static void swipePageDown(AndroidDriver<AndroidElement> driver, Double second, int num) {
|
||||
int nanos = (int) (second * 1000);
|
||||
Duration duration = Duration.ofNanos(nanos);
|
||||
int width = driver.manage().window().getSize().width;
|
||||
|
@ -183,6 +190,7 @@ public class AndroidBaseAppium {
|
|||
|
||||
/**
|
||||
* 拖住页面按屏幕比例向左滑动(手指向左,页面向左滚动)
|
||||
*
|
||||
* @param driver
|
||||
* @param second
|
||||
* @param num
|
||||
|
@ -201,6 +209,7 @@ public class AndroidBaseAppium {
|
|||
|
||||
/**
|
||||
* 拖住页面按屏幕比例向右滑动(手指向右,页面向右)
|
||||
*
|
||||
* @param driver
|
||||
* @param second
|
||||
* @param num
|
||||
|
@ -216,5 +225,5 @@ public class AndroidBaseAppium {
|
|||
.moveTo(PointOption.point(width - 10, height / 2)).release().perform();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -12,11 +12,13 @@ import luckyclient.caserun.exappium.AppiumService;
|
|||
import luckyclient.caserun.exinterface.TestControl;
|
||||
import luckyclient.dblog.DbLink;
|
||||
import luckyclient.dblog.LogOperation;
|
||||
import luckyclient.planapi.api.GetServerAPI;
|
||||
import luckyclient.planapi.entity.ProjectCase;
|
||||
import luckyclient.planapi.entity.ProjectCasesteps;
|
||||
import luckyclient.planapi.entity.PublicCaseParams;
|
||||
import luckyclient.planapi.entity.TestTaskexcute;
|
||||
import luckyclient.publicclass.AppiumConfig;
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
import luckyclient.serverapi.api.GetServerAPI;
|
||||
import luckyclient.serverapi.entity.ProjectCase;
|
||||
import luckyclient.serverapi.entity.ProjectCaseParams;
|
||||
import luckyclient.serverapi.entity.ProjectCaseSteps;
|
||||
import luckyclient.serverapi.entity.TaskExecute;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
@ -38,7 +40,7 @@ public class AndroidBatchExecute {
|
|||
AndroidDriver<AndroidElement> ad = null;
|
||||
AppiumService as=null;
|
||||
try {
|
||||
Properties properties = luckyclient.publicclass.AppiumConfig.getConfiguration();
|
||||
Properties properties = AppiumConfig.getConfiguration();
|
||||
//根据配置自动启动Appiume服务
|
||||
if(Boolean.valueOf(properties.getProperty("autoRunAppiumService"))){
|
||||
as =new AppiumService();
|
||||
|
@ -52,47 +54,42 @@ public class AndroidBatchExecute {
|
|||
e1.printStackTrace();
|
||||
}
|
||||
LogOperation caselog = new LogOperation();
|
||||
TestTaskexcute task = GetServerAPI.cgetTaskbyid(Integer.valueOf(taskid));
|
||||
List<PublicCaseParams> pcplist = GetServerAPI
|
||||
.cgetParamsByProjectid(task.getTestJob().getProjectid().toString());
|
||||
TaskExecute task = GetServerAPI.cgetTaskbyid(Integer.valueOf(taskid));
|
||||
List<ProjectCaseParams> pcplist = GetServerAPI
|
||||
.cgetParamsByProjectid(task.getProjectId().toString());
|
||||
// 执行全部非成功状态用例
|
||||
if (batchcase.indexOf("ALLFAIL") > -1) {
|
||||
String casemore = caselog.unSucCaseUpdate(taskid);
|
||||
String[] temp = casemore.split("\\#", -1);
|
||||
for (int i = 0; i < temp.length; i++) {
|
||||
String testCaseExternalId = temp[i].substring(0, temp[i].indexOf("%"));
|
||||
ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId);
|
||||
List<ProjectCasesteps> steps = GetServerAPI.getStepsbycaseid(testcase.getId());
|
||||
List<Integer> caseIdList = caselog.getCaseListForUnSucByTaskId(taskid);
|
||||
for (int i = 0; i < caseIdList.size(); i++) {
|
||||
ProjectCase testcase = GetServerAPI.cGetCaseByCaseId(caseIdList.get(i));
|
||||
List<ProjectCaseSteps> steps = GetServerAPI.getStepsbycaseid(testcase.getCaseId());
|
||||
// 删除旧的日志
|
||||
LogOperation.deleteCaseLogDetail(testCaseExternalId, taskid);
|
||||
LogOperation.deleteTaskCaseLog(testcase.getCaseId(), taskid);
|
||||
try {
|
||||
AndroidCaseExecution.caseExcution(testcase, steps, taskid, ad, caselog, pcplist);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||
LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} else { // 批量执行用例
|
||||
String[] temp = batchcase.split("\\#", -1);
|
||||
String[] temp = batchcase.split("\\#");
|
||||
for (int i = 0; i < temp.length; i++) {
|
||||
String testCaseExternalId = temp[i].substring(0, temp[i].indexOf("%"));
|
||||
// int version =
|
||||
// Integer.parseInt(temp[i].substring(temp[i].indexOf("%")+1,temp[i].length()));
|
||||
ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId);
|
||||
List<ProjectCasesteps> steps = GetServerAPI.getStepsbycaseid(testcase.getId());
|
||||
ProjectCase testcase = GetServerAPI.cGetCaseByCaseId(Integer.valueOf(temp[i]));
|
||||
List<ProjectCaseSteps> steps = GetServerAPI.getStepsbycaseid(testcase.getCaseId());
|
||||
// 删除旧的日志
|
||||
LogOperation.deleteCaseLogDetail(testCaseExternalId, taskid);
|
||||
LogOperation.deleteTaskCaseLog(testcase.getCaseId(), taskid);
|
||||
try {
|
||||
AndroidCaseExecution.caseExcution(testcase, steps, taskid, ad, caselog, pcplist);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||
LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
LogOperation.updateTastdetail(taskid, 0);
|
||||
LogOperation.updateTaskExecuteData(taskid, 0);
|
||||
ad.closeApp();
|
||||
//关闭Appium服务的线程
|
||||
if(as!=null){
|
||||
|
|
|
@ -17,10 +17,10 @@ import luckyclient.caserun.publicdispose.ActionManageForSteps;
|
|||
import luckyclient.caserun.publicdispose.ChangString;
|
||||
import luckyclient.caserun.publicdispose.ParamsManageForSteps;
|
||||
import luckyclient.dblog.LogOperation;
|
||||
import luckyclient.planapi.entity.ProjectCase;
|
||||
import luckyclient.planapi.entity.ProjectCasesteps;
|
||||
import luckyclient.planapi.entity.PublicCaseParams;
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
import luckyclient.serverapi.entity.ProjectCase;
|
||||
import luckyclient.serverapi.entity.ProjectCaseParams;
|
||||
import luckyclient.serverapi.entity.ProjectCaseSteps;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
@ -37,22 +37,23 @@ public class AndroidCaseExecution extends TestCaseExecution{
|
|||
private static String casenote = "备注初始化";
|
||||
private static String imagname = "";
|
||||
|
||||
public static void caseExcution(ProjectCase testcase, List<ProjectCasesteps> steps,String taskid, AndroidDriver<AndroidElement> appium,LogOperation caselog,List<PublicCaseParams> pcplist)
|
||||
public static void caseExcution(ProjectCase testcase, List<ProjectCaseSteps> steps,String taskid, AndroidDriver<AndroidElement> appium,LogOperation caselog,List<ProjectCaseParams> pcplist)
|
||||
throws InterruptedException, IOException {
|
||||
caselog.updateTaskCaseExecuteStatus(taskid, testcase.getCaseId(), 3);
|
||||
// 把公共参数加入到MAP中
|
||||
for (PublicCaseParams pcp : pcplist) {
|
||||
variable.put(pcp.getParamsname(), pcp.getParamsvalue());
|
||||
for (ProjectCaseParams pcp : pcplist) {
|
||||
variable.put(pcp.getParamsName(), pcp.getParamsValue());
|
||||
}
|
||||
// 加入全局变量
|
||||
variable.putAll(ParamsManageForSteps.GLOBAL_VARIABLE);
|
||||
// 0:成功 1:失败 2:锁定 其他:锁定
|
||||
// 0通过 1失败 2锁定 3执行中 4未执行
|
||||
int setcaseresult = 0;
|
||||
for (ProjectCasesteps step : steps) {
|
||||
for (ProjectCaseSteps step : steps) {
|
||||
Map<String, String> params;
|
||||
String result;
|
||||
|
||||
// 根据步骤类型来分析步骤参数
|
||||
if (4 == step.getSteptype()){
|
||||
if (3 == step.getStepType()){
|
||||
params = AppDriverAnalyticCase.analyticCaseStep(testcase, step, taskid,caselog);
|
||||
}else{
|
||||
params = InterfaceAnalyticCase.analyticCaseStep(testcase, step, taskid, caselog);
|
||||
|
@ -64,10 +65,10 @@ public class AndroidCaseExecution extends TestCaseExecution{
|
|||
}
|
||||
|
||||
// 根据步骤类型来执行步骤
|
||||
if (4 == step.getSteptype()){
|
||||
result = androidRunStep(params, variable, appium, taskid, testcase.getSign(), step.getStepnum(), caselog);
|
||||
if (3 == step.getStepType()){
|
||||
result = androidRunStep(params, variable, appium, taskid, testcase.getCaseId(), step.getStepSerialNumber(), caselog);
|
||||
}else{
|
||||
result = TestCaseExecution.runStep(params, variable, taskid, testcase.getSign(), step, caselog);
|
||||
result = TestCaseExecution.runStep(params, variable, taskid, testcase.getCaseSign(), step, caselog);
|
||||
}
|
||||
|
||||
String expectedResults = params.get("ExpectedResults").toString();
|
||||
|
@ -79,27 +80,27 @@ public class AndroidCaseExecution extends TestCaseExecution{
|
|||
if (0 != stepresult) {
|
||||
setcaseresult = stepresult;
|
||||
if (testcase.getFailcontinue() == 0) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcase.getSign()+"】第【"+step.getStepnum()+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
||||
LogUtil.APP.warn("用例【"+testcase.getCaseSign()+"】第【"+step.getStepSerialNumber()+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
||||
break;
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcase.getSign()+"】第【"+step.getStepnum()+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
||||
LogUtil.APP.warn("用例【"+testcase.getCaseSign()+"】第【"+step.getStepSerialNumber()+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
variable.clear();
|
||||
caselog.updateCaseDetail(taskid, testcase.getSign(), setcaseresult);
|
||||
caselog.updateTaskCaseExecuteStatus(taskid, testcase.getCaseId(), setcaseresult);
|
||||
if(setcaseresult==0){
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例【"+testcase.getSign()+"】全部步骤执行结果成功...");
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "用例全部步骤执行结果成功","info", "ending","");
|
||||
LogUtil.APP.info("用例【"+testcase.getCaseSign()+"】全部步骤执行结果成功...");
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "用例全部步骤执行结果成功","info", "ending","");
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcase.getSign()+"】步骤执行过程中失败或是锁定...请查看具体原因!"+casenote);
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "用例执行过程中失败或是锁定"+casenote,"error", "ending","");
|
||||
LogUtil.APP.warn("用例【"+testcase.getCaseSign()+"】步骤执行过程中失败或是锁定...请查看具体原因!"+casenote);
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "用例执行过程中失败或是锁定"+casenote,"error", "ending","");
|
||||
}
|
||||
//LogOperation.UpdateTastdetail(taskid, 0);
|
||||
}
|
||||
|
||||
public static String androidRunStep(Map<String, String> params, Map<String, String> variable, AndroidDriver<AndroidElement> appium,String taskid,String casenum,int stepno,LogOperation caselog) {
|
||||
public static String androidRunStep(Map<String, String> params, Map<String, String> variable, AndroidDriver<AndroidElement> appium,String taskid,Integer caseId,int stepno,LogOperation caselog) {
|
||||
String result = "";
|
||||
String property;
|
||||
String propertyValue;
|
||||
|
@ -118,11 +119,11 @@ public class AndroidCaseExecution extends TestCaseExecution{
|
|||
operation=ChangString.changparams(operation, variable,"操作");
|
||||
operationValue=ChangString.changparams(operationValue, variable,"操作参数");
|
||||
|
||||
luckyclient.publicclass.LogUtil.APP.info("二次解析用例过程完成,等待进行对象操作......");
|
||||
caselog.caseLogDetail(taskid, casenum, "对象操作:"+operation+"; 操作值:"+operationValue,"info", String.valueOf(stepno),"");
|
||||
LogUtil.APP.info("二次解析用例过程完成,等待进行对象操作......");
|
||||
caselog.insertTaskCaseLog(taskid, caseId, "对象操作:"+operation+"; 操作值:"+operationValue,"info", String.valueOf(stepno),"");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
luckyclient.publicclass.LogUtil.APP.error("二次解析用例过程抛出异常!---"+e.getMessage());
|
||||
LogUtil.APP.error("二次解析用例过程抛出异常!---"+e.getMessage());
|
||||
return "步骤执行失败:解析用例失败!";
|
||||
}
|
||||
|
||||
|
@ -144,7 +145,7 @@ public class AndroidCaseExecution extends TestCaseExecution{
|
|||
ae = isElementExist(appium, property, propertyValue);
|
||||
// 判断此元素是否存在
|
||||
if (null==ae) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("定位对象失败,isElementExist为null!");
|
||||
LogUtil.APP.warn("定位对象失败,isElementExist为null!");
|
||||
return "步骤执行失败:isElementExist定位元素过程失败!";
|
||||
}
|
||||
|
||||
|
@ -164,14 +165,14 @@ public class AndroidCaseExecution extends TestCaseExecution{
|
|||
result = AndroidEncapsulateOperation.driverOperation(appium, operation, operationValue);
|
||||
}
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.error("元素操作过程失败!");
|
||||
LogUtil.APP.warn("元素操作过程失败!");
|
||||
result = "步骤执行失败:元素操作过程失败!";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("元素定位过程或是操作过程失败或异常!"+e.getMessage());
|
||||
LogUtil.APP.error("元素定位过程或是操作过程失败或异常!"+e.getMessage());
|
||||
return "步骤执行失败:元素定位过程或是操作过程失败或异常!" + e.getMessage();
|
||||
}
|
||||
caselog.caseLogDetail(taskid, casenum, result,"info", String.valueOf(stepno),"");
|
||||
caselog.insertTaskCaseLog(taskid, caseId, result,"info", String.valueOf(stepno),"");
|
||||
|
||||
if(result.indexOf("获取到的值是【")>-1&&result.indexOf("】")>-1){
|
||||
result = result.substring(result.indexOf("获取到的值是【")+7, result.length()-1);
|
||||
|
@ -220,13 +221,13 @@ public class AndroidCaseExecution extends TestCaseExecution{
|
|||
return ae;
|
||||
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("当前对象定位失败:"+e.getMessage());
|
||||
LogUtil.APP.error("当前对象定位失败:"+e.getMessage());
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int judgeResult(ProjectCase testcase, ProjectCasesteps step, Map<String, String> params, AndroidDriver<AndroidElement> appium, String taskid, String expect, String result, LogOperation caselog) throws InterruptedException {
|
||||
public static int judgeResult(ProjectCase testcase, ProjectCaseSteps step, Map<String, String> params, AndroidDriver<AndroidElement> appium, String taskid, String expect, String result, LogOperation caselog) throws InterruptedException {
|
||||
int setresult = 0;
|
||||
java.text.DateFormat timeformat = new java.text.SimpleDateFormat("MMdd-hhmmss");
|
||||
imagname = timeformat.format(new Date());
|
||||
|
@ -235,36 +236,36 @@ public class AndroidCaseExecution extends TestCaseExecution{
|
|||
if (null != result && !result.contains("步骤执行失败:")) {
|
||||
// 有预期结果
|
||||
if (null != expect && !expect.isEmpty()) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("期望结果为【" + expect + "】");
|
||||
LogUtil.APP.info("期望结果为【" + expect + "】");
|
||||
|
||||
// 赋值传参模式
|
||||
if (expect.length() > ASSIGNMENT_SIGN.length() && expect.startsWith(ASSIGNMENT_SIGN)) {
|
||||
variable.put(expect.substring(ASSIGNMENT_SIGN.length()), result);
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,将测试结果【" + result + "】赋值给变量【" + expect.substring(ASSIGNMENT_SIGN.length()) + "】");
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "将测试结果【" + result + "】赋值给变量【" + expect.substring(ASSIGNMENT_SIGN.length()) + "】", "info", String.valueOf(step.getStepnum()), "");
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,将测试结果【" + result + "】赋值给变量【" + expect.substring(ASSIGNMENT_SIGN.length()) + "】");
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "将测试结果【" + result + "】赋值给变量【" + expect.substring(ASSIGNMENT_SIGN.length()) + "】", "info", String.valueOf(step.getStepSerialNumber()), "");
|
||||
}
|
||||
// 赋值全局变量
|
||||
else if (expect.length() > ASSIGNMENT_GLOBALSIGN.length() && expect.startsWith(ASSIGNMENT_GLOBALSIGN)) {
|
||||
variable.put(expect.substring(ASSIGNMENT_GLOBALSIGN.length()), result);
|
||||
ParamsManageForSteps.GLOBAL_VARIABLE.put(expect.substring(ASSIGNMENT_GLOBALSIGN.length()), result);
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,将测试结果【" + result + "】赋值给全局变量【" + expect.substring(ASSIGNMENT_GLOBALSIGN.length()) + "】");
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "将测试结果【" + result + "】赋值给全局变量【" + expect.substring(ASSIGNMENT_GLOBALSIGN.length()) + "】", "info", String.valueOf(step.getStepnum()), "");
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,将测试结果【" + result + "】赋值给全局变量【" + expect.substring(ASSIGNMENT_GLOBALSIGN.length()) + "】");
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "将测试结果【" + result + "】赋值给全局变量【" + expect.substring(ASSIGNMENT_GLOBALSIGN.length()) + "】", "info", String.valueOf(step.getStepSerialNumber()), "");
|
||||
}
|
||||
// 移动端 UI检查模式
|
||||
else if (4 == step.getSteptype() && params.get("checkproperty") != null && params.get("checkproperty_value") != null) {
|
||||
else if (3 == step.getStepType() && params.get("checkproperty") != null && params.get("checkproperty_value") != null) {
|
||||
String checkproperty = params.get("checkproperty");
|
||||
String checkPropertyValue = params.get("checkproperty_value");
|
||||
|
||||
AndroidElement ae = isElementExist(appium, checkproperty, checkPropertyValue);
|
||||
if (null != ae) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,在当前页面中找到预期结果中对象。当前步骤执行成功!");
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "在当前页面中找到预期结果中对象。当前步骤执行成功!", "info", String.valueOf(step.getStepnum()), "");
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,在当前页面中找到预期结果中对象。当前步骤执行成功!");
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "在当前页面中找到预期结果中对象。当前步骤执行成功!", "info", String.valueOf(step.getStepSerialNumber()), "");
|
||||
} else {
|
||||
casenote = "第" + step.getStepnum() + "步,没有在当前页面中找到预期结果中对象。执行失败!";
|
||||
casenote = "第" + step.getStepSerialNumber() + "步,没有在当前页面中找到预期结果中对象。执行失败!";
|
||||
setresult = 1;
|
||||
AndroidBaseAppium.screenShot(appium, imagname);
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,没有在当前页面中找到预期结果中对象。当前步骤执行失败!");
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "在当前页面中没有找到预期结果中对象。当前步骤执行失败!" + "checkproperty【" + checkproperty + "】 checkproperty_value【" + checkPropertyValue + "】", "error", String.valueOf(step.getStepnum()), imagname);
|
||||
LogUtil.APP.warn("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,没有在当前页面中找到预期结果中对象。当前步骤执行失败!");
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "在当前页面中没有找到预期结果中对象。当前步骤执行失败!" + "checkproperty【" + checkproperty + "】 checkproperty_value【" + checkPropertyValue + "】", "error", String.valueOf(step.getStepSerialNumber()), imagname);
|
||||
}
|
||||
}
|
||||
// 其它匹配模式
|
||||
|
@ -272,14 +273,14 @@ public class AndroidCaseExecution extends TestCaseExecution{
|
|||
// 模糊匹配预期结果模式
|
||||
if (expect.length() > FUZZY_MATCHING_SIGN.length() && expect.startsWith(FUZZY_MATCHING_SIGN)) {
|
||||
if (result.contains(expect.substring(FUZZY_MATCHING_SIGN.length()))) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,模糊匹配预期结果成功!执行结果:" + result);
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "模糊匹配预期结果成功!执行结果:" + result, "info", String.valueOf(step.getStepnum()), "");
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,模糊匹配预期结果成功!执行结果:" + result);
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "模糊匹配预期结果成功!执行结果:" + result, "info", String.valueOf(step.getStepSerialNumber()), "");
|
||||
} else {
|
||||
casenote = "第" + step.getStepnum() + "步,模糊匹配预期结果失败!";
|
||||
casenote = "第" + step.getStepSerialNumber() + "步,模糊匹配预期结果失败!";
|
||||
setresult = 1;
|
||||
AndroidBaseAppium.screenShot(appium, imagname);
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,模糊匹配预期结果失败!预期结果:" + expect.substring(FUZZY_MATCHING_SIGN.length()) + ",测试结果:" + result);
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "模糊匹配预期结果失败!预期结果:" + expect.substring(FUZZY_MATCHING_SIGN.length()) + ",测试结果:" + result, "error", String.valueOf(step.getStepnum()), imagname);
|
||||
LogUtil.APP.warn("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,模糊匹配预期结果失败!预期结果:" + expect.substring(FUZZY_MATCHING_SIGN.length()) + ",测试结果:" + result);
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "模糊匹配预期结果失败!预期结果:" + expect.substring(FUZZY_MATCHING_SIGN.length()) + ",测试结果:" + result, "error", String.valueOf(step.getStepSerialNumber()), imagname);
|
||||
}
|
||||
}
|
||||
// 正则匹配预期结果模式
|
||||
|
@ -287,27 +288,27 @@ public class AndroidCaseExecution extends TestCaseExecution{
|
|||
Pattern pattern = Pattern.compile(expect.substring(REGULAR_MATCHING_SIGN.length()));
|
||||
Matcher matcher = pattern.matcher(result);
|
||||
if (matcher.find()) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,正则匹配预期结果成功!执行结果:" + result);
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "正则匹配预期结果成功!", "info", String.valueOf(step.getStepnum()), "");
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,正则匹配预期结果成功!执行结果:" + result);
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "正则匹配预期结果成功!", "info", String.valueOf(step.getStepSerialNumber()), "");
|
||||
} else {
|
||||
casenote = "第" + step.getStepnum() + "步,正则匹配预期结果失败!";
|
||||
casenote = "第" + step.getStepSerialNumber() + "步,正则匹配预期结果失败!";
|
||||
setresult = 1;
|
||||
AndroidBaseAppium.screenShot(appium, imagname);
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,正则匹配预期结果失败!预期结果:" + expect.substring(REGULAR_MATCHING_SIGN.length()) + ",测试结果:" + result);
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "正则匹配预期结果失败!预期结果:" + expect.substring(REGULAR_MATCHING_SIGN.length()) + ",测试结果:" + result, "error", String.valueOf(step.getStepnum()), imagname);
|
||||
LogUtil.APP.warn("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,正则匹配预期结果失败!预期结果:" + expect.substring(REGULAR_MATCHING_SIGN.length()) + ",测试结果:" + result);
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "正则匹配预期结果失败!预期结果:" + expect.substring(REGULAR_MATCHING_SIGN.length()) + ",测试结果:" + result, "error", String.valueOf(step.getStepSerialNumber()), imagname);
|
||||
}
|
||||
}
|
||||
// 精确匹配预期结果模式
|
||||
else {
|
||||
if (expect.equals(result)) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,精确匹配预期结果成功!执行结果:" + result);
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "精确匹配预期结果成功!", "info", String.valueOf(step.getStepnum()), "");
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,精确匹配预期结果成功!执行结果:" + result);
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "精确匹配预期结果成功!", "info", String.valueOf(step.getStepSerialNumber()), "");
|
||||
} else {
|
||||
casenote = "第" + step.getStepnum() + "步,精确匹配预期结果失败!";
|
||||
casenote = "第" + step.getStepSerialNumber() + "步,精确匹配预期结果失败!";
|
||||
setresult = 1;
|
||||
AndroidBaseAppium.screenShot(appium, imagname);
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,精确匹配预期结果失败!预期结果是:【"+expect+"】 执行结果:【"+ result+"】");
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "精确匹配预期结果失败!预期结果是:【"+expect+"】 执行结果:【"+ result+"】", "error", String.valueOf(step.getStepnum()), imagname);
|
||||
LogUtil.APP.warn("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,精确匹配预期结果失败!预期结果是:【"+expect+"】 执行结果:【"+ result+"】");
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "精确匹配预期结果失败!预期结果是:【"+expect+"】 执行结果:【"+ result+"】", "error", String.valueOf(step.getStepSerialNumber()), imagname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -316,15 +317,11 @@ public class AndroidCaseExecution extends TestCaseExecution{
|
|||
casenote = (null != result) ? result : "";
|
||||
setresult = 2;
|
||||
AndroidBaseAppium.screenShot(appium, imagname);
|
||||
LogUtil.APP.error("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,执行结果:" + casenote);
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "当前步骤在执行过程中解析|定位元素|操作对象失败!" + casenote, "error", String.valueOf(step.getStepnum()), imagname);
|
||||
LogUtil.APP.warn("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,执行结果:" + casenote);
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "当前步骤在执行过程中解析|定位元素|操作对象失败!" + casenote, "error", String.valueOf(step.getStepSerialNumber()), imagname);
|
||||
}
|
||||
|
||||
return setresult;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,10 +7,11 @@ import io.appium.java_client.android.AndroidDriver;
|
|||
import io.appium.java_client.android.AndroidElement;
|
||||
import luckyclient.dblog.DbLink;
|
||||
import luckyclient.dblog.LogOperation;
|
||||
import luckyclient.planapi.api.GetServerAPI;
|
||||
import luckyclient.planapi.entity.ProjectCase;
|
||||
import luckyclient.planapi.entity.ProjectCasesteps;
|
||||
import luckyclient.planapi.entity.PublicCaseParams;
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
import luckyclient.serverapi.api.GetServerAPI;
|
||||
import luckyclient.serverapi.entity.ProjectCase;
|
||||
import luckyclient.serverapi.entity.ProjectCaseParams;
|
||||
import luckyclient.serverapi.entity.ProjectCaseSteps;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
@ -31,31 +32,33 @@ public class AndroidCaseLocalDebug {
|
|||
|
||||
try {
|
||||
ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId);
|
||||
List<PublicCaseParams> pcplist = GetServerAPI
|
||||
.cgetParamsByProjectid(String.valueOf(testcase.getProjectid()));
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始执行用例:【" + testCaseExternalId + "】......");
|
||||
List<ProjectCasesteps> steps = GetServerAPI.getStepsbycaseid(testcase.getId());
|
||||
List<ProjectCaseParams> pcplist = GetServerAPI
|
||||
.cgetParamsByProjectid(String.valueOf(testcase.getProjectId()));
|
||||
LogUtil.APP.info("开始执行用例:【" + testCaseExternalId + "】......");
|
||||
List<ProjectCaseSteps> steps = GetServerAPI.getStepsbycaseid(testcase.getCaseId());
|
||||
AndroidCaseExecution.caseExcution(testcase, steps, "888888", androiddriver, caselog, pcplist);
|
||||
|
||||
luckyclient.publicclass.LogUtil.APP.info("当前用例:【" + testcase.getSign() + "】执行完成......进入下一条");
|
||||
LogUtil.APP.info("当前用例:【" + testcase.getCaseSign() + "】执行完成......进入下一条");
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||
LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param 项目名
|
||||
* @param 用例编号
|
||||
* @param 用例版本号
|
||||
* 用于在testlink上配置好用例参数后,做多条用例串行调试
|
||||
* 用于做多条用例串行调试
|
||||
* @param androiddriver
|
||||
* @param projectname
|
||||
* @param addtestcase
|
||||
* @author Seagull
|
||||
* @date 2019年4月18日
|
||||
*/
|
||||
public static void moreCaseDebug(AndroidDriver<AndroidElement> androiddriver, String projectname,
|
||||
List<String> addtestcase) {
|
||||
System.out.println("当前调试用例总共:"+addtestcase.size());
|
||||
for(String testCaseExternalId:addtestcase) {
|
||||
try {
|
||||
luckyclient.publicclass.LogUtil.APP
|
||||
LogUtil.APP
|
||||
.info("开始调用方法,项目名:" + projectname + ",用例编号:" + testCaseExternalId);
|
||||
oneCasedebug(androiddriver, testCaseExternalId);
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -17,6 +17,7 @@ import io.appium.java_client.touch.WaitOptions;
|
|||
import io.appium.java_client.touch.offset.ElementOption;
|
||||
import io.appium.java_client.touch.offset.PointOption;
|
||||
import luckyclient.caserun.publicdispose.ChangString;
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
@ -38,20 +39,20 @@ public class AndroidEncapsulateOperation {
|
|||
switch (operation) {
|
||||
case "selectbyvisibletext":
|
||||
select.selectByVisibleText(operationValue);
|
||||
luckyclient.publicclass.LogUtil.APP
|
||||
LogUtil.APP
|
||||
.info("下拉框对象通过VisibleText属性选择...【VisibleText属性值:" + operationValue + "】");
|
||||
break;
|
||||
case "selectbyvalue":
|
||||
select.selectByValue(operationValue);
|
||||
luckyclient.publicclass.LogUtil.APP.info("下拉框对象通过Value属性选择...【Value属性值:" + operationValue + "】");
|
||||
LogUtil.APP.info("下拉框对象通过Value属性选择...【Value属性值:" + operationValue + "】");
|
||||
break;
|
||||
case "selectbyindex":
|
||||
select.selectByIndex(Integer.valueOf(operationValue));
|
||||
luckyclient.publicclass.LogUtil.APP.info("下拉框对象通过Index属性选择...【Index属性值:" + operationValue + "】");
|
||||
LogUtil.APP.info("下拉框对象通过Index属性选择...【Index属性值:" + operationValue + "】");
|
||||
break;
|
||||
case "isselect":
|
||||
result = "获取到的值是【" + ae.isSelected() + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info("判断对象是否已经被选择...【结果值:" + ae.isSelected() + "】");
|
||||
LogUtil.APP.info("判断对象是否已经被选择...【结果值:" + ae.isSelected() + "】");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -65,20 +66,20 @@ public class AndroidEncapsulateOperation {
|
|||
switch (operation) {
|
||||
case "gettext":
|
||||
result = "获取到的值是【" + ae.getText() + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info("getText获取对象text属性...【text属性值:" + result + "】");
|
||||
LogUtil.APP.info("getText获取对象text属性...【text属性值:" + result + "】");
|
||||
break; // 获取输入框内容
|
||||
case "gettagname":
|
||||
result = "获取到的值是【" + ae.getTagName() + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info("getTagName获取对象tagname属性...【tagname属性值:" + result + "】");
|
||||
LogUtil.APP.info("getTagName获取对象tagname属性...【tagname属性值:" + result + "】");
|
||||
break;
|
||||
case "getattribute":
|
||||
result = "获取到的值是【" + ae.getAttribute(value) + "】";
|
||||
luckyclient.publicclass.LogUtil.APP
|
||||
LogUtil.APP
|
||||
.info("getAttribute获取对象【" + value + "】属性...【" + value + "属性值:" + result + "】");
|
||||
break;
|
||||
case "getcssvalue":
|
||||
result = "获取到的值是【" + ae.getCssValue(value) + "】";
|
||||
luckyclient.publicclass.LogUtil.APP
|
||||
LogUtil.APP
|
||||
.info("getCssValue获取对象【" + value + "】属性...【" + value + "属性值:" + result + "】");
|
||||
break;
|
||||
default:
|
||||
|
@ -97,35 +98,35 @@ public class AndroidEncapsulateOperation {
|
|||
case "click":
|
||||
ae.click();
|
||||
result = "click点击对象...【对象定位属性:" + property + "; 定位属性值:" + propertyValue + "】";
|
||||
luckyclient.publicclass.LogUtil.APP
|
||||
LogUtil.APP
|
||||
.info("click点击对象...【对象定位属性:" + property + "; 定位属性值:" + propertyValue + "】");
|
||||
break;
|
||||
case "sendkeys":
|
||||
ae.sendKeys(operationValue);
|
||||
result = "sendKeys对象输入...【对象定位属性:" + property + "; 定位属性值:" + propertyValue + "; 操作值:" + operationValue
|
||||
+ "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info("sendkeys对象输入...【对象定位属性:" + property + "; 定位属性值:" + propertyValue
|
||||
LogUtil.APP.info("sendkeys对象输入...【对象定位属性:" + property + "; 定位属性值:" + propertyValue
|
||||
+ "; 操作值:" + operationValue + "】");
|
||||
break;
|
||||
case "clear":
|
||||
ae.clear();
|
||||
result = "clear清空输入框...【对象定位属性:" + property + "; 定位属性值:" + propertyValue + "】";
|
||||
luckyclient.publicclass.LogUtil.APP
|
||||
LogUtil.APP
|
||||
.info("clear清空输入框...【对象定位属性:" + property + "; 定位属性值:" + propertyValue + "】");
|
||||
break; // 清空输入框
|
||||
case "isenabled":
|
||||
result = "获取到的值是【" + ae.isEnabled() + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info("当前对象判断是否可用布尔值为【" + ae.isEnabled() + "】");
|
||||
LogUtil.APP.info("当前对象判断是否可用布尔值为【" + ae.isEnabled() + "】");
|
||||
break;
|
||||
case "isdisplayed":
|
||||
result = "获取到的值是【" + ae.isDisplayed() + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info("当前对象判断是否可见布尔值为【" + ae.isDisplayed() + "】");
|
||||
LogUtil.APP.info("当前对象判断是否可见布尔值为【" + ae.isDisplayed() + "】");
|
||||
break;
|
||||
case "exjsob":
|
||||
JavascriptExecutor jse = (JavascriptExecutor) appium;
|
||||
jse.executeScript(operationValue, ae);
|
||||
result = "执行JS...【" + operationValue + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info("执行JS...【" + operationValue + "】");
|
||||
LogUtil.APP.info("执行JS...【" + operationValue + "】");
|
||||
break;
|
||||
case "longpresselement":
|
||||
LongPressOptions lpoptions = new LongPressOptions();
|
||||
|
@ -138,7 +139,7 @@ public class AndroidEncapsulateOperation {
|
|||
action.longPress(lpoptions).release().perform();
|
||||
result = "longpresselement在屏幕指定元素上按住" + operationValue + "秒...【对象定位属性:" + property + "; 定位属性值:"
|
||||
+ propertyValue + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -152,15 +153,15 @@ public class AndroidEncapsulateOperation {
|
|||
switch (operation) {
|
||||
case "alertaccept":
|
||||
alert.accept();
|
||||
luckyclient.publicclass.LogUtil.APP.info("弹出框对象点击同意...");
|
||||
LogUtil.APP.info("弹出框对象点击同意...");
|
||||
break;
|
||||
case "alertdismiss":
|
||||
alert.dismiss();
|
||||
luckyclient.publicclass.LogUtil.APP.info("弹出框对象点击取消...");
|
||||
LogUtil.APP.info("弹出框对象点击取消...");
|
||||
break;
|
||||
case "alertgettext":
|
||||
result = "获取到的值是【" + alert.getText() + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info("弹出框对象通过getText获取对象text属性...【Text属性值:" + alert.getText() + "】");
|
||||
LogUtil.APP.info("弹出框对象通过getText获取对象text属性...【Text属性值:" + alert.getText() + "】");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -188,25 +189,25 @@ public class AndroidEncapsulateOperation {
|
|||
}
|
||||
handlenum++;
|
||||
}
|
||||
luckyclient.publicclass.LogUtil.APP.info("getContext获取窗口句柄..." + result);
|
||||
LogUtil.APP.info("getContext获取窗口句柄..." + result);
|
||||
break;
|
||||
case "exjs":
|
||||
JavascriptExecutor jse = (JavascriptExecutor) appium;
|
||||
jse.executeScript(operationValue);
|
||||
result = "执行JS...【" + operationValue + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info("执行JS...【" + operationValue + "】");
|
||||
LogUtil.APP.info("执行JS...【" + operationValue + "】");
|
||||
break;
|
||||
case "exAdbShell":
|
||||
Runtime.getRuntime().exec(operationValue);
|
||||
result = "执行安卓adb命令...【" + operationValue + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info("执行安卓adb命令...【" + operationValue + "】");
|
||||
LogUtil.APP.info("执行安卓adb命令...【" + operationValue + "】");
|
||||
break;
|
||||
case "keycode":
|
||||
// 模拟手机键盘
|
||||
if (ChangString.isNumeric(operationValue)) {
|
||||
appium.pressKeyCode(Integer.valueOf(operationValue));
|
||||
result = "模拟手机键盘发送指令...keycode【" + operationValue + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
} else {
|
||||
|
||||
}
|
||||
|
@ -215,7 +216,7 @@ public class AndroidEncapsulateOperation {
|
|||
case "hidekeyboard":
|
||||
appium.hideKeyboard();
|
||||
result = "隐藏手机键盘...【hideKeyboard】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break;
|
||||
case "gotocontext":
|
||||
Set<String> ctNames = appium.getContextHandles();
|
||||
|
@ -229,19 +230,19 @@ public class AndroidEncapsulateOperation {
|
|||
}
|
||||
if (flag == 1) {
|
||||
result = "切换context至【" + operationValue + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
} else {
|
||||
result = "切换context失败,未找到contextName值为【" + operationValue + "】的对象";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
break;
|
||||
case "getcontext":
|
||||
result = "获取到的值是【" + appium.getContext() + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info("获取页面Context...【" + appium.getContext() + "】");
|
||||
LogUtil.APP.info("获取页面Context...【" + appium.getContext() + "】");
|
||||
break;
|
||||
case "gettitle":
|
||||
result = "获取到的值是【" + appium.getTitle() + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info("获取页面gettitle...【" + appium.getTitle() + "】");
|
||||
LogUtil.APP.info("获取页面gettitle...【" + appium.getTitle() + "】");
|
||||
break;
|
||||
case "swipeup":
|
||||
String[] tempup = operationValue.split("\\|", -1);
|
||||
|
@ -251,14 +252,14 @@ public class AndroidEncapsulateOperation {
|
|||
int num = Integer.valueOf(tempup[1]);
|
||||
AndroidBaseAppium.swipePageUp(appium, second, num);
|
||||
result = "swipeup页面向上滑动参数...秒|次数【" + second + "|" + num + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
} else {
|
||||
result = "swipeup页面向上滑动参数判断次数出现异常【" + tempup[1] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
} else {
|
||||
result = "swipeup页面向上滑动参数判断时间出现异常【" + tempup[0] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
break;
|
||||
case "swipedown":
|
||||
|
@ -269,14 +270,14 @@ public class AndroidEncapsulateOperation {
|
|||
int num = Integer.valueOf(tempdown[1]);
|
||||
AndroidBaseAppium.swipePageDown(appium, second, num);
|
||||
result = "swipedown页面向下滑动参数...秒|次数【" + second + "|" + num + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
} else {
|
||||
result = "swipedown页面向下滑动参数判断次数出现异常【" + tempdown[1] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
} else {
|
||||
result = "swipedown页面向下滑动参数判断时间出现异常【" + tempdown[0] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
break;
|
||||
case "swipleft":
|
||||
|
@ -287,14 +288,14 @@ public class AndroidEncapsulateOperation {
|
|||
int num = Integer.valueOf(templeft[1]);
|
||||
AndroidBaseAppium.swipePageLeft(appium, second, num);
|
||||
result = "swipleft页面向左滑动参数...秒|次数【" + second + "|" + num + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
} else {
|
||||
result = "swipleft页面向左滑动参数判断次数出现异常【" + templeft[1] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
} else {
|
||||
result = "swipleft页面向左滑动参数判断时间出现异常【" + templeft[0] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
break;
|
||||
case "swipright":
|
||||
|
@ -305,14 +306,14 @@ public class AndroidEncapsulateOperation {
|
|||
int num = Integer.valueOf(tempright[1]);
|
||||
AndroidBaseAppium.swipePageRight(appium, second, num);
|
||||
result = "swipright页面向右滑动参数...秒|次数【" + second + "|" + num + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
} else {
|
||||
result = "swipright页面向右滑动参数判断次数出现异常【" + tempright[1] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
} else {
|
||||
result = "swipright页面向右滑动参数判断时间出现异常【" + tempright[0] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
break;
|
||||
case "longpressxy":
|
||||
|
@ -330,19 +331,19 @@ public class AndroidEncapsulateOperation {
|
|||
action.longPress(lpoptions).release().perform();
|
||||
result = "longpressxy在屏幕指定XY坐标上按住" + longpressxy[2] + "秒...X|Y【" + longpressx + "|" + longpressy
|
||||
+ "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
} else {
|
||||
action.longPress(PointOption.point(longpressx, longpressy)).release().perform();
|
||||
result = "longpressxy在屏幕指定XY坐标上长按...X|Y【" + longpressx + "|" + longpressy + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
} else {
|
||||
result = "longpressxy参数指定的Y坐标处理出现异常【" + longpressxy[1] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
} else {
|
||||
result = "longpressxy参数指定的X坐标处理出现异常【" + longpressxy[0] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
break;
|
||||
case "pressxy":
|
||||
|
@ -353,14 +354,14 @@ public class AndroidEncapsulateOperation {
|
|||
int pressy = Integer.valueOf(pressxy[1]);
|
||||
action.press(PointOption.point(pressx, pressy)).release().perform();
|
||||
result = "pressxy在屏幕指定XY坐标上点击...X|Y【" + pressx + "|" + pressy + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
} else {
|
||||
result = "pressxy参数指定的Y坐标处理出现异常【" + pressxy[1] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
} else {
|
||||
result = "pressxy参数指定的X坐标处理出现异常【" + pressxy[0] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
break;
|
||||
case "tapxy":
|
||||
|
@ -371,14 +372,14 @@ public class AndroidEncapsulateOperation {
|
|||
int tapy = Integer.valueOf(tapxy[1]);
|
||||
action.tap(PointOption.point(tapx, tapy)).release().perform();
|
||||
result = "tapxy在屏幕指定XY坐标上轻击...X|Y【" + tapx + "|" + tapy + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
} else {
|
||||
result = "tapxy参数指定的Y坐标处理出现异常【" + tapxy[1] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
} else {
|
||||
result = "tapxy参数指定的X坐标处理出现异常【" + tapxy[0] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
break;
|
||||
case "jspressxy":
|
||||
|
@ -390,19 +391,19 @@ public class AndroidEncapsulateOperation {
|
|||
if (null != jspressxy[2] && ChangString.isNumeric(jspressxy[2])) {
|
||||
AndroidBaseAppium.clickScreenForJs(appium, jspressx, jspressy, Integer.valueOf(jspressxy[2]));
|
||||
result = "jspressxy在屏幕指定XY坐标上按" + jspressxy[2] + "秒...X|Y【" + jspressx + "|" + jspressy + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
} else {
|
||||
AndroidBaseAppium.clickScreenForJs(appium, jspressx, jspressy, 2);
|
||||
result = "jspressxy在屏幕指定XY坐标上按2秒(持续时间判断异常,使用默认2秒时间)...X|Y【" + jspressx + "|" + jspressy + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
} else {
|
||||
result = "jspressxy参数指定的Y坐标处理出现异常【" + jspressxy[1] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
} else {
|
||||
result = "jspressxy参数指定的X坐标处理出现异常【" + jspressxy[0] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
break;
|
||||
case "moveto":
|
||||
|
@ -421,34 +422,34 @@ public class AndroidEncapsulateOperation {
|
|||
action.press(PointOption.point(startx, starty))
|
||||
.waitAction(WaitOptions.waitOptions(Duration.ofNanos(1500)))
|
||||
.moveTo(PointOption.point(endx, endy));
|
||||
luckyclient.publicclass.LogUtil.APP.info("从开始坐标【" + startxy[0] + "," + startxy[1]
|
||||
LogUtil.APP.info("从开始坐标【" + startxy[0] + "," + startxy[1]
|
||||
+ "】拖动至坐标【" + endxy[0] + "," + endxy[1] + "】");
|
||||
} else {
|
||||
if (movexyi == 1) {
|
||||
action.press(PointOption.point(startx, starty))
|
||||
.waitAction(WaitOptions.waitOptions(Duration.ofNanos(1500)))
|
||||
.moveTo(PointOption.point(endx - startx, endy - starty));
|
||||
luckyclient.publicclass.LogUtil.APP.info("从开始坐标【" + startxy[0] + "," + startxy[1]
|
||||
LogUtil.APP.info("从开始坐标【" + startxy[0] + "," + startxy[1]
|
||||
+ "】拖动至坐标【" + endxy[0] + "," + endxy[1] + "】");
|
||||
} else {
|
||||
action.waitAction(WaitOptions.waitOptions(Duration.ofNanos(1500)))
|
||||
.moveTo(PointOption.point(endx - startx, endy - starty));
|
||||
luckyclient.publicclass.LogUtil.APP
|
||||
LogUtil.APP
|
||||
.info("第" + movexyi + "次拖动至坐标【" + endxy[0] + "," + endxy[1] + "】");
|
||||
}
|
||||
startx = endx;
|
||||
starty = endy;
|
||||
}
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("判断结束坐标位置出现异常,结束坐标参数【" + movexy[movexyi] + "】");
|
||||
LogUtil.APP.warn("判断结束坐标位置出现异常,结束坐标参数【" + movexy[movexyi] + "】");
|
||||
}
|
||||
}
|
||||
action.release().perform();
|
||||
result = "moveto全部拖动释放并完成发送...开始位置【" + startxy[0] + "," + startxy[1] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
} else {
|
||||
result = "moveto参数指定的起始坐标处理出现异常【" + movexy[0] + "】,请检查!";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
break;
|
||||
case "timeout":
|
||||
|
@ -458,10 +459,10 @@ public class AndroidEncapsulateOperation {
|
|||
// 设置元素出现最大时长30秒
|
||||
appium.manage().timeouts().implicitlyWait(Integer.valueOf(operationValue), TimeUnit.SECONDS);
|
||||
result = "设置全局页面加载&元素出现最大等待时间【" + operationValue + "】秒...";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
} else {
|
||||
result = "【等待时间转换出错,请检查参数】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result + "原因是因为判断你的等待时间不是数字...");
|
||||
LogUtil.APP.info(result + "原因是因为判断你的等待时间不是数字...");
|
||||
}
|
||||
break;
|
||||
case "screenshot":
|
||||
|
@ -469,7 +470,7 @@ public class AndroidEncapsulateOperation {
|
|||
String imagname = "FunctionScreenShot_" + timeformat.format(new Date());
|
||||
AndroidBaseAppium.screenShot(appium, imagname);
|
||||
result = "截图名称【" + imagname + "】...";
|
||||
luckyclient.publicclass.LogUtil.APP.info("使用方法主动截取当前屏幕..." + result);
|
||||
LogUtil.APP.info("使用方法主动截取当前屏幕..." + result);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -11,10 +11,12 @@ import luckyclient.caserun.exappium.AppiumService;
|
|||
import luckyclient.caserun.exinterface.TestControl;
|
||||
import luckyclient.dblog.DbLink;
|
||||
import luckyclient.dblog.LogOperation;
|
||||
import luckyclient.planapi.api.GetServerAPI;
|
||||
import luckyclient.planapi.entity.ProjectCase;
|
||||
import luckyclient.planapi.entity.ProjectCasesteps;
|
||||
import luckyclient.planapi.entity.PublicCaseParams;
|
||||
import luckyclient.publicclass.AppiumConfig;
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
import luckyclient.serverapi.api.GetServerAPI;
|
||||
import luckyclient.serverapi.entity.ProjectCase;
|
||||
import luckyclient.serverapi.entity.ProjectCaseParams;
|
||||
import luckyclient.serverapi.entity.ProjectCaseSteps;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
@ -29,7 +31,7 @@ import luckyclient.planapi.entity.PublicCaseParams;
|
|||
*/
|
||||
public class AndroidOneCaseExecute {
|
||||
|
||||
public static void oneCaseExecuteForTast(String projectname, String testCaseExternalId, int version, String taskid)
|
||||
public static void oneCaseExecuteForTast(String projectname, Integer caseId, int version, String taskid)
|
||||
throws IOException, InterruptedException {
|
||||
// 记录日志到数据库
|
||||
DbLink.exetype = 0;
|
||||
|
@ -37,7 +39,7 @@ public class AndroidOneCaseExecute {
|
|||
AndroidDriver<AndroidElement> ad = null;
|
||||
AppiumService as=null;
|
||||
try {
|
||||
Properties properties = luckyclient.publicclass.AppiumConfig.getConfiguration();
|
||||
Properties properties = AppiumConfig.getConfiguration();
|
||||
//根据配置自动启动Appiume服务
|
||||
if(Boolean.valueOf(properties.getProperty("autoRunAppiumService"))){
|
||||
as =new AppiumService();
|
||||
|
@ -47,24 +49,24 @@ public class AndroidOneCaseExecute {
|
|||
|
||||
ad = AppiumInitialization.setAndroidAppium(properties);
|
||||
} catch (IOException e1) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("初始化AndroidDriver出错!", e1);
|
||||
LogUtil.APP.error("初始化AndroidDriver出错!", e1);
|
||||
e1.printStackTrace();
|
||||
}
|
||||
LogOperation caselog = new LogOperation();
|
||||
// 删除旧的日志
|
||||
LogOperation.deleteCaseLogDetail(testCaseExternalId, taskid);
|
||||
ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId);
|
||||
List<PublicCaseParams> pcplist = GetServerAPI.cgetParamsByProjectid(String.valueOf(testcase.getProjectid()));
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始执行用例:【" + testCaseExternalId + "】......");
|
||||
ProjectCase testcase = GetServerAPI.cGetCaseByCaseId(caseId);
|
||||
LogOperation.deleteTaskCaseLog(testcase.getCaseId(), taskid);
|
||||
List<ProjectCaseParams> pcplist = GetServerAPI.cgetParamsByProjectid(String.valueOf(testcase.getProjectId()));
|
||||
LogUtil.APP.info("开始执行用例:【" + testcase.getCaseSign() + "】......");
|
||||
try {
|
||||
List<ProjectCasesteps> steps = GetServerAPI.getStepsbycaseid(testcase.getId());
|
||||
List<ProjectCaseSteps> steps = GetServerAPI.getStepsbycaseid(testcase.getCaseId());
|
||||
AndroidCaseExecution.caseExcution(testcase, steps, taskid, ad, caselog, pcplist);
|
||||
luckyclient.publicclass.LogUtil.APP.info("当前用例:【" + testcase.getSign() + "】执行完成......进入下一条");
|
||||
LogUtil.APP.info("当前用例:【" + testcase.getCaseSign() + "】执行完成......进入下一条");
|
||||
} catch (InterruptedException e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||
LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
LogOperation.updateTastdetail(taskid, 0);
|
||||
LogOperation.updateTaskExecuteData(taskid, 0);
|
||||
ad.closeApp();
|
||||
//关闭Appium服务的线程
|
||||
if(as!=null){
|
||||
|
|
|
@ -16,15 +16,14 @@ import io.appium.java_client.ios.IOSElement;
|
|||
import io.appium.java_client.ios.IOSTouchAction;
|
||||
import io.appium.java_client.touch.WaitOptions;
|
||||
import io.appium.java_client.touch.offset.PointOption;
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||
* =================================================================
|
||||
*
|
||||
* @author: seagull
|
||||
*
|
||||
* @author: seagull
|
||||
* @date 2018年2月2日
|
||||
*
|
||||
*/
|
||||
|
@ -51,7 +50,7 @@ public class IosBaseAppium {
|
|||
File screenFile = new File(pngpath);
|
||||
FileUtils.copyFile(imageFile, screenFile);
|
||||
imageFile.deleteOnExit();
|
||||
luckyclient.publicclass.LogUtil.APP
|
||||
LogUtil.APP
|
||||
.info("已对当前界面进行截图操作,可通过用例执行界面的日志明细查看,也可以前往客户端上查看...【" + pngpath + "】");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -12,20 +12,20 @@ import luckyclient.caserun.exappium.AppiumService;
|
|||
import luckyclient.caserun.exinterface.TestControl;
|
||||
import luckyclient.dblog.DbLink;
|
||||
import luckyclient.dblog.LogOperation;
|
||||
import luckyclient.planapi.api.GetServerAPI;
|
||||
import luckyclient.planapi.entity.ProjectCase;
|
||||
import luckyclient.planapi.entity.ProjectCasesteps;
|
||||
import luckyclient.planapi.entity.PublicCaseParams;
|
||||
import luckyclient.planapi.entity.TestTaskexcute;
|
||||
import luckyclient.publicclass.AppiumConfig;
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
import luckyclient.serverapi.api.GetServerAPI;
|
||||
import luckyclient.serverapi.entity.ProjectCase;
|
||||
import luckyclient.serverapi.entity.ProjectCaseParams;
|
||||
import luckyclient.serverapi.entity.ProjectCaseSteps;
|
||||
import luckyclient.serverapi.entity.TaskExecute;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||
* =================================================================
|
||||
*
|
||||
* @author: seagull
|
||||
*
|
||||
* =================================================================
|
||||
* @author: seagull
|
||||
* @date 2018年2月2日
|
||||
*
|
||||
*/
|
||||
|
@ -38,7 +38,7 @@ public class IosBatchExecute {
|
|||
IOSDriver<IOSElement> iosd = null;
|
||||
AppiumService as=null;
|
||||
try {
|
||||
Properties properties = luckyclient.publicclass.AppiumConfig.getConfiguration();
|
||||
Properties properties = AppiumConfig.getConfiguration();
|
||||
//根据配置自动启动Appiume服务
|
||||
if(Boolean.valueOf(properties.getProperty("autoRunAppiumService"))){
|
||||
as =new AppiumService();
|
||||
|
@ -52,47 +52,42 @@ public class IosBatchExecute {
|
|||
e1.printStackTrace();
|
||||
}
|
||||
LogOperation caselog = new LogOperation();
|
||||
TestTaskexcute task = GetServerAPI.cgetTaskbyid(Integer.valueOf(taskid));
|
||||
List<PublicCaseParams> pcplist = GetServerAPI
|
||||
.cgetParamsByProjectid(task.getTestJob().getProjectid().toString());
|
||||
TaskExecute task = GetServerAPI.cgetTaskbyid(Integer.valueOf(taskid));
|
||||
List<ProjectCaseParams> pcplist = GetServerAPI
|
||||
.cgetParamsByProjectid(task.getProjectId().toString());
|
||||
// 执行全部非成功状态用例
|
||||
if (batchcase.indexOf("ALLFAIL") > -1) {
|
||||
String casemore = caselog.unSucCaseUpdate(taskid);
|
||||
String[] temp = casemore.split("\\#", -1);
|
||||
for (int i = 0; i < temp.length; i++) {
|
||||
String testCaseExternalId = temp[i].substring(0, temp[i].indexOf("%"));
|
||||
ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId);
|
||||
List<ProjectCasesteps> steps = GetServerAPI.getStepsbycaseid(testcase.getId());
|
||||
List<Integer> caseIdList = caselog.getCaseListForUnSucByTaskId(taskid);
|
||||
for (int i = 0; i < caseIdList.size(); i++) {
|
||||
ProjectCase testcase = GetServerAPI.cGetCaseByCaseId(caseIdList.get(i));
|
||||
List<ProjectCaseSteps> steps = GetServerAPI.getStepsbycaseid(testcase.getCaseId());
|
||||
// 删除旧的日志
|
||||
LogOperation.deleteCaseLogDetail(testCaseExternalId, taskid);
|
||||
LogOperation.deleteTaskCaseLog(testcase.getCaseId(), taskid);
|
||||
try {
|
||||
IosCaseExecution.caseExcution(testcase, steps, taskid, iosd, caselog, pcplist);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||
LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} else { // 批量执行用例
|
||||
String[] temp = batchcase.split("\\#", -1);
|
||||
String[] temp = batchcase.split("\\#");
|
||||
for (int i = 0; i < temp.length; i++) {
|
||||
String testCaseExternalId = temp[i].substring(0, temp[i].indexOf("%"));
|
||||
// int version =
|
||||
// Integer.parseInt(temp[i].substring(temp[i].indexOf("%")+1,temp[i].length()));
|
||||
ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId);
|
||||
List<ProjectCasesteps> steps = GetServerAPI.getStepsbycaseid(testcase.getId());
|
||||
ProjectCase testcase = GetServerAPI.cGetCaseByCaseId(Integer.valueOf(temp[i]));
|
||||
List<ProjectCaseSteps> steps = GetServerAPI.getStepsbycaseid(testcase.getCaseId());
|
||||
// 删除旧的日志
|
||||
LogOperation.deleteCaseLogDetail(testCaseExternalId, taskid);
|
||||
LogOperation.deleteTaskCaseLog(testcase.getCaseId(), taskid);
|
||||
try {
|
||||
IosCaseExecution.caseExcution(testcase, steps, taskid, iosd, caselog, pcplist);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||
LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
LogOperation.updateTastdetail(taskid, 0);
|
||||
LogOperation.updateTaskExecuteData(taskid, 0);
|
||||
iosd.closeApp();
|
||||
//关闭Appium服务的线程
|
||||
if(as!=null){
|
||||
|
|
|
@ -17,10 +17,10 @@ import luckyclient.caserun.publicdispose.ActionManageForSteps;
|
|||
import luckyclient.caserun.publicdispose.ChangString;
|
||||
import luckyclient.caserun.publicdispose.ParamsManageForSteps;
|
||||
import luckyclient.dblog.LogOperation;
|
||||
import luckyclient.planapi.entity.ProjectCase;
|
||||
import luckyclient.planapi.entity.ProjectCasesteps;
|
||||
import luckyclient.planapi.entity.PublicCaseParams;
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
import luckyclient.serverapi.entity.ProjectCase;
|
||||
import luckyclient.serverapi.entity.ProjectCaseParams;
|
||||
import luckyclient.serverapi.entity.ProjectCaseSteps;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
@ -37,23 +37,24 @@ public class IosCaseExecution extends TestCaseExecution{
|
|||
private static String casenote = "备注初始化";
|
||||
private static String imagname = "";
|
||||
|
||||
public static void caseExcution(ProjectCase testcase, List<ProjectCasesteps> steps,String taskid, IOSDriver<IOSElement> appium,LogOperation caselog,List<PublicCaseParams> pcplist)
|
||||
public static void caseExcution(ProjectCase testcase, List<ProjectCaseSteps> steps,String taskid, IOSDriver<IOSElement> appium,LogOperation caselog,List<ProjectCaseParams> pcplist)
|
||||
throws InterruptedException, IOException {
|
||||
caselog.updateTaskCaseExecuteStatus(taskid, testcase.getCaseId(), 3);
|
||||
// 把公共参数加入到MAP中
|
||||
for (PublicCaseParams pcp : pcplist) {
|
||||
variable.put(pcp.getParamsname(), pcp.getParamsvalue());
|
||||
for (ProjectCaseParams pcp : pcplist) {
|
||||
variable.put(pcp.getParamsName(), pcp.getParamsValue());
|
||||
}
|
||||
// 加入全局变量
|
||||
variable.putAll(ParamsManageForSteps.GLOBAL_VARIABLE);
|
||||
|
||||
// 0:成功 1:失败 2:锁定 其他:锁定
|
||||
int setcaseresult = 0;
|
||||
for (ProjectCasesteps step : steps) {
|
||||
for (ProjectCaseSteps step : steps) {
|
||||
Map<String, String> params;
|
||||
String result;
|
||||
|
||||
// 根据步骤类型来分析步骤参数
|
||||
if (4 == step.getSteptype()){
|
||||
if (3 == step.getStepType()){
|
||||
params = AppDriverAnalyticCase.analyticCaseStep(testcase, step, taskid,caselog);
|
||||
}else{
|
||||
params = InterfaceAnalyticCase.analyticCaseStep(testcase, step, taskid, caselog);
|
||||
|
@ -65,10 +66,10 @@ public class IosCaseExecution extends TestCaseExecution{
|
|||
}
|
||||
|
||||
// 根据步骤类型来执行步骤
|
||||
if (4 == step.getSteptype()){
|
||||
result = iosRunStep(params, variable, appium, taskid, testcase.getSign(), step.getStepnum(), caselog);
|
||||
if (3 == step.getStepType()){
|
||||
result = iosRunStep(params, variable, appium, taskid, testcase.getCaseId(), step.getStepSerialNumber(), caselog);
|
||||
}else{
|
||||
result = TestCaseExecution.runStep(params, variable, taskid, testcase.getSign(), step, caselog);
|
||||
result = TestCaseExecution.runStep(params, variable, taskid, testcase.getCaseSign(), step, caselog);
|
||||
}
|
||||
|
||||
String expectedResults = params.get("ExpectedResults").toString();
|
||||
|
@ -80,28 +81,28 @@ public class IosCaseExecution extends TestCaseExecution{
|
|||
if (0 != stepresult) {
|
||||
setcaseresult = stepresult;
|
||||
if (testcase.getFailcontinue() == 0) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcase.getSign()+"】第【"+step.getStepnum()+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
||||
LogUtil.APP.warn("用例【"+testcase.getCaseSign()+"】第【"+step.getStepSerialNumber()+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
||||
break;
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcase.getSign()+"】第【"+step.getStepnum()+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
||||
LogUtil.APP.warn("用例【"+testcase.getCaseSign()+"】第【"+step.getStepSerialNumber()+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
variable.clear();
|
||||
caselog.updateCaseDetail(taskid, testcase.getSign(), setcaseresult);
|
||||
caselog.updateTaskCaseExecuteStatus(taskid, testcase.getCaseId(), setcaseresult);
|
||||
if(setcaseresult==0){
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例【"+testcase.getSign()+"】全部步骤执行结果成功...");
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "用例全部步骤执行结果成功","info", "ending","");
|
||||
LogUtil.APP.info("用例【"+testcase.getCaseSign()+"】全部步骤执行结果成功...");
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "用例全部步骤执行结果成功","info", "ending","");
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcase.getSign()+"】步骤执行过程中失败或是锁定...请查看具体原因!"+casenote);
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "用例执行过程中失败或是锁定"+casenote,"error", "ending","");
|
||||
LogUtil.APP.warn("用例【"+testcase.getCaseSign()+"】步骤执行过程中失败或是锁定...请查看具体原因!"+casenote);
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "用例执行过程中失败或是锁定"+casenote,"error", "ending","");
|
||||
}
|
||||
//LogOperation.UpdateTastdetail(taskid, 0);
|
||||
}
|
||||
|
||||
public static String iosRunStep(Map<String, String> params, Map<String, String> variable, IOSDriver<IOSElement> appium,String taskid,String casenum,int stepno,LogOperation caselog) {
|
||||
public static String iosRunStep(Map<String, String> params, Map<String, String> variable, IOSDriver<IOSElement> appium,String taskid,Integer caseId,int stepno,LogOperation caselog) {
|
||||
String result = "";
|
||||
String property;
|
||||
String propertyValue;
|
||||
|
@ -120,11 +121,11 @@ public class IosCaseExecution extends TestCaseExecution{
|
|||
operation=ChangString.changparams(operation, variable,"操作");
|
||||
operationValue=ChangString.changparams(operationValue, variable,"操作参数");
|
||||
|
||||
luckyclient.publicclass.LogUtil.APP.info("二次解析用例过程完成,等待进行对象操作......");
|
||||
caselog.caseLogDetail(taskid, casenum, "对象操作:"+operation+"; 操作值:"+operationValue,"info", String.valueOf(stepno),"");
|
||||
LogUtil.APP.info("二次解析用例过程完成,等待进行对象操作......");
|
||||
caselog.insertTaskCaseLog(taskid, caseId, "对象操作:"+operation+"; 操作值:"+operationValue,"info", String.valueOf(stepno),"");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
luckyclient.publicclass.LogUtil.APP.error("二次解析用例过程抛出异常!---"+e.getMessage());
|
||||
LogUtil.APP.error("二次解析用例过程抛出异常!---"+e.getMessage());
|
||||
return "步骤执行失败:解析用例失败!";
|
||||
}
|
||||
|
||||
|
@ -146,7 +147,7 @@ public class IosCaseExecution extends TestCaseExecution{
|
|||
ae = isElementExist(appium, property, propertyValue);
|
||||
// 判断此元素是否存在
|
||||
if (null==ae) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("定位对象失败,isElementExist为null!");
|
||||
LogUtil.APP.warn("定位对象失败,isElementExist为null!");
|
||||
return "步骤执行失败:isElementExist定位元素过程失败!";
|
||||
}
|
||||
|
||||
|
@ -166,14 +167,14 @@ public class IosCaseExecution extends TestCaseExecution{
|
|||
result = IosEncapsulateOperation.driverOperation(appium, operation, operationValue);
|
||||
}
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.error("元素操作过程失败!");
|
||||
LogUtil.APP.warn("元素操作过程失败!");
|
||||
result = "步骤执行失败:元素操作过程失败!";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("元素定位过程或是操作过程失败或异常!"+e.getMessage());
|
||||
LogUtil.APP.error("元素定位过程或是操作过程失败或异常!"+e.getMessage());
|
||||
return "步骤执行失败:元素定位过程或是操作过程失败或异常!" + e.getMessage();
|
||||
}
|
||||
caselog.caseLogDetail(taskid, casenum, result,"info", String.valueOf(stepno),"");
|
||||
caselog.insertTaskCaseLog(taskid, caseId, result,"info", String.valueOf(stepno),"");
|
||||
|
||||
if(result.indexOf("获取到的值是【")>-1&&result.indexOf("】")>-1){
|
||||
result = result.substring(result.indexOf("获取到的值是【")+7, result.length()-1);
|
||||
|
@ -228,13 +229,13 @@ public class IosCaseExecution extends TestCaseExecution{
|
|||
return ae;
|
||||
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("当前对象定位失败:"+e.getMessage());
|
||||
LogUtil.APP.error("当前对象定位失败:"+e.getMessage());
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int judgeResult(ProjectCase testcase, ProjectCasesteps step, Map<String, String> params, IOSDriver<IOSElement> appium, String taskid, String expect, String result, LogOperation caselog) throws InterruptedException {
|
||||
public static int judgeResult(ProjectCase testcase, ProjectCaseSteps step, Map<String, String> params, IOSDriver<IOSElement> appium, String taskid, String expect, String result, LogOperation caselog) throws InterruptedException {
|
||||
int setresult = 0;
|
||||
java.text.DateFormat timeformat = new java.text.SimpleDateFormat("MMdd-hhmmss");
|
||||
imagname = timeformat.format(new Date());
|
||||
|
@ -243,36 +244,36 @@ public class IosCaseExecution extends TestCaseExecution{
|
|||
if (null != result && !result.contains("步骤执行失败:")) {
|
||||
// 有预期结果
|
||||
if (null != expect && !expect.isEmpty()) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("期望结果为【" + expect + "】");
|
||||
LogUtil.APP.info("期望结果为【" + expect + "】");
|
||||
|
||||
// 赋值传参模式
|
||||
if (expect.length() > ASSIGNMENT_SIGN.length() && expect.startsWith(ASSIGNMENT_SIGN)) {
|
||||
variable.put(expect.substring(ASSIGNMENT_SIGN.length()), result);
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,将测试结果【" + result + "】赋值给变量【" + expect.substring(ASSIGNMENT_SIGN.length()) + "】");
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "将测试结果【" + result + "】赋值给变量【" + expect.substring(ASSIGNMENT_SIGN.length()) + "】", "info", String.valueOf(step.getStepnum()), "");
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,将测试结果【" + result + "】赋值给变量【" + expect.substring(ASSIGNMENT_SIGN.length()) + "】");
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "将测试结果【" + result + "】赋值给变量【" + expect.substring(ASSIGNMENT_SIGN.length()) + "】", "info", String.valueOf(step.getStepSerialNumber()), "");
|
||||
}
|
||||
// 赋值全局变量
|
||||
else if (expect.length() > ASSIGNMENT_GLOBALSIGN.length() && expect.startsWith(ASSIGNMENT_GLOBALSIGN)) {
|
||||
variable.put(expect.substring(ASSIGNMENT_GLOBALSIGN.length()), result);
|
||||
ParamsManageForSteps.GLOBAL_VARIABLE.put(expect.substring(ASSIGNMENT_GLOBALSIGN.length()), result);
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,将测试结果【" + result + "】赋值给全局变量【" + expect.substring(ASSIGNMENT_GLOBALSIGN.length()) + "】");
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "将测试结果【" + result + "】赋值给全局变量【" + expect.substring(ASSIGNMENT_GLOBALSIGN.length()) + "】", "info", String.valueOf(step.getStepnum()), "");
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,将测试结果【" + result + "】赋值给全局变量【" + expect.substring(ASSIGNMENT_GLOBALSIGN.length()) + "】");
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "将测试结果【" + result + "】赋值给全局变量【" + expect.substring(ASSIGNMENT_GLOBALSIGN.length()) + "】", "info", String.valueOf(step.getStepSerialNumber()), "");
|
||||
}
|
||||
// 移动端 UI检查模式
|
||||
else if (4 == step.getSteptype() && params.get("checkproperty") != null && params.get("checkproperty_value") != null) {
|
||||
else if (3 == step.getStepType() && params.get("checkproperty") != null && params.get("checkproperty_value") != null) {
|
||||
String checkproperty = params.get("checkproperty");
|
||||
String checkPropertyValue = params.get("checkproperty_value");
|
||||
|
||||
IOSElement ae = isElementExist(appium, checkproperty, checkPropertyValue);
|
||||
if (null != ae) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,在当前页面中找到预期结果中对象。当前步骤执行成功!");
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "在当前页面中找到预期结果中对象。当前步骤执行成功!", "info", String.valueOf(step.getStepnum()), "");
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,在当前页面中找到预期结果中对象。当前步骤执行成功!");
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "在当前页面中找到预期结果中对象。当前步骤执行成功!", "info", String.valueOf(step.getStepSerialNumber()), "");
|
||||
} else {
|
||||
casenote = "第" + step.getStepnum() + "步,没有在当前页面中找到预期结果中对象。执行失败!";
|
||||
casenote = "第" + step.getStepSerialNumber() + "步,没有在当前页面中找到预期结果中对象。执行失败!";
|
||||
setresult = 1;
|
||||
IosBaseAppium.screenShot(appium, imagname);
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,没有在当前页面中找到预期结果中对象。当前步骤执行失败!");
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "在当前页面中没有找到预期结果中对象。当前步骤执行失败!" + "checkproperty【" + checkproperty + "】 checkproperty_value【" + checkPropertyValue + "】", "error", String.valueOf(step.getStepnum()), imagname);
|
||||
LogUtil.APP.warn("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,没有在当前页面中找到预期结果中对象。当前步骤执行失败!");
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "在当前页面中没有找到预期结果中对象。当前步骤执行失败!" + "checkproperty【" + checkproperty + "】 checkproperty_value【" + checkPropertyValue + "】", "error", String.valueOf(step.getStepSerialNumber()), imagname);
|
||||
}
|
||||
}
|
||||
// 其它匹配模式
|
||||
|
@ -280,14 +281,14 @@ public class IosCaseExecution extends TestCaseExecution{
|
|||
// 模糊匹配预期结果模式
|
||||
if (expect.length() > FUZZY_MATCHING_SIGN.length() && expect.startsWith(FUZZY_MATCHING_SIGN)) {
|
||||
if (result.contains(expect.substring(FUZZY_MATCHING_SIGN.length()))) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,模糊匹配预期结果成功!执行结果:" + result);
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "模糊匹配预期结果成功!执行结果:" + result, "info", String.valueOf(step.getStepnum()), "");
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,模糊匹配预期结果成功!执行结果:" + result);
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "模糊匹配预期结果成功!执行结果:" + result, "info", String.valueOf(step.getStepSerialNumber()), "");
|
||||
} else {
|
||||
casenote = "第" + step.getStepnum() + "步,模糊匹配预期结果失败!";
|
||||
casenote = "第" + step.getStepSerialNumber() + "步,模糊匹配预期结果失败!";
|
||||
setresult = 1;
|
||||
IosBaseAppium.screenShot(appium, imagname);
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,模糊匹配预期结果失败!预期结果:" + expect.substring(FUZZY_MATCHING_SIGN.length()) + ",测试结果:" + result);
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "模糊匹配预期结果失败!预期结果:" + expect.substring(FUZZY_MATCHING_SIGN.length()) + ",测试结果:" + result, "error", String.valueOf(step.getStepnum()), imagname);
|
||||
LogUtil.APP.warn("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,模糊匹配预期结果失败!预期结果:" + expect.substring(FUZZY_MATCHING_SIGN.length()) + ",测试结果:" + result);
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "模糊匹配预期结果失败!预期结果:" + expect.substring(FUZZY_MATCHING_SIGN.length()) + ",测试结果:" + result, "error", String.valueOf(step.getStepSerialNumber()), imagname);
|
||||
}
|
||||
}
|
||||
// 正则匹配预期结果模式
|
||||
|
@ -295,27 +296,27 @@ public class IosCaseExecution extends TestCaseExecution{
|
|||
Pattern pattern = Pattern.compile(expect.substring(REGULAR_MATCHING_SIGN.length()));
|
||||
Matcher matcher = pattern.matcher(result);
|
||||
if (matcher.find()) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,正则匹配预期结果成功!执行结果:" + result);
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "正则匹配预期结果成功!", "info", String.valueOf(step.getStepnum()), "");
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,正则匹配预期结果成功!执行结果:" + result);
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "正则匹配预期结果成功!", "info", String.valueOf(step.getStepSerialNumber()), "");
|
||||
} else {
|
||||
casenote = "第" + step.getStepnum() + "步,正则匹配预期结果失败!";
|
||||
casenote = "第" + step.getStepSerialNumber() + "步,正则匹配预期结果失败!";
|
||||
setresult = 1;
|
||||
IosBaseAppium.screenShot(appium, imagname);
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,正则匹配预期结果失败!预期结果:" + expect.substring(REGULAR_MATCHING_SIGN.length()) + ",测试结果:" + result);
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "正则匹配预期结果失败!预期结果:" + expect.substring(REGULAR_MATCHING_SIGN.length()) + ",测试结果:" + result, "error", String.valueOf(step.getStepnum()), imagname);
|
||||
LogUtil.APP.warn("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,正则匹配预期结果失败!预期结果:" + expect.substring(REGULAR_MATCHING_SIGN.length()) + ",测试结果:" + result);
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "正则匹配预期结果失败!预期结果:" + expect.substring(REGULAR_MATCHING_SIGN.length()) + ",测试结果:" + result, "error", String.valueOf(step.getStepSerialNumber()), imagname);
|
||||
}
|
||||
}
|
||||
// 精确匹配预期结果模式
|
||||
else {
|
||||
if (expect.equals(result)) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,精确匹配预期结果成功!执行结果:" + result);
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "精确匹配预期结果成功!", "info", String.valueOf(step.getStepnum()), "");
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,精确匹配预期结果成功!执行结果:" + result);
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "精确匹配预期结果成功!", "info", String.valueOf(step.getStepSerialNumber()), "");
|
||||
} else {
|
||||
casenote = "第" + step.getStepnum() + "步,精确匹配预期结果失败!";
|
||||
casenote = "第" + step.getStepSerialNumber() + "步,精确匹配预期结果失败!";
|
||||
setresult = 1;
|
||||
IosBaseAppium.screenShot(appium, imagname);
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,精确匹配预期结果失败!预期结果是:【"+expect+"】 执行结果:【"+ result+"】");
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "精确匹配预期结果失败!预期结果是:【"+expect+"】 执行结果:【"+ result+"】", "error", String.valueOf(step.getStepnum()), imagname);
|
||||
LogUtil.APP.warn("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,精确匹配预期结果失败!预期结果是:【"+expect+"】 执行结果:【"+ result+"】");
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "精确匹配预期结果失败!预期结果是:【"+expect+"】 执行结果:【"+ result+"】", "error", String.valueOf(step.getStepSerialNumber()), imagname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -324,8 +325,8 @@ public class IosCaseExecution extends TestCaseExecution{
|
|||
casenote = (null != result) ? result : "";
|
||||
setresult = 2;
|
||||
IosBaseAppium.screenShot(appium, imagname);
|
||||
LogUtil.APP.error("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,执行结果:" + casenote);
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "当前步骤在执行过程中解析|定位元素|操作对象失败!" + casenote, "error", String.valueOf(step.getStepnum()), imagname);
|
||||
LogUtil.APP.warn("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,执行结果:" + casenote);
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "当前步骤在执行过程中解析|定位元素|操作对象失败!" + casenote, "error", String.valueOf(step.getStepSerialNumber()), imagname);
|
||||
}
|
||||
|
||||
return setresult;
|
||||
|
|
|
@ -7,10 +7,11 @@ import io.appium.java_client.ios.IOSDriver;
|
|||
import io.appium.java_client.ios.IOSElement;
|
||||
import luckyclient.dblog.DbLink;
|
||||
import luckyclient.dblog.LogOperation;
|
||||
import luckyclient.planapi.api.GetServerAPI;
|
||||
import luckyclient.planapi.entity.ProjectCase;
|
||||
import luckyclient.planapi.entity.ProjectCasesteps;
|
||||
import luckyclient.planapi.entity.PublicCaseParams;
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
import luckyclient.serverapi.api.GetServerAPI;
|
||||
import luckyclient.serverapi.entity.ProjectCase;
|
||||
import luckyclient.serverapi.entity.ProjectCaseParams;
|
||||
import luckyclient.serverapi.entity.ProjectCaseSteps;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
@ -31,15 +32,15 @@ public class IosCaseLocalDebug {
|
|||
|
||||
try {
|
||||
ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId);
|
||||
List<PublicCaseParams> pcplist = GetServerAPI
|
||||
.cgetParamsByProjectid(String.valueOf(testcase.getProjectid()));
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始执行用例:【" + testCaseExternalId + "】......");
|
||||
List<ProjectCasesteps> steps = GetServerAPI.getStepsbycaseid(testcase.getId());
|
||||
List<ProjectCaseParams> pcplist = GetServerAPI
|
||||
.cgetParamsByProjectid(String.valueOf(testcase.getProjectId()));
|
||||
LogUtil.APP.info("开始执行用例:【" + testCaseExternalId + "】......");
|
||||
List<ProjectCaseSteps> steps = GetServerAPI.getStepsbycaseid(testcase.getCaseId());
|
||||
IosCaseExecution.caseExcution(testcase, steps, "888888", iosdriver, caselog, pcplist);
|
||||
|
||||
luckyclient.publicclass.LogUtil.APP.info("当前用例:【" + testcase.getSign() + "】执行完成......进入下一条");
|
||||
LogUtil.APP.info("当前用例:【" + testcase.getCaseSign() + "】执行完成......进入下一条");
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||
LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +56,7 @@ public class IosCaseLocalDebug {
|
|||
System.out.println("当前调试用例总共:"+addtestcase.size());
|
||||
for(String testCaseExternalId:addtestcase) {
|
||||
try {
|
||||
luckyclient.publicclass.LogUtil.APP
|
||||
LogUtil.APP
|
||||
.info("开始调用方法,项目名:" + projectname + ",用例编号:" + testCaseExternalId);
|
||||
oneCasedebug(iosdriver, testCaseExternalId);
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -17,6 +17,7 @@ import io.appium.java_client.touch.WaitOptions;
|
|||
import io.appium.java_client.touch.offset.ElementOption;
|
||||
import io.appium.java_client.touch.offset.PointOption;
|
||||
import luckyclient.caserun.publicdispose.ChangString;
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
@ -38,20 +39,20 @@ public class IosEncapsulateOperation {
|
|||
switch (operation) {
|
||||
case "selectbyvisibletext":
|
||||
select.selectByVisibleText(operationValue);
|
||||
luckyclient.publicclass.LogUtil.APP
|
||||
LogUtil.APP
|
||||
.info("下拉框对象通过VisibleText属性选择...【VisibleText属性值:" + operationValue + "】");
|
||||
break;
|
||||
case "selectbyvalue":
|
||||
select.selectByValue(operationValue);
|
||||
luckyclient.publicclass.LogUtil.APP.info("下拉框对象通过Value属性选择...【Value属性值:" + operationValue + "】");
|
||||
LogUtil.APP.info("下拉框对象通过Value属性选择...【Value属性值:" + operationValue + "】");
|
||||
break;
|
||||
case "selectbyindex":
|
||||
select.selectByIndex(Integer.valueOf(operationValue));
|
||||
luckyclient.publicclass.LogUtil.APP.info("下拉框对象通过Index属性选择...【Index属性值:" + operationValue + "】");
|
||||
LogUtil.APP.info("下拉框对象通过Index属性选择...【Index属性值:" + operationValue + "】");
|
||||
break;
|
||||
case "isselect":
|
||||
result = "获取到的值是【" + ie.isSelected() + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info("判断对象是否已经被选择...【结果值:" + ie.isSelected() + "】");
|
||||
LogUtil.APP.info("判断对象是否已经被选择...【结果值:" + ie.isSelected() + "】");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -65,20 +66,20 @@ public class IosEncapsulateOperation {
|
|||
switch (operation) {
|
||||
case "gettext":
|
||||
result = "获取到的值是【" + ie.getText() + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info("getText获取对象text属性...【text属性值:" + result + "】");
|
||||
LogUtil.APP.info("getText获取对象text属性...【text属性值:" + result + "】");
|
||||
break; // 获取输入框内容
|
||||
case "gettagname":
|
||||
result = "获取到的值是【" + ie.getTagName() + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info("getTagName获取对象tagname属性...【tagname属性值:" + result + "】");
|
||||
LogUtil.APP.info("getTagName获取对象tagname属性...【tagname属性值:" + result + "】");
|
||||
break;
|
||||
case "getattribute":
|
||||
result = "获取到的值是【" + ie.getAttribute(value) + "】";
|
||||
luckyclient.publicclass.LogUtil.APP
|
||||
LogUtil.APP
|
||||
.info("getAttribute获取对象【" + value + "】属性...【" + value + "属性值:" + result + "】");
|
||||
break;
|
||||
case "getcssvalue":
|
||||
result = "获取到的值是【" + ie.getCssValue(value) + "】";
|
||||
luckyclient.publicclass.LogUtil.APP
|
||||
LogUtil.APP
|
||||
.info("getCssValue获取对象【" + value + "】属性...【" + value + "属性值:" + result + "】");
|
||||
break;
|
||||
default:
|
||||
|
@ -96,35 +97,35 @@ public class IosEncapsulateOperation {
|
|||
case "click":
|
||||
ie.click();
|
||||
result = "click点击对象...【对象定位属性:" + property + "; 定位属性值:" + propertyValue + "】";
|
||||
luckyclient.publicclass.LogUtil.APP
|
||||
LogUtil.APP
|
||||
.info("click点击对象...【对象定位属性:" + property + "; 定位属性值:" + propertyValue + "】");
|
||||
break;
|
||||
case "sendkeys":
|
||||
ie.sendKeys(operationValue);
|
||||
result = "sendKeys对象输入...【对象定位属性:" + property + "; 定位属性值:" + propertyValue + "; 操作值:" + operationValue
|
||||
+ "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info("sendkeys对象输入...【对象定位属性:" + property + "; 定位属性值:" + propertyValue
|
||||
LogUtil.APP.info("sendkeys对象输入...【对象定位属性:" + property + "; 定位属性值:" + propertyValue
|
||||
+ "; 操作值:" + operationValue + "】");
|
||||
break;
|
||||
case "clear":
|
||||
ie.clear();
|
||||
result = "clear清空输入框...【对象定位属性:" + property + "; 定位属性值:" + propertyValue + "】";
|
||||
luckyclient.publicclass.LogUtil.APP
|
||||
LogUtil.APP
|
||||
.info("clear清空输入框...【对象定位属性:" + property + "; 定位属性值:" + propertyValue + "】");
|
||||
break; // 清空输入框
|
||||
case "isenabled":
|
||||
result = "获取到的值是【" + ie.isEnabled() + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info("当前对象判断是否可用布尔值为【" + ie.isEnabled() + "】");
|
||||
LogUtil.APP.info("当前对象判断是否可用布尔值为【" + ie.isEnabled() + "】");
|
||||
break;
|
||||
case "isdisplayed":
|
||||
result = "获取到的值是【" + ie.isDisplayed() + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info("当前对象判断是否可见布尔值为【" + ie.isDisplayed() + "】");
|
||||
LogUtil.APP.info("当前对象判断是否可见布尔值为【" + ie.isDisplayed() + "】");
|
||||
break;
|
||||
case "exjsob":
|
||||
JavascriptExecutor jse = (JavascriptExecutor) appium;
|
||||
jse.executeScript(operationValue, ie);
|
||||
result = "执行JS...【" + operationValue + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info("执行JS...【" + operationValue + "】");
|
||||
LogUtil.APP.info("执行JS...【" + operationValue + "】");
|
||||
break;
|
||||
case "longpresselement":
|
||||
LongPressOptions lpoptions = new LongPressOptions();
|
||||
|
@ -137,7 +138,7 @@ public class IosEncapsulateOperation {
|
|||
action.longPress(lpoptions).release().perform();
|
||||
result = "longpresselement在屏幕指定元素上按住" + operationValue + "秒...【对象定位属性:" + property + "; 定位属性值:"
|
||||
+ propertyValue + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -151,15 +152,15 @@ public class IosEncapsulateOperation {
|
|||
switch (operation) {
|
||||
case "alertaccept":
|
||||
alert.accept();
|
||||
luckyclient.publicclass.LogUtil.APP.info("弹出框对象点击同意...");
|
||||
LogUtil.APP.info("弹出框对象点击同意...");
|
||||
break;
|
||||
case "alertdismiss":
|
||||
alert.dismiss();
|
||||
luckyclient.publicclass.LogUtil.APP.info("弹出框对象点击取消...");
|
||||
LogUtil.APP.info("弹出框对象点击取消...");
|
||||
break;
|
||||
case "alertgettext":
|
||||
result = "获取到的值是【" + alert.getText() + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info("弹出框对象通过getText获取对象text属性...【Text属性值:" + alert.getText() + "】");
|
||||
LogUtil.APP.info("弹出框对象通过getText获取对象text属性...【Text属性值:" + alert.getText() + "】");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -187,19 +188,19 @@ public class IosEncapsulateOperation {
|
|||
}
|
||||
handlenum++;
|
||||
}
|
||||
luckyclient.publicclass.LogUtil.APP.info("getContext获取窗口句柄..." + result);
|
||||
LogUtil.APP.info("getContext获取窗口句柄..." + result);
|
||||
break;
|
||||
case "exjs":
|
||||
JavascriptExecutor jse = (JavascriptExecutor) appium;
|
||||
jse.executeScript(operationValue);
|
||||
result = "执行JS...【" + operationValue + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info("执行JS...【" + operationValue + "】");
|
||||
LogUtil.APP.info("执行JS...【" + operationValue + "】");
|
||||
break;
|
||||
// 隐藏手机键盘
|
||||
case "hideKeyboard":
|
||||
appium.hideKeyboard();
|
||||
result = "隐藏手机键盘...【hideKeyboard】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break;
|
||||
case "gotocontext":
|
||||
Set<String> ctNames = appium.getContextHandles();
|
||||
|
@ -213,19 +214,19 @@ public class IosEncapsulateOperation {
|
|||
}
|
||||
if (flag == 1) {
|
||||
result = "切换context至【" + operationValue + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
} else {
|
||||
result = "切换context失败,未找到contextName值为【" + operationValue + "】的对象";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
break;
|
||||
case "getcontext":
|
||||
result = "获取到的值是【" + appium.getContext() + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info("获取页面Context...【" + appium.getContext() + "】");
|
||||
LogUtil.APP.info("获取页面Context...【" + appium.getContext() + "】");
|
||||
break;
|
||||
case "gettitle":
|
||||
result = "获取到的值是【" + appium.getTitle() + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info("获取页面gettitle...【" + appium.getTitle() + "】");
|
||||
LogUtil.APP.info("获取页面gettitle...【" + appium.getTitle() + "】");
|
||||
break;
|
||||
case "swipeup":
|
||||
String[] tempup = operationValue.split("\\|", -1);
|
||||
|
@ -235,14 +236,14 @@ public class IosEncapsulateOperation {
|
|||
int num = Integer.valueOf(tempup[1]);
|
||||
IosBaseAppium.swipePageUp(appium, second, num);
|
||||
result = "swipeup页面向上滑动参数...秒|次数【" + second + "|" + num + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
} else {
|
||||
result = "swipeup页面向上滑动参数判断次数出现异常【" + tempup[1] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
} else {
|
||||
result = "swipeup页面向上滑动参数判断时间出现异常【" + tempup[0] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
break;
|
||||
case "swipedown":
|
||||
|
@ -253,14 +254,14 @@ public class IosEncapsulateOperation {
|
|||
int num = Integer.valueOf(tempdown[1]);
|
||||
IosBaseAppium.swipePageDown(appium, second, num);
|
||||
result = "swipedown页面向下滑动参数...秒|次数【" + second + "|" + num + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
} else {
|
||||
result = "swipedown页面向下滑动参数判断次数出现异常【" + tempdown[1] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
} else {
|
||||
result = "swipedown页面向下滑动参数判断时间出现异常【" + tempdown[0] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
break;
|
||||
case "swipleft":
|
||||
|
@ -271,14 +272,14 @@ public class IosEncapsulateOperation {
|
|||
int num = Integer.valueOf(templeft[1]);
|
||||
IosBaseAppium.swipePageLeft(appium, second, num);
|
||||
result = "swipleft页面向左滑动参数...秒|次数【" + second + "|" + num + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
} else {
|
||||
result = "swipleft页面向左滑动参数判断次数出现异常【" + templeft[1] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
} else {
|
||||
result = "swipleft页面向左滑动参数判断时间出现异常【" + templeft[0] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
break;
|
||||
case "swipright":
|
||||
|
@ -289,14 +290,14 @@ public class IosEncapsulateOperation {
|
|||
int num = Integer.valueOf(tempright[1]);
|
||||
IosBaseAppium.swipePageRight(appium, second, num);
|
||||
result = "swipright页面向右滑动参数...秒|次数【" + second + "|" + num + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
} else {
|
||||
result = "swipright页面向右滑动参数判断次数出现异常【" + tempright[1] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
} else {
|
||||
result = "swipright页面向右滑动参数判断时间出现异常【" + tempright[0] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
break;
|
||||
case "longpressxy":
|
||||
|
@ -314,19 +315,19 @@ public class IosEncapsulateOperation {
|
|||
action.longPress(lpoptions).release().perform();
|
||||
result = "longpressxy在屏幕指定XY坐标上按住" + longpressxy[2] + "秒...X|Y【" + longpressx + "|" + longpressy
|
||||
+ "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
} else {
|
||||
action.longPress(PointOption.point(longpressx, longpressy)).release().perform();
|
||||
result = "longpressxy在屏幕指定XY坐标上长按...X|Y【" + longpressx + "|" + longpressy + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
} else {
|
||||
result = "longpressxy参数指定的Y坐标处理出现异常【" + longpressxy[1] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
} else {
|
||||
result = "longpressxy参数指定的X坐标处理出现异常【" + longpressxy[0] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
break;
|
||||
case "pressxy":
|
||||
|
@ -337,14 +338,14 @@ public class IosEncapsulateOperation {
|
|||
int pressy = Integer.valueOf(pressxy[1]);
|
||||
action.press(PointOption.point(pressx, pressy)).release().perform();
|
||||
result = "pressxy在屏幕指定XY坐标上点击...X|Y【" + pressx + "|" + pressy + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
} else {
|
||||
result = "pressxy参数指定的Y坐标处理出现异常【" + pressxy[1] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
} else {
|
||||
result = "pressxy参数指定的X坐标处理出现异常【" + pressxy[0] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
break;
|
||||
case "tapxy":
|
||||
|
@ -355,14 +356,14 @@ public class IosEncapsulateOperation {
|
|||
int tapy = Integer.valueOf(tapxy[1]);
|
||||
action.tap(PointOption.point(tapx, tapy)).release().perform();
|
||||
result = "tapxy在屏幕指定XY坐标上轻击...X|Y【" + tapx + "|" + tapy + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
} else {
|
||||
result = "tapxy参数指定的Y坐标处理出现异常【" + tapxy[1] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
} else {
|
||||
result = "tapxy参数指定的X坐标处理出现异常【" + tapxy[0] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
break;
|
||||
case "jspressxy":
|
||||
|
@ -374,19 +375,19 @@ public class IosEncapsulateOperation {
|
|||
if (null != jspressxy[2] && ChangString.isNumeric(jspressxy[2])) {
|
||||
IosBaseAppium.clickScreenForJs(appium, jspressx, jspressy, Integer.valueOf(jspressxy[2]));
|
||||
result = "jspressxy在屏幕指定XY坐标上按" + jspressxy[2] + "秒...X|Y【" + jspressx + "|" + jspressy + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
} else {
|
||||
IosBaseAppium.clickScreenForJs(appium, jspressx, jspressy, 2);
|
||||
result = "jspressxy在屏幕指定XY坐标上按2秒(持续时间判断异常,使用默认2秒时间)...X|Y【" + jspressx + "|" + jspressy + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
} else {
|
||||
result = "jspressxy参数指定的Y坐标处理出现异常【" + jspressxy[1] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
} else {
|
||||
result = "jspressxy参数指定的X坐标处理出现异常【" + jspressxy[0] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
break;
|
||||
case "moveto":
|
||||
|
@ -405,34 +406,34 @@ public class IosEncapsulateOperation {
|
|||
action.press(PointOption.point(startx, starty))
|
||||
.waitAction(WaitOptions.waitOptions(Duration.ofNanos(1500)))
|
||||
.moveTo(PointOption.point(endx, endy));
|
||||
luckyclient.publicclass.LogUtil.APP.info("从开始坐标【" + startxy[0] + "," + startxy[1]
|
||||
LogUtil.APP.info("从开始坐标【" + startxy[0] + "," + startxy[1]
|
||||
+ "】拖动至坐标【" + endxy[0] + "," + endxy[1] + "】");
|
||||
} else {
|
||||
if (movexyi == 1) {
|
||||
action.press(PointOption.point(startx, starty))
|
||||
.waitAction(WaitOptions.waitOptions(Duration.ofNanos(1500)))
|
||||
.moveTo(PointOption.point(endx - startx, endy - starty));
|
||||
luckyclient.publicclass.LogUtil.APP.info("从开始坐标【" + startxy[0] + "," + startxy[1]
|
||||
LogUtil.APP.info("从开始坐标【" + startxy[0] + "," + startxy[1]
|
||||
+ "】拖动至坐标【" + endxy[0] + "," + endxy[1] + "】");
|
||||
} else {
|
||||
action.waitAction(WaitOptions.waitOptions(Duration.ofNanos(1500)))
|
||||
.moveTo(PointOption.point(endx - startx, endy - starty));
|
||||
luckyclient.publicclass.LogUtil.APP
|
||||
LogUtil.APP
|
||||
.info("第" + movexyi + "次拖动至坐标【" + endxy[0] + "," + endxy[1] + "】");
|
||||
}
|
||||
startx = endx;
|
||||
starty = endy;
|
||||
}
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("判断结束坐标位置出现异常,结束坐标参数【" + movexy[movexyi] + "】");
|
||||
LogUtil.APP.warn("判断结束坐标位置出现异常,结束坐标参数【" + movexy[movexyi] + "】");
|
||||
}
|
||||
}
|
||||
action.release().perform();
|
||||
result = "moveto全部拖动释放并完成发送...开始位置【" + startxy[0] + "," + startxy[1] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
} else {
|
||||
result = "moveto参数指定的起始坐标处理出现异常【" + movexy[0] + "】,请检查!";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
}
|
||||
break;
|
||||
case "timeout":
|
||||
|
@ -442,10 +443,10 @@ public class IosEncapsulateOperation {
|
|||
// 设置元素出现最大时长30秒
|
||||
appium.manage().timeouts().implicitlyWait(Integer.valueOf(operationValue), TimeUnit.SECONDS);
|
||||
result = "设置全局页面加载&元素出现最大等待时间【" + operationValue + "】秒...";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
} else {
|
||||
result = "【等待时间转换出错,请检查参数】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result + "原因是因为判断你的等待时间不是数字...");
|
||||
LogUtil.APP.info(result + "原因是因为判断你的等待时间不是数字...");
|
||||
}
|
||||
break;
|
||||
case "screenshot":
|
||||
|
@ -453,7 +454,7 @@ public class IosEncapsulateOperation {
|
|||
String imagname = "FunctionScreenShot_" + timeformat.format(new Date());
|
||||
IosBaseAppium.screenShot(appium, imagname);
|
||||
result = "截图名称【" + imagname + "】...";
|
||||
luckyclient.publicclass.LogUtil.APP.info("使用方法主动截取当前屏幕..." + result);
|
||||
LogUtil.APP.info("使用方法主动截取当前屏幕..." + result);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -11,25 +11,25 @@ import luckyclient.caserun.exappium.AppiumService;
|
|||
import luckyclient.caserun.exinterface.TestControl;
|
||||
import luckyclient.dblog.DbLink;
|
||||
import luckyclient.dblog.LogOperation;
|
||||
import luckyclient.planapi.api.GetServerAPI;
|
||||
import luckyclient.planapi.entity.ProjectCase;
|
||||
import luckyclient.planapi.entity.ProjectCasesteps;
|
||||
import luckyclient.planapi.entity.PublicCaseParams;
|
||||
import luckyclient.publicclass.AppiumConfig;
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
import luckyclient.serverapi.api.GetServerAPI;
|
||||
import luckyclient.serverapi.entity.ProjectCase;
|
||||
import luckyclient.serverapi.entity.ProjectCaseParams;
|
||||
import luckyclient.serverapi.entity.ProjectCaseSteps;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||
* =================================================================
|
||||
*
|
||||
* @author: seagull
|
||||
*
|
||||
* =================================================================
|
||||
* @author: seagull
|
||||
* @date 2018年2月2日
|
||||
*
|
||||
*/
|
||||
public class IosOneCaseExecute {
|
||||
|
||||
public static void oneCaseExecuteForTast(String projectname, String testCaseExternalId, int version, String taskid)
|
||||
public static void oneCaseExecuteForTast(String projectname, Integer caseId, int version, String taskid)
|
||||
throws IOException, InterruptedException {
|
||||
// 记录日志到数据库
|
||||
DbLink.exetype = 0;
|
||||
|
@ -37,7 +37,7 @@ public class IosOneCaseExecute {
|
|||
IOSDriver<IOSElement> iosd = null;
|
||||
AppiumService as=null;
|
||||
try {
|
||||
Properties properties = luckyclient.publicclass.AppiumConfig.getConfiguration();
|
||||
Properties properties = AppiumConfig.getConfiguration();
|
||||
//根据配置自动启动Appiume服务
|
||||
if(Boolean.valueOf(properties.getProperty("autoRunAppiumService"))){
|
||||
as =new AppiumService();
|
||||
|
@ -47,24 +47,25 @@ public class IosOneCaseExecute {
|
|||
|
||||
iosd = AppiumInitialization.setIosAppium(properties);
|
||||
} catch (IOException e1) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("初始化IOSDriver出错!", e1);
|
||||
LogUtil.APP.error("初始化IOSDriver出错!", e1);
|
||||
e1.printStackTrace();
|
||||
}
|
||||
LogOperation caselog = new LogOperation();
|
||||
ProjectCase testcase = GetServerAPI.cGetCaseByCaseId(caseId);
|
||||
// 删除旧的日志
|
||||
LogOperation.deleteCaseLogDetail(testCaseExternalId, taskid);
|
||||
ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId);
|
||||
List<PublicCaseParams> pcplist = GetServerAPI.cgetParamsByProjectid(String.valueOf(testcase.getProjectid()));
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始执行用例:【" + testCaseExternalId + "】......");
|
||||
LogOperation.deleteTaskCaseLog(testcase.getCaseId(), taskid);
|
||||
|
||||
List<ProjectCaseParams> pcplist = GetServerAPI.cgetParamsByProjectid(String.valueOf(testcase.getProjectId()));
|
||||
LogUtil.APP.info("开始执行用例:【" + testcase.getCaseSign() + "】......");
|
||||
try {
|
||||
List<ProjectCasesteps> steps = GetServerAPI.getStepsbycaseid(testcase.getId());
|
||||
List<ProjectCaseSteps> steps = GetServerAPI.getStepsbycaseid(testcase.getCaseId());
|
||||
IosCaseExecution.caseExcution(testcase, steps, taskid, iosd, caselog, pcplist);
|
||||
luckyclient.publicclass.LogUtil.APP.info("当前用例:【" + testcase.getSign() + "】执行完成......进入下一条");
|
||||
LogUtil.APP.info("当前用例:【" + testcase.getCaseSign() + "】执行完成......进入下一条");
|
||||
} catch (InterruptedException e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||
LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
LogOperation.updateTastdetail(taskid, 0);
|
||||
LogOperation.updateTaskExecuteData(taskid, 0);
|
||||
iosd.closeApp();
|
||||
//关闭Appium服务的线程
|
||||
if(as!=null){
|
||||
|
|
|
@ -6,17 +6,16 @@ import java.util.Map;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import br.eti.kinoshita.testlinkjavaapi.util.TestLinkAPIException;
|
||||
import luckyclient.caserun.exinterface.analyticsteps.InterfaceAnalyticCase;
|
||||
import luckyclient.caserun.publicdispose.ActionManageForSteps;
|
||||
import luckyclient.caserun.publicdispose.ChangString;
|
||||
import luckyclient.dblog.LogOperation;
|
||||
import luckyclient.planapi.api.GetServerAPI;
|
||||
import luckyclient.planapi.entity.ProjectCase;
|
||||
import luckyclient.planapi.entity.ProjectCasesteps;
|
||||
import luckyclient.planapi.entity.PublicCaseParams;
|
||||
import luckyclient.publicclass.InvokeMethod;
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
import luckyclient.publicclass.remoterinterface.HttpRequest;
|
||||
import luckyclient.serverapi.api.GetServerAPI;
|
||||
import luckyclient.serverapi.entity.ProjectCase;
|
||||
import luckyclient.serverapi.entity.ProjectCaseParams;
|
||||
import luckyclient.serverapi.entity.ProjectCaseSteps;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
@ -49,21 +48,21 @@ public class ApiTestCaseDebug {
|
|||
Object[] getParameterValues = null;
|
||||
String testnote = "初始化测试结果";
|
||||
int k = 0;
|
||||
ProjectCase testcaseob = GetServerAPI.cgetCaseBysign(testCaseExternalId);
|
||||
List<PublicCaseParams> pcplist = GetServerAPI.cgetParamsByProjectid(String.valueOf(testcaseob.getProjectid()));
|
||||
ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId);
|
||||
List<ProjectCaseParams> pcplist = GetServerAPI.cgetParamsByProjectid(String.valueOf(testcase.getProjectId()));
|
||||
// 把公共参数加入到MAP中
|
||||
for (PublicCaseParams pcp : pcplist) {
|
||||
variable.put(pcp.getParamsname(), pcp.getParamsvalue());
|
||||
for (ProjectCaseParams pcp : pcplist) {
|
||||
variable.put(pcp.getParamsName(), pcp.getParamsValue());
|
||||
}
|
||||
List<ProjectCasesteps> steps = GetServerAPI.getStepsbycaseid(testcaseob.getId());
|
||||
List<ProjectCaseSteps> steps = GetServerAPI.getStepsbycaseid(testcase.getCaseId());
|
||||
if (steps.size() == 0) {
|
||||
setcaseresult = 2;
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例中未找到步骤,请检查!");
|
||||
LogUtil.APP.warn("用例中未找到步骤,请检查!");
|
||||
testnote = "用例中未找到步骤,请检查!";
|
||||
}
|
||||
// 进入循环,解析用例所有步骤
|
||||
for (int i = 0; i < steps.size(); i++) {
|
||||
Map<String, String> casescript = InterfaceAnalyticCase.analyticCaseStep(testcaseob, steps.get(i), "888888",
|
||||
Map<String, String> casescript = InterfaceAnalyticCase.analyticCaseStep(testcase, steps.get(i), "888888",
|
||||
null);
|
||||
try {
|
||||
packagename = casescript.get("PackageName").toString();
|
||||
|
@ -72,7 +71,7 @@ public class ApiTestCaseDebug {
|
|||
functionname = ChangString.changparams(functionname, variable, "方法名");
|
||||
} catch (Exception e) {
|
||||
k = 0;
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcaseob.getSign() + "解析包名或是方法名失败,请检查!");
|
||||
LogUtil.APP.error("用例:" + testcase.getCaseSign() + "解析包名或是方法名失败,请检查!");
|
||||
e.printStackTrace();
|
||||
break; // 某一步骤失败后,此条用例置为失败退出
|
||||
}
|
||||
|
@ -95,7 +94,7 @@ public class ApiTestCaseDebug {
|
|||
}
|
||||
String parameterValues = casescript.get("FunctionParams" + (j + 1));
|
||||
parameterValues = ChangString.changparams(parameterValues, variable, "用例参数");
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcaseob.getSign() + "解析包名:" + packagename
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + "解析包名:" + packagename
|
||||
+ " 方法名:" + functionname + " 第" + (j + 1) + "个参数:" + parameterValues);
|
||||
getParameterValues[j] = parameterValues;
|
||||
}
|
||||
|
@ -104,37 +103,37 @@ public class ApiTestCaseDebug {
|
|||
}
|
||||
// 调用动态方法,执行测试用例
|
||||
try {
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始调用方法:" + functionname + " .....");
|
||||
LogUtil.APP.info("开始调用方法:" + functionname + " .....");
|
||||
testnote = InvokeMethod.callCase(packagename, functionname, getParameterValues,
|
||||
steps.get(i).getSteptype(), steps.get(i).getExtend());
|
||||
steps.get(i).getStepType(), steps.get(i).getExtend());
|
||||
testnote = ActionManageForSteps.actionManage(casescript.get("Action"), testnote);
|
||||
if (null != expectedresults && !expectedresults.isEmpty()) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("expectedResults=【" + expectedresults + "】");
|
||||
LogUtil.APP.info("expectedResults=【" + expectedresults + "】");
|
||||
// 赋值传参
|
||||
if (expectedresults.length() > ASSIGNMENT_SIGN.length()
|
||||
&& expectedresults.startsWith(ASSIGNMENT_SIGN)) {
|
||||
variable.put(expectedresults.substring(ASSIGNMENT_SIGN.length()), testnote);
|
||||
luckyclient.publicclass.LogUtil.APP
|
||||
.info("用例:" + testcaseob.getSign() + " 第" + (i + 1) + "步,将测试结果【" + testnote + "】赋值给变量【"
|
||||
LogUtil.APP
|
||||
.info("用例:" + testcase.getCaseSign() + " 第" + (i + 1) + "步,将测试结果【" + testnote + "】赋值给变量【"
|
||||
+ expectedresults.substring(ASSIGNMENT_SIGN.length()) + "】");
|
||||
}
|
||||
// 模糊匹配
|
||||
else if (expectedresults.length() > FUZZY_MATCHING_SIGN.length()
|
||||
&& expectedresults.startsWith(FUZZY_MATCHING_SIGN)) {
|
||||
if (testnote.contains(expectedresults.substring(FUZZY_MATCHING_SIGN.length()))) {
|
||||
luckyclient.publicclass.LogUtil.APP.info(
|
||||
"用例:" + testcaseob.getSign() + " 第" + (i + 1) + "步,模糊匹配预期结果成功!执行结果:" + testnote);
|
||||
LogUtil.APP.info(
|
||||
"用例:" + testcase.getCaseSign() + " 第" + (i + 1) + "步,模糊匹配预期结果成功!执行结果:" + testnote);
|
||||
} else {
|
||||
setcaseresult = 1;
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcaseob.getSign() + " 第" + (i + 1)
|
||||
LogUtil.APP.warn("用例:" + testcase.getCaseSign() + " 第" + (i + 1)
|
||||
+ "步,模糊匹配预期结果失败!预期结果:" + expectedresults.substring(FUZZY_MATCHING_SIGN.length())
|
||||
+ ",测试结果:" + testnote);
|
||||
testnote = "用例第" + (i + 1) + "步,模糊匹配预期结果失败!";
|
||||
if (testcaseob.getFailcontinue() == 0) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
||||
if (testcase.getFailcontinue() == 0) {
|
||||
LogUtil.APP.warn("用例【"+testcase.getCaseSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
||||
break;
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
||||
LogUtil.APP.warn("用例【"+testcase.getCaseSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -144,66 +143,66 @@ public class ApiTestCaseDebug {
|
|||
Pattern pattern = Pattern.compile(expectedresults.substring(REGULAR_MATCHING_SIGN.length()));
|
||||
Matcher matcher = pattern.matcher(testnote);
|
||||
if (matcher.find()) {
|
||||
luckyclient.publicclass.LogUtil.APP.info(
|
||||
"用例:" + testcaseob.getSign() + " 第" + (i + 1) + "步,正则匹配预期结果成功!执行结果:" + testnote);
|
||||
LogUtil.APP.info(
|
||||
"用例:" + testcase.getCaseSign() + " 第" + (i + 1) + "步,正则匹配预期结果成功!执行结果:" + testnote);
|
||||
} else {
|
||||
setcaseresult = 1;
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcaseob.getSign() + " 第" + (i + 1)
|
||||
LogUtil.APP.warn("用例:" + testcase.getCaseSign() + " 第" + (i + 1)
|
||||
+ "步,正则匹配预期结果失败!预期结果:" + expectedresults.substring(REGULAR_MATCHING_SIGN.length())
|
||||
+ ",测试结果:" + testnote);
|
||||
testnote = "用例第" + (i + 1) + "步,正则匹配预期结果失败!";
|
||||
if (testcaseob.getFailcontinue() == 0) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
||||
if (testcase.getFailcontinue() == 0) {
|
||||
LogUtil.APP.warn("用例【"+testcase.getCaseSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
||||
break;
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
||||
LogUtil.APP.warn("用例【"+testcase.getCaseSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
||||
}
|
||||
}
|
||||
}
|
||||
// 完全相等
|
||||
else {
|
||||
if (expectedresults.equals(testnote)) {
|
||||
luckyclient.publicclass.LogUtil.APP.info(
|
||||
"用例:" + testcaseob.getSign() + " 第" + (i + 1) + "步,精确匹配预期结果成功!执行结果:" + testnote);
|
||||
LogUtil.APP.info(
|
||||
"用例:" + testcase.getCaseSign() + " 第" + (i + 1) + "步,精确匹配预期结果成功!执行结果:" + testnote);
|
||||
} else {
|
||||
setcaseresult = 1;
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcaseob.getSign() + " 第" + (i + 1)
|
||||
LogUtil.APP.warn("用例:" + testcase.getCaseSign() + " 第" + (i + 1)
|
||||
+ "步,精确匹配预期结果失败!预期结果:" + expectedresults + ",测试结果:" + testnote);
|
||||
testnote = "用例第" + (i + 1) + "步,精确匹配预期结果失败!";
|
||||
if (testcaseob.getFailcontinue() == 0) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
||||
if (testcase.getFailcontinue() == 0) {
|
||||
LogUtil.APP.warn("用例【"+testcase.getCaseSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
||||
break;
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
||||
LogUtil.APP.warn("用例【"+testcase.getCaseSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
setcaseresult = 1;
|
||||
luckyclient.publicclass.LogUtil.APP.error("调用方法过程出错,方法名:" + functionname + " 请重新检查脚本方法名称以及参数!");
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error("调用方法过程出错,方法名:" + functionname + " 请重新检查脚本方法名称以及参数!");
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
testnote = "CallCase调用出错!";
|
||||
e.printStackTrace();
|
||||
if (testcaseob.getFailcontinue() == 0) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
||||
if (testcase.getFailcontinue() == 0) {
|
||||
LogUtil.APP.warn("用例【"+testcase.getCaseSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
||||
break;
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
||||
LogUtil.APP.warn("用例【"+testcase.getCaseSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
||||
}
|
||||
}
|
||||
}
|
||||
variable.clear(); // 清空传参MAP
|
||||
// 如果调用方法过程中未出错,进入设置测试结果流程
|
||||
if (testnote.indexOf("CallCase调用出错!") <= -1 && testnote.indexOf("解析出错啦!") <= -1) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例 " + testCaseExternalId + "解析成功,并成功调用用例中方法,请继续查看执行结果!");
|
||||
LogUtil.APP.info("用例 " + testCaseExternalId + "解析成功,并成功调用用例中方法,请继续查看执行结果!");
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例 " + testCaseExternalId + "解析或是调用步骤中的方法出错!");
|
||||
LogUtil.APP.warn("用例 " + testCaseExternalId + "解析或是调用步骤中的方法出错!");
|
||||
}
|
||||
if (0 == setcaseresult) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例 " + testCaseExternalId + "步骤全部执行成功!");
|
||||
LogUtil.APP.info("用例 " + testCaseExternalId + "步骤全部执行成功!");
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例 " + testCaseExternalId + "在执行过程中失败,请检查日志!");
|
||||
LogUtil.APP.warn("用例 " + testCaseExternalId + "在执行过程中失败,请检查日志!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -217,7 +216,7 @@ public class ApiTestCaseDebug {
|
|||
System.out.println("当前调试用例总共:"+addtestcase.size());
|
||||
for(String testCaseExternalId:addtestcase) {
|
||||
try {
|
||||
luckyclient.publicclass.LogUtil.APP
|
||||
LogUtil.APP
|
||||
.info("开始调用方法,项目名:" + projectname + ",用例编号:" + testCaseExternalId);
|
||||
oneCaseDebug(projectname, testCaseExternalId);
|
||||
} catch (Exception e) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新系统中用例指定步骤的预期结果
|
||||
*/
|
||||
|
@ -256,9 +239,9 @@ public class ApiTestCaseDebug {
|
|||
params += "&stepnum=" + steps;
|
||||
params += "&expectedresults=" + expectedResults;
|
||||
results = HttpRequest.sendPost("/projectCasesteps/cUpdateStepExpectedResults.do", params);
|
||||
} catch (TestLinkAPIException te) {
|
||||
te.printStackTrace(System.err);
|
||||
results = te.getMessage().toString();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace(System.err);
|
||||
results = e.getMessage().toString();
|
||||
return results;
|
||||
}
|
||||
return results;
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package luckyclient.caserun.exinterface;
|
||||
|
||||
import luckyclient.caserun.exinterface.TestControl;
|
||||
import luckyclient.dblog.LogOperation;
|
||||
import luckyclient.planapi.api.GetServerAPI;
|
||||
import luckyclient.planapi.entity.TestTaskexcute;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import luckyclient.dblog.LogOperation;
|
||||
import luckyclient.serverapi.api.GetServerAPI;
|
||||
import luckyclient.serverapi.entity.ProjectCase;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
|
@ -29,8 +29,7 @@ public class BatchTestCaseExecution {
|
|||
*/
|
||||
|
||||
public static void batchCaseExecuteForTast(String projectname,String taskid,String batchcase) throws Exception{
|
||||
TestTaskexcute task=GetServerAPI.cgetTaskbyid(Integer.valueOf(taskid));
|
||||
int threadcount = task.getTestJob().getThreadCount();
|
||||
int threadcount = GetServerAPI.cGetTaskSchedulingByTaskId(Integer.valueOf(taskid)).getExThreadCount();
|
||||
ThreadPoolExecutor threadExecute = new ThreadPoolExecutor(threadcount, 30, 3, TimeUnit.SECONDS,
|
||||
new ArrayBlockingQueue<Runnable>(1000),
|
||||
new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
|
@ -38,21 +37,17 @@ public class BatchTestCaseExecution {
|
|||
if(batchcase.indexOf("ALLFAIL")>-1){
|
||||
//初始化写用例结果以及日志模块
|
||||
LogOperation caselog = new LogOperation();
|
||||
String casemore = caselog.unSucCaseUpdate(taskid);
|
||||
String[] temp=casemore.split("\\#",-1);
|
||||
for(int i=0;i<temp.length;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));
|
||||
List<Integer> caseIdList = caselog.getCaseListForUnSucByTaskId(taskid);
|
||||
for(int i=0;i<caseIdList.size();i++){
|
||||
ProjectCase testcase = GetServerAPI.cGetCaseByCaseId(caseIdList.get(i));
|
||||
TestControl.THREAD_COUNT++; //多线程计数++,用于检测线程是否全部执行完
|
||||
threadExecute.execute(new ThreadForBatchCase(projectname,testCaseExternalId,version,taskid));
|
||||
threadExecute.execute(new ThreadForBatchCase(projectname,testcase.getCaseId(),taskid));
|
||||
}
|
||||
}else{ //批量执行用例
|
||||
String[] temp=batchcase.split("\\#",-1);
|
||||
for(int i=0;i<temp.length-1;i++){
|
||||
String testCaseExternalId = temp[i].substring(0, temp[i].indexOf("%"));
|
||||
int version = Integer.parseInt(temp[i].substring(temp[i].indexOf("%")+1,temp[i].length()));
|
||||
String[] temp=batchcase.split("\\#");
|
||||
for(int i=0;i<temp.length;i++){
|
||||
TestControl.THREAD_COUNT++; //多线程计数++,用于检测线程是否全部执行完
|
||||
threadExecute.execute(new ThreadForBatchCase(projectname,testCaseExternalId,version,taskid));
|
||||
threadExecute.execute(new ThreadForBatchCase(projectname,Integer.valueOf(temp[i]),taskid));
|
||||
}
|
||||
}
|
||||
//多线程计数,用于检测线程是否全部执行完
|
||||
|
|
|
@ -23,12 +23,12 @@ import luckyclient.caserun.publicdispose.ChangString;
|
|||
import luckyclient.caserun.publicdispose.ParamsManageForSteps;
|
||||
import luckyclient.dblog.DbLink;
|
||||
import luckyclient.dblog.LogOperation;
|
||||
import luckyclient.planapi.api.GetServerAPI;
|
||||
import luckyclient.planapi.entity.ProjectCase;
|
||||
import luckyclient.planapi.entity.ProjectCasesteps;
|
||||
import luckyclient.planapi.entity.PublicCaseParams;
|
||||
import luckyclient.publicclass.InvokeMethod;
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
import luckyclient.serverapi.api.GetServerAPI;
|
||||
import luckyclient.serverapi.entity.ProjectCase;
|
||||
import luckyclient.serverapi.entity.ProjectCaseParams;
|
||||
import luckyclient.serverapi.entity.ProjectCaseSteps;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
@ -53,7 +53,7 @@ public class TestCaseExecution {
|
|||
* @param version 用例版本号
|
||||
* 用于单条用例调试,并通过日志框架写日志到UTP上,用做UTP上单条用例运行
|
||||
*/
|
||||
public static void oneCaseExecuteForTast(String projectname, String testCaseExternalId, int version, String taskid) {
|
||||
public static void oneCaseExecuteForTask(String projectname, Integer caseId, String taskid) {
|
||||
TestControl.TASKID = taskid;
|
||||
DbLink.exetype = 0;
|
||||
// 初始化写用例结果以及日志模块
|
||||
|
@ -65,26 +65,27 @@ public class TestCaseExecution {
|
|||
Object[] getParameterValues = null;
|
||||
String testnote = "初始化测试结果";
|
||||
int k = 0;
|
||||
ProjectCase testcase = GetServerAPI.cGetCaseByCaseId(caseId);
|
||||
// 删除旧的日志
|
||||
LogOperation.deleteCaseLogDetail(testCaseExternalId, taskid);
|
||||
ProjectCase testcaseob = GetServerAPI.cgetCaseBysign(testCaseExternalId);
|
||||
List<PublicCaseParams> pcplist = GetServerAPI.cgetParamsByProjectid(String.valueOf(testcaseob.getProjectid()));
|
||||
LogOperation.deleteTaskCaseLog(testcase.getCaseId(), taskid);
|
||||
|
||||
List<ProjectCaseParams> pcplist = GetServerAPI.cgetParamsByProjectid(String.valueOf(testcase.getProjectId()));
|
||||
// 把公共参数加入到MAP中
|
||||
for (PublicCaseParams pcp : pcplist) {
|
||||
VARIABLE.put(pcp.getParamsname(), pcp.getParamsvalue());
|
||||
for (ProjectCaseParams pcp : pcplist) {
|
||||
VARIABLE.put(pcp.getParamsName(), pcp.getParamsValue());
|
||||
}
|
||||
// 加入全局变量
|
||||
VARIABLE.putAll(ParamsManageForSteps.GLOBAL_VARIABLE);
|
||||
List<ProjectCasesteps> steps = GetServerAPI.getStepsbycaseid(testcaseob.getId());
|
||||
List<ProjectCaseSteps> steps = GetServerAPI.getStepsbycaseid(testcase.getCaseId());
|
||||
if (steps.size() == 0) {
|
||||
setcaseresult = 2;
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例中未找到步骤,请检查!");
|
||||
caselog.caseLogDetail(taskid, testCaseExternalId, "用例中未找到步骤,请检查!", "error", "1", "");
|
||||
LogUtil.APP.warn("用例中未找到步骤,请检查!");
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "用例中未找到步骤,请检查!", "error", "1", "");
|
||||
testnote = "用例中未找到步骤,请检查!";
|
||||
}
|
||||
// 进入循环,解析用例所有步骤
|
||||
for (int i = 0; i < steps.size(); i++) {
|
||||
Map<String, String> casescript = InterfaceAnalyticCase.analyticCaseStep(testcaseob, steps.get(i), taskid, caselog);
|
||||
Map<String, String> casescript = InterfaceAnalyticCase.analyticCaseStep(testcase, steps.get(i), taskid, caselog);
|
||||
try {
|
||||
packagename = casescript.get("PackageName");
|
||||
packagename = ChangString.changparams(packagename, VARIABLE, "包路径");
|
||||
|
@ -92,8 +93,8 @@ public class TestCaseExecution {
|
|||
functionname = ChangString.changparams(functionname, VARIABLE, "方法名");
|
||||
} catch (Exception e) {
|
||||
k = 0;
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcaseob.getSign() + "解析包名或是方法名失败,请检查!");
|
||||
caselog.caseLogDetail(taskid, testcaseob.getSign(), "解析包名或是方法名失败,请检查!", "error", String.valueOf(i + 1), "");
|
||||
LogUtil.APP.error("用例:" + testcase.getCaseSign() + "解析包名或是方法名失败,请检查!");
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "解析包名或是方法名失败,请检查!", "error", String.valueOf(i + 1), "");
|
||||
e.printStackTrace();
|
||||
break; // 某一步骤失败后,此条用例置为失败退出
|
||||
}
|
||||
|
@ -117,8 +118,8 @@ public class TestCaseExecution {
|
|||
|
||||
String parameterValues = casescript.get("FunctionParams" + (j + 1));
|
||||
parameterValues = ChangString.changparams(parameterValues, VARIABLE, "用例参数");
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcaseob.getSign() + "解析包名:" + packagename + " 方法名:" + functionname + " 第" + (j + 1) + "个参数:" + parameterValues);
|
||||
caselog.caseLogDetail(taskid, testcaseob.getSign(), "解析包名:" + packagename + " 方法名:" + functionname + " 第" + (j + 1) + "个参数:" + parameterValues, "info", String.valueOf(i + 1), "");
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + "解析包名:" + packagename + " 方法名:" + functionname + " 第" + (j + 1) + "个参数:" + parameterValues);
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "解析包名:" + packagename + " 方法名:" + functionname + " 第" + (j + 1) + "个参数:" + parameterValues, "info", String.valueOf(i + 1), "");
|
||||
getParameterValues[j] = parameterValues;
|
||||
}
|
||||
} else {
|
||||
|
@ -126,35 +127,34 @@ public class TestCaseExecution {
|
|||
}
|
||||
// 调用动态方法,执行测试用例
|
||||
try {
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始调用方法:" + functionname + " .....");
|
||||
caselog.caseLogDetail(taskid, testCaseExternalId, "开始调用方法:" + functionname + " .....", "info", String.valueOf(i + 1), "");
|
||||
testnote = InvokeMethod.callCase(packagename, functionname, getParameterValues, steps.get(i).getSteptype(), steps.get(i).getExtend());
|
||||
LogUtil.APP.info("开始调用方法:" + functionname + " .....");
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "开始调用方法:" + functionname + " .....", "info", String.valueOf(i + 1), "");
|
||||
testnote = InvokeMethod.callCase(packagename, functionname, getParameterValues, steps.get(i).getStepType(), steps.get(i).getExtend());
|
||||
testnote = ActionManageForSteps.actionManage(casescript.get("Action"), testnote);
|
||||
// 判断结果
|
||||
int stepresult = interfaceJudgeResult(testcaseob, steps.get(i), taskid, expectedresults, testnote, caselog);
|
||||
int stepresult = interfaceJudgeResult(testcase, steps.get(i), taskid, expectedresults, testnote, caselog);
|
||||
// 失败,并且不在继续,直接终止
|
||||
if (0 != stepresult) {
|
||||
setcaseresult = stepresult;
|
||||
if (testcaseob.getFailcontinue() == 0) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+steps.get(i).getStepnum()+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
||||
if (testcase.getFailcontinue() == 0) {
|
||||
LogUtil.APP.warn("用例【"+testcase.getCaseSign()+"】第【"+steps.get(i).getStepSerialNumber()+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
||||
break;
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+steps.get(i).getStepnum()+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
||||
LogUtil.APP.warn("用例【"+testcase.getCaseSign()+"】第【"+steps.get(i).getStepSerialNumber()+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.ERROR.error("调用方法过程出错,方法名:" + functionname + " 请重新检查脚本方法名称以及参数!");
|
||||
caselog.caseLogDetail(taskid, testCaseExternalId, "调用方法过程出错,方法名:" + functionname + " 请重新检查脚本方法名称以及参数!", "error", String.valueOf(i + 1), "");
|
||||
luckyclient.publicclass.LogUtil.ERROR.error(e, e);
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "调用方法过程出错,方法名:" + functionname + " 请重新检查脚本方法名称以及参数!", "error", String.valueOf(i + 1), "");
|
||||
LogUtil.APP.error("调用方法过程出错,方法名:" + functionname + " 请重新检查脚本方法名称以及参数!", e);
|
||||
testnote = "CallCase调用出错!";
|
||||
setcaseresult = 1;
|
||||
e.printStackTrace();
|
||||
if (testcaseob.getFailcontinue() == 0) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
||||
if (testcase.getFailcontinue() == 0) {
|
||||
LogUtil.APP.error("用例【"+testcase.getCaseSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
||||
break;
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
||||
LogUtil.APP.error("用例【"+testcase.getCaseSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -162,23 +162,23 @@ public class TestCaseExecution {
|
|||
VARIABLE.clear(); // 清空传参MAP
|
||||
// 如果调用方法过程中未出错,进入设置测试结果流程
|
||||
if (!testnote.contains("CallCase调用出错!") && !testnote.contains("解析出错啦!")) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例 " + testCaseExternalId + "解析成功,并成功调用用例中方法,请继续查看执行结果!");
|
||||
caselog.caseLogDetail(taskid, testCaseExternalId, "解析成功,并成功调用用例中方法,请继续查看执行结果!", "info", "SETCASERESULT...", "");
|
||||
caselog.updateCaseDetail(taskid, testCaseExternalId, setcaseresult);
|
||||
LogUtil.APP.info("用例 " + testcase.getCaseSign() + "解析成功,并成功调用用例中方法,请继续查看执行结果!");
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "解析成功,并成功调用用例中方法,请继续查看执行结果!", "info", "SETCASERESULT...", "");
|
||||
caselog.updateTaskCaseExecuteStatus(taskid, testcase.getCaseId(), setcaseresult);
|
||||
} else {
|
||||
setcaseresult = 1;
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例 " + testCaseExternalId + "解析或是调用步骤中的方法出错!");
|
||||
caselog.caseLogDetail(taskid, testCaseExternalId, "解析或是调用步骤中的方法出错!", "error", "SETCASERESULT...", "");
|
||||
caselog.updateCaseDetail(taskid, testCaseExternalId, 2);
|
||||
LogUtil.APP.warn("用例 " + testcase.getCaseSign() + "解析或是调用步骤中的方法出错!");
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "解析或是调用步骤中的方法出错!", "error", "SETCASERESULT...", "");
|
||||
caselog.updateTaskCaseExecuteStatus(taskid, testcase.getCaseId(), 2);
|
||||
}
|
||||
if (0 == setcaseresult) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例 " + testCaseExternalId + "步骤全部执行成功!");
|
||||
caselog.caseLogDetail(taskid, testCaseExternalId, "步骤全部执行成功!", "info", "EXECUTECASESUC...", "");
|
||||
LogUtil.APP.info("用例 " + testcase.getCaseSign() + "步骤全部执行成功!");
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "步骤全部执行成功!", "info", "EXECUTECASESUC...", "");
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例 " + testCaseExternalId + "在执行过程中失败,请检查日志!");
|
||||
caselog.caseLogDetail(taskid, testCaseExternalId, "在执行过程中失败,请检查日志!", "error", "EXECUTECASESUC...", "");
|
||||
LogUtil.APP.warn("用例 " + testcase.getCaseSign() + "在执行过程中失败,请检查日志!");
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "在执行过程中失败,请检查日志!", "error", "EXECUTECASESUC...", "");
|
||||
}
|
||||
LogOperation.updateTastdetail(taskid, 0);
|
||||
LogOperation.updateTaskExecuteData(taskid, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -197,22 +197,22 @@ public class TestCaseExecution {
|
|||
Object[] getParameterValues = null;
|
||||
String testnote = "初始化测试结果";
|
||||
int k = 0;
|
||||
ProjectCase testcaseob = GetServerAPI.cgetCaseBysign(testCaseExternalId);
|
||||
List<PublicCaseParams> pcplist = GetServerAPI.cgetParamsByProjectid(String.valueOf(testcaseob.getProjectid()));
|
||||
ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId);
|
||||
List<ProjectCaseParams> pcplist = GetServerAPI.cgetParamsByProjectid(String.valueOf(testcase.getProjectId()));
|
||||
// 把公共参数加入到MAP中
|
||||
for (PublicCaseParams pcp : pcplist) {
|
||||
variable.put(pcp.getParamsname(), pcp.getParamsvalue());
|
||||
for (ProjectCaseParams pcp : pcplist) {
|
||||
variable.put(pcp.getParamsName(), pcp.getParamsValue());
|
||||
}
|
||||
List<ProjectCasesteps> steps = GetServerAPI.getStepsbycaseid(testcaseob.getId());
|
||||
List<ProjectCaseSteps> steps = GetServerAPI.getStepsbycaseid(testcase.getCaseId());
|
||||
if (steps.size() == 0) {
|
||||
setresult = 2;
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例中未找到步骤,请检查!");
|
||||
caselog.caseLogDetail(taskid, testcaseob.getSign(), "用例中未找到步骤,请检查!", "error", "1", "");
|
||||
LogUtil.APP.warn("用例中未找到步骤,请检查!");
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "用例中未找到步骤,请检查!", "error", "1", "");
|
||||
testnote = "用例中未找到步骤,请检查!";
|
||||
}
|
||||
// 进入循环,解析用例所有步骤
|
||||
for (int i = 0; i < steps.size(); i++) {
|
||||
Map<String, String> casescript = InterfaceAnalyticCase.analyticCaseStep(testcaseob, steps.get(i), taskid, caselog);
|
||||
Map<String, String> casescript = InterfaceAnalyticCase.analyticCaseStep(testcase, steps.get(i), taskid, caselog);
|
||||
try {
|
||||
packagename = casescript.get("PackageName");
|
||||
packagename = ChangString.changparams(packagename, variable, "包路径");
|
||||
|
@ -220,8 +220,8 @@ public class TestCaseExecution {
|
|||
functionname = ChangString.changparams(functionname, variable, "方法名");
|
||||
} catch (Exception e) {
|
||||
k = 0;
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcaseob.getSign() + "解析包名或是方法名失败,请检查!");
|
||||
caselog.caseLogDetail(taskid, testcaseob.getSign(), "解析包名或是方法名失败,请检查!", "error", String.valueOf(i + 1), "");
|
||||
LogUtil.APP.error("用例:" + testcase.getCaseId() + "解析包名或是方法名失败,请检查!");
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "解析包名或是方法名失败,请检查!", "error", String.valueOf(i + 1), "");
|
||||
e.printStackTrace();
|
||||
break; // 某一步骤失败后,此条用例置为失败退出
|
||||
}
|
||||
|
@ -244,8 +244,8 @@ public class TestCaseExecution {
|
|||
}
|
||||
String parameterValues = casescript.get("FunctionParams" + (j + 1));
|
||||
parameterValues = ChangString.changparams(parameterValues, variable, "用例参数");
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcaseob.getSign() + "解析包名:" + packagename + " 方法名:" + functionname + " 第" + (j + 1) + "个参数:" + parameterValues);
|
||||
caselog.caseLogDetail(taskid, testcaseob.getSign(), "解析包名:" + packagename + " 方法名:" + functionname + " 第" + (j + 1) + "个参数:" + parameterValues, "info", String.valueOf(i + 1), "");
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + "解析包名:" + packagename + " 方法名:" + functionname + " 第" + (j + 1) + "个参数:" + parameterValues);
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "解析包名:" + packagename + " 方法名:" + functionname + " 第" + (j + 1) + "个参数:" + parameterValues, "info", String.valueOf(i + 1), "");
|
||||
getParameterValues[j] = parameterValues;
|
||||
}
|
||||
} else {
|
||||
|
@ -253,25 +253,25 @@ public class TestCaseExecution {
|
|||
}
|
||||
// 调用动态方法,执行测试用例
|
||||
try {
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始调用方法:" + functionname + " .....");
|
||||
LogUtil.APP.info("开始调用方法:" + functionname + " .....");
|
||||
|
||||
testnote = InvokeMethod.callCase(packagename, functionname, getParameterValues, steps.get(i).getSteptype(), steps.get(i).getExtend());
|
||||
testnote = InvokeMethod.callCase(packagename, functionname, getParameterValues, steps.get(i).getStepType(), steps.get(i).getExtend());
|
||||
testnote = ActionManageForSteps.actionManage(casescript.get("Action"), testnote);
|
||||
if (null != expectedresults && !expectedresults.isEmpty()) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("expectedResults=【" + expectedresults + "】");
|
||||
LogUtil.APP.info("expectedResults=【" + expectedresults + "】");
|
||||
// 赋值传参
|
||||
if (expectedresults.length() > ASSIGNMENT_SIGN.length() && expectedresults.startsWith(ASSIGNMENT_SIGN)) {
|
||||
variable.put(expectedresults.substring(ASSIGNMENT_SIGN.length()), testnote);
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcaseob.getSign() + " 第" + (i + 1) + "步,将测试结果【" + testnote + "】赋值给变量【" + expectedresults.substring(ASSIGNMENT_SIGN.length()) + "】");
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + " 第" + (i + 1) + "步,将测试结果【" + testnote + "】赋值给变量【" + expectedresults.substring(ASSIGNMENT_SIGN.length()) + "】");
|
||||
}
|
||||
// 模糊匹配
|
||||
else if (expectedresults.length() > FUZZY_MATCHING_SIGN.length() && expectedresults.startsWith(FUZZY_MATCHING_SIGN)) {
|
||||
if (testnote.contains(expectedresults.substring(FUZZY_MATCHING_SIGN.length()))) {
|
||||
setresult = 0;
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcaseob.getSign() + " 第" + (i + 1) + "步,模糊匹配预期结果成功!执行结果:" + testnote);
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + " 第" + (i + 1) + "步,模糊匹配预期结果成功!执行结果:" + testnote);
|
||||
} else {
|
||||
setresult = 1;
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcaseob.getSign() + " 第" + (i + 1) + "步,模糊匹配预期结果失败!预期结果:" + expectedresults.substring(FUZZY_MATCHING_SIGN.length()) + ",测试结果:" + testnote);
|
||||
LogUtil.APP.warn("用例:" + testcase.getCaseSign() + " 第" + (i + 1) + "步,模糊匹配预期结果失败!预期结果:" + expectedresults.substring(FUZZY_MATCHING_SIGN.length()) + ",测试结果:" + testnote);
|
||||
testnote = "用例第" + (i + 1) + "步,模糊匹配预期结果失败!";
|
||||
break; // 某一步骤失败后,此条用例置为失败退出
|
||||
}
|
||||
|
@ -282,10 +282,10 @@ public class TestCaseExecution {
|
|||
Matcher matcher = pattern.matcher(testnote);
|
||||
if (matcher.find()) {
|
||||
setresult = 0;
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcaseob.getSign() + " 第" + (i + 1) + "步,正则匹配预期结果成功!执行结果:" + testnote);
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + " 第" + (i + 1) + "步,正则匹配预期结果成功!执行结果:" + testnote);
|
||||
} else {
|
||||
setresult = 1;
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcaseob.getSign() + " 第" + (i + 1) + "步,正则匹配预期结果失败!预期结果:" + expectedresults.substring(REGULAR_MATCHING_SIGN.length()) + ",测试结果:" + testnote);
|
||||
LogUtil.APP.warn("用例:" + testcase.getCaseSign() + " 第" + (i + 1) + "步,正则匹配预期结果失败!预期结果:" + expectedresults.substring(REGULAR_MATCHING_SIGN.length()) + ",测试结果:" + testnote);
|
||||
testnote = "用例第" + (i + 1) + "步,正则匹配预期结果失败!";
|
||||
break; // 某一步骤失败后,此条用例置为失败退出
|
||||
}
|
||||
|
@ -294,18 +294,17 @@ public class TestCaseExecution {
|
|||
else {
|
||||
if (expectedresults.equals(testnote)) {
|
||||
setresult = 0;
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcaseob.getSign() + " 第" + (i + 1) + "步,精确匹配预期结果成功!执行结果:" + testnote);
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + " 第" + (i + 1) + "步,精确匹配预期结果成功!执行结果:" + testnote);
|
||||
} else {
|
||||
setresult = 1;
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcaseob.getSign() + " 第" + (i + 1) + "步,精确匹配预期结果失败!预期结果:" + expectedresults + ",测试结果:" + testnote);
|
||||
LogUtil.APP.warn("用例:" + testcase.getCaseSign() + " 第" + (i + 1) + "步,精确匹配预期结果失败!预期结果:" + expectedresults + ",测试结果:" + testnote);
|
||||
testnote = "用例第" + (i + 1) + "步,精确匹配预期结果失败!";
|
||||
break; // 某一步骤失败后,此条用例置为失败退出
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.ERROR.error("调用方法过程出错,方法名:" + functionname + " 请重新检查脚本方法名称以及参数!");
|
||||
LogUtil.ERROR.error(e, e);
|
||||
LogUtil.APP.error("调用方法过程出错,方法名:" + functionname + " 请重新检查脚本方法名称以及参数!",e);
|
||||
testnote = "CallCase调用出错!";
|
||||
setresult = 1;
|
||||
e.printStackTrace();
|
||||
|
@ -314,9 +313,9 @@ public class TestCaseExecution {
|
|||
}
|
||||
variable.clear(); // 清空传参MAP
|
||||
if (0 == setresult) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例 " + testcaseob.getSign() + "步骤全部执行成功!");
|
||||
LogUtil.APP.info("用例 " + testcase.getCaseSign() + "步骤全部执行成功!");
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例 " + testcaseob.getSign() + "在执行过程中失败,请检查日志!");
|
||||
LogUtil.APP.warn("用例 " + testcase.getCaseSign() + "在执行过程中失败,请检查日志!");
|
||||
}
|
||||
return testnote;
|
||||
}
|
||||
|
@ -331,38 +330,39 @@ public class TestCaseExecution {
|
|||
* @throws InterruptedException
|
||||
* 提供给Web用例中,runcase的时候使用
|
||||
*/
|
||||
protected static String oneCaseExecuteForUICase(String testCaseExternalId, String taskid, LogOperation caselog, Object driver) throws InterruptedException {
|
||||
@SuppressWarnings("unchecked")
|
||||
protected static String oneCaseExecuteForUICase(String testCaseExternalId, String taskid, LogOperation caselog, Object driver) throws InterruptedException {
|
||||
String expectedresults = null;
|
||||
Integer setresult = 1;
|
||||
String testnote = "初始化测试结果";
|
||||
ProjectCase testcaseob = GetServerAPI.cgetCaseBysign(testCaseExternalId);
|
||||
List<PublicCaseParams> pcplist = GetServerAPI.cgetParamsByProjectid(String.valueOf(testcaseob.getProjectid()));
|
||||
ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId);
|
||||
List<ProjectCaseParams> pcplist = GetServerAPI.cgetParamsByProjectid(String.valueOf(testcase.getProjectId()));
|
||||
// 把公共参数加入到MAP中
|
||||
for (PublicCaseParams pcp : pcplist) {
|
||||
VARIABLE.put(pcp.getParamsname(), pcp.getParamsvalue());
|
||||
for (ProjectCaseParams pcp : pcplist) {
|
||||
VARIABLE.put(pcp.getParamsName(), pcp.getParamsValue());
|
||||
}
|
||||
// 加入全局变量
|
||||
VARIABLE.putAll(ParamsManageForSteps.GLOBAL_VARIABLE);
|
||||
List<ProjectCasesteps> steps = GetServerAPI.getStepsbycaseid(testcaseob.getId());
|
||||
List<ProjectCaseSteps> steps = GetServerAPI.getStepsbycaseid(testcase.getCaseId());
|
||||
if (steps.size() == 0) {
|
||||
setresult = 2;
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例中未找到步骤,请检查!");
|
||||
caselog.caseLogDetail(taskid, testcaseob.getSign(), "用例中未找到步骤,请检查!", "error", "1", "");
|
||||
LogUtil.APP.warn("用例中未找到步骤,请检查!");
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "用例中未找到步骤,请检查!", "error", "1", "");
|
||||
testnote = "用例中未找到步骤,请检查!";
|
||||
}
|
||||
|
||||
// 进入循环,解析用例所有步骤
|
||||
for (ProjectCasesteps step : steps) {
|
||||
for (ProjectCaseSteps step : steps) {
|
||||
Map<String, String> params;
|
||||
String result;
|
||||
|
||||
// 根据步骤类型来分析步骤参数
|
||||
if (1 == step.getSteptype()){
|
||||
params = WebDriverAnalyticCase.analyticCaseStep(testcaseob, step, taskid, caselog);
|
||||
}else if (4 == step.getSteptype()){
|
||||
params = AppDriverAnalyticCase.analyticCaseStep(testcaseob, step, taskid,caselog);
|
||||
if (1 == step.getStepType()){
|
||||
params = WebDriverAnalyticCase.analyticCaseStep(testcase, step, taskid, caselog);
|
||||
}else if (3 == step.getStepType()){
|
||||
params = AppDriverAnalyticCase.analyticCaseStep(testcase, step, taskid,caselog);
|
||||
} else{
|
||||
params = InterfaceAnalyticCase.analyticCaseStep(testcaseob, step, taskid, caselog);
|
||||
params = InterfaceAnalyticCase.analyticCaseStep(testcase, step, taskid, caselog);
|
||||
}
|
||||
|
||||
// 判断分析步骤参数是否有异常
|
||||
|
@ -375,28 +375,28 @@ public class TestCaseExecution {
|
|||
expectedresults = ChangString.changparams(expectedresults, VARIABLE, "预期结果");
|
||||
|
||||
// 根据步骤类型来执行步骤
|
||||
if (1 == step.getSteptype()){
|
||||
if (1 == step.getStepType()){
|
||||
WebDriver wd=(WebDriver)driver;
|
||||
result = WebCaseExecution.runWebStep(params, VARIABLE, wd, taskid, testcaseob.getSign(), step.getStepnum(), caselog);
|
||||
result = WebCaseExecution.runWebStep(params, VARIABLE, wd, taskid, testcase.getCaseId(), step.getStepSerialNumber(), caselog);
|
||||
// 判断结果
|
||||
setresult = WebCaseExecution.judgeResult(testcaseob, step, params, wd, taskid, expectedresults, result, caselog);
|
||||
}else if (4 == step.getSteptype()){
|
||||
setresult = WebCaseExecution.judgeResult(testcase, step, params, wd, taskid, expectedresults, result, caselog);
|
||||
}else if (3 == step.getStepType()){
|
||||
if (driver instanceof AndroidDriver){
|
||||
AndroidDriver<AndroidElement> ad=(AndroidDriver<AndroidElement>)driver;
|
||||
result = AndroidCaseExecution.androidRunStep(params, VARIABLE, ad, taskid, testcaseob.getSign(), step.getStepnum(), caselog);
|
||||
result = AndroidCaseExecution.androidRunStep(params, VARIABLE, ad, taskid, testcase.getCaseId(), step.getStepSerialNumber(), caselog);
|
||||
// 判断结果
|
||||
setresult = AndroidCaseExecution.judgeResult(testcaseob, step, params, ad, taskid, expectedresults, result, caselog);
|
||||
setresult = AndroidCaseExecution.judgeResult(testcase, step, params, ad, taskid, expectedresults, result, caselog);
|
||||
}else{
|
||||
IOSDriver<IOSElement> ios=(IOSDriver<IOSElement>)driver;
|
||||
result = IosCaseExecution.iosRunStep(params, VARIABLE, ios, taskid, testcaseob.getSign(), step.getStepnum(), caselog);
|
||||
result = IosCaseExecution.iosRunStep(params, VARIABLE, ios, taskid, testcase.getCaseId(), step.getStepSerialNumber(), caselog);
|
||||
// 判断结果
|
||||
setresult = IosCaseExecution.judgeResult(testcaseob, step, params, ios, taskid, expectedresults, result, caselog);
|
||||
setresult = IosCaseExecution.judgeResult(testcase, step, params, ios, taskid, expectedresults, result, caselog);
|
||||
}
|
||||
|
||||
} else{
|
||||
result = runStep(params, VARIABLE, taskid, testcaseob.getSign(), step, caselog);
|
||||
result = runStep(params, VARIABLE, taskid, testcase.getCaseSign(), step, caselog);
|
||||
// 判断结果
|
||||
setresult = interfaceJudgeResult(testcaseob, step, taskid, expectedresults, testnote, caselog);
|
||||
setresult = interfaceJudgeResult(testcase, step, taskid, expectedresults, testnote, caselog);
|
||||
}
|
||||
|
||||
if (0 != setresult){
|
||||
|
@ -406,11 +406,11 @@ public class TestCaseExecution {
|
|||
|
||||
VARIABLE.clear(); // 清空传参MAP
|
||||
if (0 == setresult) {
|
||||
testnote = "调用用例【" + testcaseob.getSign() + "】执行成功!";
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例 " + testcaseob.getSign() + "步骤全部执行成功!");
|
||||
testnote = "调用用例【" + testcase.getCaseSign() + "】执行成功!";
|
||||
LogUtil.APP.info("用例 " + testcase.getCaseSign() + "步骤全部执行成功!");
|
||||
} else {
|
||||
testnote = "调用用例【" + testcaseob.getSign() + "】执行失败,请检查日志!";
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例 " + testcaseob.getSign() + "在执行过程中失败,请检查日志!");
|
||||
testnote = "调用用例【" + testcase.getCaseSign() + "】执行失败,请检查日志!";
|
||||
LogUtil.APP.warn("用例 " + testcase.getCaseSign() + "在执行过程中失败,请检查日志!");
|
||||
}
|
||||
return testnote;
|
||||
}
|
||||
|
@ -425,12 +425,12 @@ public class TestCaseExecution {
|
|||
* @param caselog
|
||||
* @return
|
||||
*/
|
||||
public static String runStep(Map<String, String> params, Map<String, String> variable, String taskid, String casenum, ProjectCasesteps step, LogOperation caselog) {
|
||||
public static String runStep(Map<String, String> params, Map<String, String> variable, String taskid, String casenum, ProjectCaseSteps step, LogOperation caselog) {
|
||||
String result = "";
|
||||
String packagename = "";
|
||||
String functionname = "";
|
||||
Object[] getParameterValues = null;
|
||||
|
||||
ProjectCase projectCase = GetServerAPI.cgetCaseBysign(casenum);
|
||||
try {
|
||||
packagename = params.get("PackageName");
|
||||
packagename = ChangString.changparams(packagename, variable, "包路径");
|
||||
|
@ -438,8 +438,8 @@ public class TestCaseExecution {
|
|||
functionname = ChangString.changparams(functionname, variable, "方法名");
|
||||
|
||||
if (null != functionname && functionname.contains("解析异常")) {
|
||||
LogUtil.APP.error("用例: " + casenum + ", 解析这个方法【" + functionname + "】失败!");
|
||||
caselog.caseLogDetail(taskid, casenum, "用例: " + casenum + ", 解析这个方法【" + functionname + "】失败!", "error", String.valueOf(step.getStepnum()), "");
|
||||
LogUtil.APP.warn("用例: " + casenum + ", 解析这个方法【" + functionname + "】失败!");
|
||||
caselog.insertTaskCaseLog(taskid, projectCase.getCaseId(), "用例: " + casenum + ", 解析这个方法【" + functionname + "】失败!", "error", String.valueOf(step.getStepSerialNumber()), "");
|
||||
result = "步骤执行失败:解析用例失败!";
|
||||
} else {
|
||||
// 判断方法是否带参数
|
||||
|
@ -452,8 +452,8 @@ public class TestCaseExecution {
|
|||
}
|
||||
String parameterValues = params.get("FunctionParams" + (j + 1));
|
||||
parameterValues = ChangString.changparams(parameterValues, variable, "用例参数");
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例: " + casenum + ", 解析包路径:" + packagename + "; 方法名:" + functionname + " 第" + (j + 1) + "个参数:" + parameterValues);
|
||||
caselog.caseLogDetail(taskid, casenum, "用例: " + casenum + ", 解析包名:" + packagename + " 方法名:" + functionname + " 第" + (j + 1) + "个参数:" + parameterValues, "info", String.valueOf(step.getStepnum()), "");
|
||||
LogUtil.APP.info("用例: " + casenum + ", 解析包路径:" + packagename + "; 方法名:" + functionname + " 第" + (j + 1) + "个参数:" + parameterValues);
|
||||
caselog.insertTaskCaseLog(taskid, projectCase.getCaseId(), "用例: " + casenum + ", 解析包名:" + packagename + " 方法名:" + functionname + " 第" + (j + 1) + "个参数:" + parameterValues, "info", String.valueOf(step.getStepSerialNumber()), "");
|
||||
getParameterValues[j] = parameterValues;
|
||||
}
|
||||
} else {
|
||||
|
@ -461,48 +461,51 @@ public class TestCaseExecution {
|
|||
}
|
||||
|
||||
LogUtil.APP.info("二次解析用例过程完成,等待进行接口操作......");
|
||||
caselog.caseLogDetail(taskid, casenum, "包路径: " + packagename + "; 方法名: " + functionname, "info", String.valueOf(step.getStepnum()), "");
|
||||
caselog.insertTaskCaseLog(taskid, projectCase.getCaseId(), "包路径: " + packagename + "; 方法名: " + functionname, "info", String.valueOf(step.getStepSerialNumber()), "");
|
||||
|
||||
result = InvokeMethod.callCase(packagename, functionname, getParameterValues, step.getSteptype(), step.getExtend());
|
||||
result = InvokeMethod.callCase(packagename, functionname, getParameterValues, step.getStepType(), step.getExtend());
|
||||
result = ActionManageForSteps.actionManage(step.getAction(), result);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.APP.error("调用方法过程出错,方法名:" + functionname + ",请重新检查脚本方法名称以及参数!");
|
||||
result = "步骤执行失败:接口调用出错!";
|
||||
}
|
||||
if (result.contains("步骤执行失败:")) caselog.caseLogDetail(taskid, casenum, result, "error", String.valueOf(step.getStepnum()), "");
|
||||
else caselog.caseLogDetail(taskid, casenum, result, "info", String.valueOf(step.getStepnum()), "");
|
||||
if (result.contains("步骤执行失败:")){
|
||||
caselog.insertTaskCaseLog(taskid, projectCase.getCaseId(), result, "error", String.valueOf(step.getStepSerialNumber()), "");
|
||||
} else{
|
||||
caselog.insertTaskCaseLog(taskid, projectCase.getCaseId(), result, "info", String.valueOf(step.getStepSerialNumber()), "");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static int interfaceJudgeResult(ProjectCase testcase, ProjectCasesteps step, String taskid, String expectedresults, String testnote, LogOperation caselog){
|
||||
private static int interfaceJudgeResult(ProjectCase testcase, ProjectCaseSteps step, String taskid, String expectedresults, String testnote, LogOperation caselog){
|
||||
int setresult = 0;
|
||||
try{
|
||||
if (null != expectedresults && !expectedresults.isEmpty()) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("expectedResults=【" + expectedresults + "】");
|
||||
LogUtil.APP.info("expectedResults=【" + expectedresults + "】");
|
||||
// 赋值传参
|
||||
if (expectedresults.length() > ASSIGNMENT_SIGN.length() && expectedresults.startsWith(ASSIGNMENT_SIGN)) {
|
||||
VARIABLE.put(expectedresults.substring(ASSIGNMENT_SIGN.length()), testnote);
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,将测试结果【" + testnote + "】赋值给变量【" + expectedresults.substring(ASSIGNMENT_SIGN.length()) + "】");
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "将测试结果【" + testnote + "】赋值给变量【" + expectedresults.substring(ASSIGNMENT_SIGN.length()) + "】", "info", String.valueOf(step.getStepnum()), "");
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,将测试结果【" + testnote + "】赋值给变量【" + expectedresults.substring(ASSIGNMENT_SIGN.length()) + "】");
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "将测试结果【" + testnote + "】赋值给变量【" + expectedresults.substring(ASSIGNMENT_SIGN.length()) + "】", "info", String.valueOf(step.getStepSerialNumber()), "");
|
||||
}
|
||||
// 赋值全局变量
|
||||
else if (expectedresults.length() > ASSIGNMENT_GLOBALSIGN.length() && expectedresults.startsWith(ASSIGNMENT_GLOBALSIGN)) {
|
||||
VARIABLE.put(expectedresults.substring(ASSIGNMENT_GLOBALSIGN.length()), testnote);
|
||||
ParamsManageForSteps.GLOBAL_VARIABLE.put(expectedresults.substring(ASSIGNMENT_GLOBALSIGN.length()), testnote);
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,将测试结果【" + testnote + "】赋值给全局变量【" + expectedresults.substring(ASSIGNMENT_GLOBALSIGN.length()) + "】");
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "将测试结果【" + testnote + "】赋值给全局变量【" + expectedresults.substring(ASSIGNMENT_GLOBALSIGN.length()) + "】", "info", String.valueOf(step.getStepnum()), "");
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,将测试结果【" + testnote + "】赋值给全局变量【" + expectedresults.substring(ASSIGNMENT_GLOBALSIGN.length()) + "】");
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "将测试结果【" + testnote + "】赋值给全局变量【" + expectedresults.substring(ASSIGNMENT_GLOBALSIGN.length()) + "】", "info", String.valueOf(step.getStepSerialNumber()), "");
|
||||
}
|
||||
// 模糊匹配
|
||||
else if (expectedresults.length() > FUZZY_MATCHING_SIGN.length() && expectedresults.startsWith(FUZZY_MATCHING_SIGN)) {
|
||||
if (testnote.contains(expectedresults.substring(FUZZY_MATCHING_SIGN.length()))) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,模糊匹配预期结果成功!执行结果:" + testnote);
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "模糊匹配预期结果成功!执行结果:" + testnote, "info", String.valueOf(step.getStepnum()), "");
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,模糊匹配预期结果成功!执行结果:" + testnote);
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "模糊匹配预期结果成功!执行结果:" + testnote, "info", String.valueOf(step.getStepSerialNumber()), "");
|
||||
} else {
|
||||
setresult = 1;
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,模糊匹配预期结果失败!预期结果:" + expectedresults.substring(FUZZY_MATCHING_SIGN.length()) + ",测试结果:" + testnote);
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "模糊匹配预期结果失败!预期结果:" + expectedresults.substring(FUZZY_MATCHING_SIGN.length()) + ",测试结果:" + testnote, "error", String.valueOf(step.getStepnum()), "");
|
||||
testnote = "用例第" + step.getStepnum() + "步,模糊匹配预期结果失败!";
|
||||
LogUtil.APP.warn("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,模糊匹配预期结果失败!预期结果:" + expectedresults.substring(FUZZY_MATCHING_SIGN.length()) + ",测试结果:" + testnote);
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "模糊匹配预期结果失败!预期结果:" + expectedresults.substring(FUZZY_MATCHING_SIGN.length()) + ",测试结果:" + testnote, "error", String.valueOf(step.getStepSerialNumber()), "");
|
||||
testnote = "用例第" + step.getStepSerialNumber() + "步,模糊匹配预期结果失败!";
|
||||
}
|
||||
}
|
||||
// 正则匹配
|
||||
|
@ -510,25 +513,25 @@ public class TestCaseExecution {
|
|||
Pattern pattern = Pattern.compile(expectedresults.substring(REGULAR_MATCHING_SIGN.length()));
|
||||
Matcher matcher = pattern.matcher(testnote);
|
||||
if (matcher.find()) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,正则匹配预期结果成功!执行结果:" + testnote);
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "正则匹配预期结果成功!执行结果:" + testnote, "info", String.valueOf(step.getStepnum()), "");
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,正则匹配预期结果成功!执行结果:" + testnote);
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "正则匹配预期结果成功!执行结果:" + testnote, "info", String.valueOf(step.getStepSerialNumber()), "");
|
||||
} else {
|
||||
setresult = 1;
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,正则匹配预期结果失败!预期结果:" + expectedresults.substring(REGULAR_MATCHING_SIGN.length()) + ",测试结果:" + testnote);
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "正则匹配预期结果失败!预期结果:" + expectedresults.substring(REGULAR_MATCHING_SIGN.length()) + ",测试结果:" + testnote, "error", String.valueOf(step.getStepnum()), "");
|
||||
testnote = "用例第" + step.getStepnum() + "步,正则匹配预期结果失败!";
|
||||
LogUtil.APP.warn("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,正则匹配预期结果失败!预期结果:" + expectedresults.substring(REGULAR_MATCHING_SIGN.length()) + ",测试结果:" + testnote);
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "正则匹配预期结果失败!预期结果:" + expectedresults.substring(REGULAR_MATCHING_SIGN.length()) + ",测试结果:" + testnote, "error", String.valueOf(step.getStepSerialNumber()), "");
|
||||
testnote = "用例第" + step.getStepSerialNumber() + "步,正则匹配预期结果失败!";
|
||||
}
|
||||
}
|
||||
// 完全相等
|
||||
else {
|
||||
if (expectedresults.equals(testnote)) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,精确匹配预期结果成功!执行结果:" + testnote);
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "精确匹配预期结果成功!执行结果:" + testnote, "info", String.valueOf(step.getStepnum()), "");
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,精确匹配预期结果成功!执行结果:" + testnote);
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "精确匹配预期结果成功!执行结果:" + testnote, "info", String.valueOf(step.getStepSerialNumber()), "");
|
||||
} else {
|
||||
setresult = 1;
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,精确匹配预期结果失败!预期结果:" + expectedresults + ",测试结果:" + testnote);
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "精确匹配预期结果失败!预期结果:" + expectedresults + ",测试结果:" + testnote, "error", String.valueOf(step.getStepnum()), "");
|
||||
testnote = "用例第" + step.getStepnum() + "步,精确匹配预期结果失败!";
|
||||
LogUtil.APP.warn("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,精确匹配预期结果失败!预期结果:" + expectedresults + ",测试结果:" + testnote);
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "精确匹配预期结果失败!预期结果:" + expectedresults + ",测试结果:" + testnote, "error", String.valueOf(step.getStepSerialNumber()), "");
|
||||
testnote = "用例第" + step.getStepSerialNumber() + "步,精确匹配预期结果失败!";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,33 +6,28 @@ import java.util.concurrent.ArrayBlockingQueue;
|
|||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import br.eti.kinoshita.testlinkjavaapi.model.TestCase;
|
||||
import luckyclient.caserun.exinterface.testlink.ThreadForTestLinkExecuteCase;
|
||||
import luckyclient.dblog.DbLink;
|
||||
import luckyclient.dblog.LogOperation;
|
||||
import luckyclient.jenkinsapi.BuildingInitialization;
|
||||
import luckyclient.jenkinsapi.RestartServerInitialization;
|
||||
import luckyclient.mail.HtmlMail;
|
||||
import luckyclient.mail.MailSendInitialization;
|
||||
import luckyclient.planapi.api.GetServerAPI;
|
||||
import luckyclient.planapi.entity.ProjectCase;
|
||||
import luckyclient.planapi.entity.ProjectCasesteps;
|
||||
import luckyclient.planapi.entity.PublicCaseParams;
|
||||
import luckyclient.planapi.entity.TestJobs;
|
||||
import luckyclient.planapi.entity.TestTaskexcute;
|
||||
import luckyclient.testlinkapi.TestBuildApi;
|
||||
import luckyclient.testlinkapi.TestCaseApi;
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
import luckyclient.serverapi.api.GetServerAPI;
|
||||
import luckyclient.serverapi.entity.ProjectCase;
|
||||
import luckyclient.serverapi.entity.ProjectCaseParams;
|
||||
import luckyclient.serverapi.entity.ProjectCaseSteps;
|
||||
import luckyclient.serverapi.entity.TaskExecute;
|
||||
import luckyclient.serverapi.entity.TaskScheduling;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||
* =================================================================
|
||||
*
|
||||
* @ClassName: TestControl
|
||||
* @Description: 启动扫描指定项目的用例脚本,并调用脚本中的方法
|
||||
* @author: seagull
|
||||
* @Description: 启动扫描指定项目的用例脚本,并调用脚本中的方法 @author: seagull
|
||||
* @date 2014年8月24日 上午9:29:40
|
||||
*
|
||||
*/
|
||||
|
@ -40,45 +35,6 @@ public class TestControl {
|
|||
public static String TASKID = "NULL";
|
||||
public static int THREAD_COUNT = 0;
|
||||
|
||||
/**
|
||||
* @param args
|
||||
* @throws ClassNotFoundException
|
||||
* 控制台模式调度计划执行testlink用例
|
||||
*/
|
||||
|
||||
public static void manualExecutionTestLinkPlan(String projectname, String testplan) throws Exception {
|
||||
DbLink.exetype = 1;
|
||||
int threadcount = 10;
|
||||
// 创建线程池,多线程执行用例
|
||||
ThreadPoolExecutor threadExecute = new ThreadPoolExecutor(threadcount, 20, 3, TimeUnit.SECONDS,
|
||||
new ArrayBlockingQueue<Runnable>(1000), new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
|
||||
TestBuildApi.getBuild(projectname);
|
||||
TestCase[] testCases = TestCaseApi.getplantestcase(projectname, "NULL", testplan);
|
||||
String taskid = "888888";
|
||||
|
||||
for (TestCase testcase : testCases) {
|
||||
if (testcase.getSteps().size() == 0) {
|
||||
continue;
|
||||
}
|
||||
THREAD_COUNT++; // 多线程计数++,用于检测线程是否全部执行完
|
||||
threadExecute
|
||||
.execute(new ThreadForTestLinkExecuteCase(projectname, testcase.getFullExternalId(), testcase, taskid));
|
||||
// new ThreadForExecuteCase(projectname,caseid,testcaseob).run();
|
||||
}
|
||||
// 多线程计数,用于检测线程是否全部执行完
|
||||
int i = 0;
|
||||
while (THREAD_COUNT != 0) {
|
||||
i++;
|
||||
if (i > 600) {
|
||||
break;
|
||||
}
|
||||
Thread.sleep(6000);
|
||||
}
|
||||
luckyclient.publicclass.LogUtil.APP.info("亲,没有下一条啦!我发现你的用例已经全部执行完毕,快去看看有没有失败的用例吧!");
|
||||
threadExecute.shutdown();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param args
|
||||
* @throws ClassNotFoundException
|
||||
|
@ -93,25 +49,23 @@ public class TestControl {
|
|||
new ArrayBlockingQueue<Runnable>(1000), new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
|
||||
List<ProjectCase> testCases = GetServerAPI.getCasesbyplanname(planname);
|
||||
List<PublicCaseParams> pcplist = new ArrayList<PublicCaseParams>();
|
||||
if(testCases.size()!=0){
|
||||
pcplist=GetServerAPI.cgetParamsByProjectid(String.valueOf(testCases.get(0).getProjectid()));
|
||||
List<ProjectCaseParams> pcplist = new ArrayList<ProjectCaseParams>();
|
||||
if (testCases.size() != 0) {
|
||||
pcplist = GetServerAPI.cgetParamsByProjectid(String.valueOf(testCases.get(0).getProjectId()));
|
||||
}
|
||||
|
||||
|
||||
String taskid = "888888";
|
||||
// 初始化写用例结果以及日志模块
|
||||
LogOperation caselog = new LogOperation();
|
||||
LogOperation caselog = new LogOperation();
|
||||
for (ProjectCase testcase : testCases) {
|
||||
List<ProjectCasesteps> steps = GetServerAPI.getStepsbycaseid(testcase.getId());
|
||||
List<ProjectCaseSteps> steps = GetServerAPI.getStepsbycaseid(testcase.getCaseId());
|
||||
if (steps.size() == 0) {
|
||||
caselog.addCaseDetail(taskid, testcase.getSign(), "1", testcase.getName(), 2);
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【" + testcase.getSign() + "】没有找到步骤,直接跳过,请检查!");
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(),"在用例中没有找到步骤,请检查","error", "1", "");
|
||||
LogUtil.APP.warn("用例【" + testcase.getCaseSign() + "】没有找到步骤,直接跳过,请检查!");
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "在用例中没有找到步骤,请检查", "error", "1", "");
|
||||
continue;
|
||||
}
|
||||
THREAD_COUNT++; // 多线程计数++,用于检测线程是否全部执行完
|
||||
threadExecute
|
||||
.execute(new ThreadForExecuteCase(testcase, steps,taskid,pcplist,caselog));
|
||||
threadExecute.execute(new ThreadForExecuteCase(testcase, steps, taskid, pcplist, caselog));
|
||||
}
|
||||
// 多线程计数,用于检测线程是否全部执行完
|
||||
int i = 0;
|
||||
|
@ -122,129 +76,95 @@ public class TestControl {
|
|||
}
|
||||
Thread.sleep(6000);
|
||||
}
|
||||
luckyclient.publicclass.LogUtil.APP.info("亲,没有下一条啦!我发现你的用例已经全部执行完毕,快去看看有没有失败的用例吧!");
|
||||
LogUtil.APP.info("亲,没有下一条啦!我发现你的用例已经全部执行完毕,快去看看有没有失败的用例吧!");
|
||||
threadExecute.shutdown();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param args
|
||||
* @throws ClassNotFoundException
|
||||
* 计划任务模式调度计划执行用例
|
||||
*/
|
||||
|
||||
public static void taskExecutionPlan(String taskid,TestTaskexcute task) throws Exception {
|
||||
public static void taskExecutionPlan(TaskExecute task) throws Exception {
|
||||
DbLink.exetype = 0;
|
||||
String taskid = task.getTaskId().toString();
|
||||
TestControl.TASKID = taskid;
|
||||
String restartstatus = RestartServerInitialization.restartServerRun(taskid);
|
||||
String buildstatus = BuildingInitialization.buildingRun(taskid);
|
||||
String jobname = task.getTestJob().getTaskName();
|
||||
String projectname=task.getTestJob().getPlanproj();
|
||||
int timeout = task.getTestJob().getTimeout();
|
||||
TestJobs testJob = task.getTestJob();
|
||||
int[] tastcount=null;
|
||||
List<PublicCaseParams> pcplist=GetServerAPI.cgetParamsByProjectid(task.getTestJob().getProjectid().toString());
|
||||
TaskScheduling taskScheduling = GetServerAPI.cGetTaskSchedulingByTaskId(task.getTaskId());
|
||||
String jobname = taskScheduling.getSchedulingName();
|
||||
int timeout = taskScheduling.getTaskTimeout();
|
||||
int[] tastcount = null;
|
||||
List<ProjectCaseParams> pcplist = GetServerAPI.cgetParamsByProjectid(taskScheduling.getProjectId().toString());
|
||||
// 初始化写用例结果以及日志模块
|
||||
LogOperation caselog = new LogOperation();
|
||||
LogOperation caselog = new LogOperation();
|
||||
// 判断是否要自动重启TOMCAT
|
||||
if (restartstatus.indexOf("Status:true") > -1) {
|
||||
// 判断是否构建是否成功
|
||||
if (buildstatus.indexOf("Status:true") > -1) {
|
||||
int threadcount = task.getTestJob().getThreadCount();
|
||||
int threadcount = taskScheduling.getExThreadCount();
|
||||
// 创建线程池,多线程执行用例
|
||||
ThreadPoolExecutor threadExecute = new ThreadPoolExecutor(threadcount, 20, 3, TimeUnit.SECONDS,
|
||||
new ArrayBlockingQueue<Runnable>(1000), new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
|
||||
if(task.getTestJob().getProjecttype()==1){
|
||||
TestBuildApi.getBuild(projectname);
|
||||
TestCase[] testCases= TestCaseApi.getplantestcase(projectname, taskid, "");
|
||||
LogOperation.updateTastStatus(taskid, testCases.length);
|
||||
for (TestCase testcase : testCases) {
|
||||
if (testcase.getSteps().size() == 0) {
|
||||
continue;
|
||||
}
|
||||
THREAD_COUNT++; // 多线程计数++,用于检测线程是否全部执行完
|
||||
threadExecute.execute(
|
||||
new ThreadForTestLinkExecuteCase(projectname, testcase.getFullExternalId(), testcase, taskid));
|
||||
|
||||
List<ProjectCase> cases = GetServerAPI.getCasesbyplanId(taskScheduling.getPlanId());
|
||||
LogOperation.updateTaskExecuteStatus(taskid, cases.size());
|
||||
int casepriority = 0;
|
||||
for (int j = 0; j < cases.size(); j++) {
|
||||
ProjectCase projectcase = cases.get(j);
|
||||
List<ProjectCaseSteps> steps = GetServerAPI.getStepsbycaseid(projectcase.getCaseId());
|
||||
if (steps.size() == 0) {
|
||||
caselog.insertTaskCaseExecute(taskid, taskScheduling.getProjectId(),projectcase.getCaseId(),projectcase.getCaseSign(), projectcase.getCaseName(), 2);
|
||||
LogUtil.APP.warn("用例【" + projectcase.getCaseSign() + "】没有找到步骤,直接跳过,请检查!");
|
||||
caselog.insertTaskCaseLog(taskid, projectcase.getCaseId(), "在用例中没有找到步骤,请检查", "error", "1", "");
|
||||
continue;
|
||||
}
|
||||
// 多线程计数,用于检测线程是否全部执行完
|
||||
int i = 0;
|
||||
while (THREAD_COUNT != 0) {
|
||||
i++;
|
||||
if (i > timeout * 10) {
|
||||
break;
|
||||
}
|
||||
Thread.sleep(6000);
|
||||
}
|
||||
tastcount = LogOperation.updateTastdetail(taskid, testCases.length);
|
||||
|
||||
}else{
|
||||
List<ProjectCase> cases=GetServerAPI.getCasesbyplanid(task.getTestJob().getPlanid());
|
||||
LogOperation.updateTastStatus(taskid, cases.size());
|
||||
int casepriority=0;
|
||||
for (int j=0;j<cases.size();j++) {
|
||||
ProjectCase projectcase =cases.get(j);
|
||||
List<ProjectCasesteps> steps=GetServerAPI.getStepsbycaseid(projectcase.getId());
|
||||
if (steps.size()== 0) {
|
||||
caselog.addCaseDetail(taskid, projectcase.getSign(), "1", projectcase.getName(), 2);
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【" + projectcase.getSign() + "】没有找到步骤,直接跳过,请检查!");
|
||||
caselog.caseLogDetail(taskid, projectcase.getSign(),"在用例中没有找到步骤,请检查","error", "1", "");
|
||||
continue;
|
||||
}
|
||||
// 多线程计数,如果用例设置了优先级,必须等优先级高的用例执行完成,才继续后面的用例
|
||||
if(casepriority<projectcase.getPriority()){
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例编号:"+projectcase.getSign()+" casepriority:"+casepriority+" projectcase.getPriority():"+projectcase.getPriority());
|
||||
luckyclient.publicclass.LogUtil.APP.info("THREAD_COUNT:"+THREAD_COUNT);
|
||||
int i = 0;
|
||||
while (THREAD_COUNT != 0) {
|
||||
i++;
|
||||
if (i > timeout*60*5/cases.size()) {
|
||||
break;
|
||||
}
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
}
|
||||
casepriority=projectcase.getPriority();
|
||||
THREAD_COUNT++; // 多线程计数++,用于检测线程是否全部执行完
|
||||
threadExecute.execute(
|
||||
new ThreadForExecuteCase(projectcase, steps,taskid,pcplist,caselog));
|
||||
}
|
||||
// 多线程计数,用于检测线程是否全部执行完
|
||||
// 多线程计数,如果用例设置了优先级,必须等优先级高的用例执行完成,才继续后面的用例
|
||||
if (casepriority < projectcase.getPriority()) {
|
||||
LogUtil.APP.info("用例编号:" + projectcase.getCaseSign() + " casepriority:"
|
||||
+ casepriority + " projectcase.getPriority():" + projectcase.getPriority());
|
||||
LogUtil.APP.info("THREAD_COUNT:" + THREAD_COUNT);
|
||||
int i = 0;
|
||||
while (THREAD_COUNT != 0) {
|
||||
i++;
|
||||
if (i > timeout * 10) {
|
||||
if (i > timeout * 60 * 5 / cases.size()) {
|
||||
break;
|
||||
}
|
||||
Thread.sleep(6000);
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
tastcount = LogOperation.updateTastdetail(taskid, cases.size());
|
||||
|
||||
}
|
||||
casepriority = projectcase.getPriority();
|
||||
THREAD_COUNT++; // 多线程计数++,用于检测线程是否全部执行完
|
||||
threadExecute.execute(new ThreadForExecuteCase(projectcase, steps, taskid, pcplist, caselog));
|
||||
}
|
||||
// 多线程计数,用于检测线程是否全部执行完
|
||||
int i = 0;
|
||||
while (THREAD_COUNT != 0) {
|
||||
i++;
|
||||
if (i > timeout * 10) {
|
||||
break;
|
||||
}
|
||||
Thread.sleep(6000);
|
||||
}
|
||||
tastcount = LogOperation.updateTaskExecuteData(taskid, cases.size());
|
||||
|
||||
String testtime = LogOperation.getTestTime(taskid);
|
||||
MailSendInitialization.sendMailInitialization(HtmlMail.htmlSubjectFormat(jobname),
|
||||
HtmlMail.htmlContentFormat(tastcount, taskid, buildstatus, restartstatus, testtime,jobname), taskid, testJob,
|
||||
tastcount);
|
||||
HtmlMail.htmlContentFormat(tastcount, taskid, buildstatus, restartstatus, testtime, jobname),
|
||||
taskid, taskScheduling, tastcount);
|
||||
threadExecute.shutdown();
|
||||
luckyclient.publicclass.LogUtil.APP.info("亲,没有下一条啦!我发现你的用例已经全部执行完毕,快去看看有没有失败的用例吧!");
|
||||
LogUtil.APP.info("亲,没有下一条啦!我发现你的用例已经全部执行完毕,快去看看有没有失败的用例吧!");
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("项目构建失败,自动化测试自动退出!请前往JENKINS中检查项目构建情况。");
|
||||
MailSendInitialization.sendMailInitialization(jobname,
|
||||
"构建项目过程中失败,自动化测试自动退出!请前去JENKINS查看构建情况!", taskid, testJob,
|
||||
tastcount);
|
||||
LogUtil.APP.warn("项目构建失败,自动化测试自动退出!请前往JENKINS中检查项目构建情况。");
|
||||
MailSendInitialization.sendMailInitialization(jobname, "构建项目过程中失败,自动化测试自动退出!请前去JENKINS查看构建情况!", taskid,
|
||||
taskScheduling, tastcount);
|
||||
}
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("项目TOMCAT重启失败,自动化测试自动退出!请检查项目TOMCAT运行情况。");
|
||||
MailSendInitialization.sendMailInitialization(jobname,
|
||||
"项目TOMCAT重启失败,自动化测试自动退出!请检查项目TOMCAT运行情况!", taskid, testJob,
|
||||
tastcount);
|
||||
LogUtil.APP.warn("项目TOMCAT重启失败,自动化测试自动退出!请检查项目TOMCAT运行情况。");
|
||||
MailSendInitialization.sendMailInitialization(jobname, "项目TOMCAT重启失败,自动化测试自动退出!请检查项目TOMCAT运行情况!", taskid,
|
||||
taskScheduling, tastcount);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
int timeout=10;
|
||||
int a=timeout*60*5/13;
|
||||
System.out.println(a);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,20 +14,18 @@ package luckyclient.caserun.exinterface;
|
|||
public class ThreadForBatchCase extends Thread{
|
||||
|
||||
private String projectname;
|
||||
private String testCaseExternalId;
|
||||
private int version;
|
||||
private String tastid;
|
||||
private Integer caseId;
|
||||
private String taskid;
|
||||
|
||||
public ThreadForBatchCase(String projectname,String testCaseExternalId,int version,String tastid){
|
||||
public ThreadForBatchCase(String projectname,Integer caseId,String taskid){
|
||||
this.projectname = projectname;
|
||||
this.testCaseExternalId = testCaseExternalId;
|
||||
this.version = version;
|
||||
this.tastid = tastid;
|
||||
this.caseId = caseId;
|
||||
this.taskid = taskid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(){
|
||||
TestCaseExecution.oneCaseExecuteForTast(projectname, testCaseExternalId, version, tastid);
|
||||
TestCaseExecution.oneCaseExecuteForTask(projectname, caseId, taskid);
|
||||
TestControl.THREAD_COUNT--; //多线程计数--,用于检测线程是否全部执行完
|
||||
}
|
||||
|
||||
|
|
|
@ -11,10 +11,11 @@ import luckyclient.caserun.publicdispose.ActionManageForSteps;
|
|||
import luckyclient.caserun.publicdispose.ChangString;
|
||||
import luckyclient.caserun.publicdispose.ParamsManageForSteps;
|
||||
import luckyclient.dblog.LogOperation;
|
||||
import luckyclient.planapi.entity.ProjectCase;
|
||||
import luckyclient.planapi.entity.ProjectCasesteps;
|
||||
import luckyclient.planapi.entity.PublicCaseParams;
|
||||
import luckyclient.publicclass.InvokeMethod;
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
import luckyclient.serverapi.entity.ProjectCase;
|
||||
import luckyclient.serverapi.entity.ProjectCaseParams;
|
||||
import luckyclient.serverapi.entity.ProjectCaseSteps;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
@ -34,16 +35,20 @@ public class ThreadForExecuteCase extends Thread {
|
|||
private static final String FUZZY_MATCHING_SIGN = "%=";
|
||||
private static final String REGULAR_MATCHING_SIGN = "~=";
|
||||
|
||||
private String caseid;
|
||||
private ProjectCase testcaseob;
|
||||
private Integer caseId;
|
||||
private String caseSign;
|
||||
private ProjectCase testcase;
|
||||
private String taskid;
|
||||
private List<ProjectCasesteps> steps;
|
||||
private List<PublicCaseParams> pcplist;
|
||||
private Integer projectId;
|
||||
private List<ProjectCaseSteps> steps;
|
||||
private List<ProjectCaseParams> pcplist;
|
||||
private LogOperation caselog;
|
||||
|
||||
public ThreadForExecuteCase(ProjectCase projectcase, List<ProjectCasesteps> steps, String taskid, List<PublicCaseParams> pcplist, LogOperation caselog) {
|
||||
this.caseid = projectcase.getSign();
|
||||
this.testcaseob = projectcase;
|
||||
public ThreadForExecuteCase(ProjectCase projectcase, List<ProjectCaseSteps> steps, String taskid, List<ProjectCaseParams> pcplist, LogOperation caselog) {
|
||||
this.caseId = projectcase.getCaseId();
|
||||
this.testcase = projectcase;
|
||||
this.projectId = projectcase.getProjectId();
|
||||
this.caseSign = projectcase.getCaseSign();
|
||||
this.taskid = taskid;
|
||||
this.steps = steps;
|
||||
this.pcplist = pcplist;
|
||||
|
@ -54,8 +59,8 @@ public class ThreadForExecuteCase extends Thread {
|
|||
public void run() {
|
||||
Map<String, String> variable = new HashMap<>(0);
|
||||
// 把公共参数加入到MAP中
|
||||
for (PublicCaseParams pcp : pcplist) {
|
||||
variable.put(pcp.getParamsname(), pcp.getParamsvalue());
|
||||
for (ProjectCaseParams pcp : pcplist) {
|
||||
variable.put(pcp.getParamsName(), pcp.getParamsValue());
|
||||
}
|
||||
// 加入全局变量
|
||||
variable.putAll(ParamsManageForSteps.GLOBAL_VARIABLE);
|
||||
|
@ -68,10 +73,10 @@ public class ThreadForExecuteCase extends Thread {
|
|||
int k = 0;
|
||||
// 进入循环,解析单个用例所有步骤
|
||||
// 插入开始执行的用例
|
||||
caselog.addCaseDetail(taskid, caseid, "1", testcaseob.getName(), 4);
|
||||
caselog.insertTaskCaseExecute(taskid, projectId, caseId, caseSign, testcase.getCaseName(), 3);
|
||||
for (int i = 0; i < steps.size(); i++) {
|
||||
// 解析单个步骤中的脚本
|
||||
Map<String, String> casescript = InterfaceAnalyticCase.analyticCaseStep(testcaseob, steps.get(i), taskid, caselog);
|
||||
Map<String, String> casescript = InterfaceAnalyticCase.analyticCaseStep(testcase, steps.get(i), taskid, caselog);
|
||||
try {
|
||||
packagename = casescript.get("PackageName");
|
||||
packagename = ChangString.changparams(packagename, variable, "包路径");
|
||||
|
@ -79,8 +84,8 @@ public class ThreadForExecuteCase extends Thread {
|
|||
functionname = ChangString.changparams(functionname, variable, "方法名");
|
||||
} catch (Exception e) {
|
||||
k = 0;
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcaseob.getSign() + "解析包名或是方法名失败,请检查!");
|
||||
caselog.caseLogDetail(taskid, caseid, "解析包名或是方法名失败,请检查!", "error", String.valueOf(i + 1), "");
|
||||
LogUtil.APP.error("用例:" + testcase.getCaseSign() + "解析包名或是方法名失败,请检查!");
|
||||
caselog.insertTaskCaseLog(taskid, caseId, "解析包名或是方法名失败,请检查!", "error", String.valueOf(i + 1), "");
|
||||
e.printStackTrace();
|
||||
break; // 某一步骤失败后,此条用例置为失败退出
|
||||
}
|
||||
|
@ -103,8 +108,8 @@ public class ThreadForExecuteCase extends Thread {
|
|||
}
|
||||
String parameterValues = casescript.get("FunctionParams" + (j + 1));
|
||||
parameterValues = ChangString.changparams(parameterValues, variable, "用例参数");
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcaseob.getSign() + "解析包名:" + packagename + " 方法名:" + functionname + " 第" + (j + 1) + "个参数:" + parameterValues);
|
||||
caselog.caseLogDetail(taskid, caseid, "解析包名:" + packagename + " 方法名:" + functionname + " 第" + (j + 1) + "个参数:" + parameterValues, "info", String.valueOf(i + 1), "");
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + "解析包名:" + packagename + " 方法名:" + functionname + " 第" + (j + 1) + "个参数:" + parameterValues);
|
||||
caselog.insertTaskCaseLog(taskid, caseId, "解析包名:" + packagename + " 方法名:" + functionname + " 第" + (j + 1) + "个参数:" + parameterValues, "info", String.valueOf(i + 1), "");
|
||||
getParameterValues[j] = parameterValues;
|
||||
}
|
||||
} else {
|
||||
|
@ -112,41 +117,41 @@ public class ThreadForExecuteCase extends Thread {
|
|||
}
|
||||
// 调用动态方法,执行测试用例
|
||||
try {
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcaseob.getSign() + "开始调用方法:" + functionname + " .....");
|
||||
caselog.caseLogDetail(taskid, caseid, "开始调用方法:" + functionname + " .....", "info", String.valueOf(i + 1), "");
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + "开始调用方法:" + functionname + " .....");
|
||||
caselog.insertTaskCaseLog(taskid, caseId, "开始调用方法:" + functionname + " .....", "info", String.valueOf(i + 1), "");
|
||||
|
||||
testnote = InvokeMethod.callCase(packagename, functionname, getParameterValues, steps.get(i).getSteptype(), steps.get(i).getExtend());
|
||||
testnote = InvokeMethod.callCase(packagename, functionname, getParameterValues, steps.get(i).getStepType(), steps.get(i).getExtend());
|
||||
testnote = ActionManageForSteps.actionManage(casescript.get("Action"), testnote);
|
||||
if (null != expectedresults && !expectedresults.isEmpty()) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("expectedResults=【" + expectedresults + "】");
|
||||
LogUtil.APP.info("expectedResults=【" + expectedresults + "】");
|
||||
// 赋值传参
|
||||
if (expectedresults.length() > ASSIGNMENT_SIGN.length() && expectedresults.startsWith(ASSIGNMENT_SIGN)) {
|
||||
variable.put(expectedresults.substring(ASSIGNMENT_SIGN.length()), testnote);
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcaseob.getSign() + " 第" + (i + 1) + "步,将测试结果【" + testnote + "】赋值给变量【" + expectedresults.substring(ASSIGNMENT_SIGN.length()) + "】");
|
||||
caselog.caseLogDetail(taskid, caseid, "将测试结果【" + testnote + "】赋值给变量【" + expectedresults.substring(ASSIGNMENT_SIGN.length()) + "】", "info", String.valueOf(i + 1), "");
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + " 第" + (i + 1) + "步,将测试结果【" + testnote + "】赋值给变量【" + expectedresults.substring(ASSIGNMENT_SIGN.length()) + "】");
|
||||
caselog.insertTaskCaseLog(taskid, caseId, "将测试结果【" + testnote + "】赋值给变量【" + expectedresults.substring(ASSIGNMENT_SIGN.length()) + "】", "info", String.valueOf(i + 1), "");
|
||||
}
|
||||
// 赋值全局变量
|
||||
else if (expectedresults.length() > ASSIGNMENT_GLOBALSIGN.length() && expectedresults.startsWith(ASSIGNMENT_GLOBALSIGN)) {
|
||||
variable.put(expectedresults.substring(ASSIGNMENT_GLOBALSIGN.length()), testnote);
|
||||
ParamsManageForSteps.GLOBAL_VARIABLE.put(expectedresults.substring(ASSIGNMENT_GLOBALSIGN.length()), testnote);
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcaseob.getSign() + " 第" + (i + 1) + "步,将测试结果【" + testnote + "】赋值给全局变量【" + expectedresults.substring(ASSIGNMENT_GLOBALSIGN.length()) + "】");
|
||||
caselog.caseLogDetail(taskid, caseid, "将测试结果【" + testnote + "】赋值给全局变量【" + expectedresults.substring(ASSIGNMENT_GLOBALSIGN.length()) + "】", "info", String.valueOf(i + 1), "");
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + " 第" + (i + 1) + "步,将测试结果【" + testnote + "】赋值给全局变量【" + expectedresults.substring(ASSIGNMENT_GLOBALSIGN.length()) + "】");
|
||||
caselog.insertTaskCaseLog(taskid, caseId, "将测试结果【" + testnote + "】赋值给全局变量【" + expectedresults.substring(ASSIGNMENT_GLOBALSIGN.length()) + "】", "info", String.valueOf(i + 1), "");
|
||||
}
|
||||
// 模糊匹配
|
||||
else if (expectedresults.length() > FUZZY_MATCHING_SIGN.length() && expectedresults.startsWith(FUZZY_MATCHING_SIGN)) {
|
||||
if (testnote.contains(expectedresults.substring(FUZZY_MATCHING_SIGN.length()))) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcaseob.getSign() + " 第" + (i + 1) + "步,模糊匹配预期结果成功!执行结果:" + testnote);
|
||||
caselog.caseLogDetail(taskid, caseid, "模糊匹配预期结果成功!执行结果:" + testnote, "info", String.valueOf(i + 1), "");
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + " 第" + (i + 1) + "步,模糊匹配预期结果成功!执行结果:" + testnote);
|
||||
caselog.insertTaskCaseLog(taskid, caseId, "模糊匹配预期结果成功!执行结果:" + testnote, "info", String.valueOf(i + 1), "");
|
||||
} else {
|
||||
setcaseresult = 1;
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcaseob.getSign() + " 第" + (i + 1) + "步,模糊匹配预期结果失败!预期结果:" + expectedresults.substring(FUZZY_MATCHING_SIGN.length()) + ",测试结果:" + testnote);
|
||||
caselog.caseLogDetail(taskid, caseid, "第" + (i + 1) + "步,模糊匹配预期结果失败!预期结果:" + expectedresults.substring(FUZZY_MATCHING_SIGN.length()) + ",测试结果:" + testnote, "error", String.valueOf(i + 1), "");
|
||||
LogUtil.APP.warn("用例:" + testcase.getCaseSign() + " 第" + (i + 1) + "步,模糊匹配预期结果失败!预期结果:" + expectedresults.substring(FUZZY_MATCHING_SIGN.length()) + ",测试结果:" + testnote);
|
||||
caselog.insertTaskCaseLog(taskid, caseId, "第" + (i + 1) + "步,模糊匹配预期结果失败!预期结果:" + expectedresults.substring(FUZZY_MATCHING_SIGN.length()) + ",测试结果:" + testnote, "error", String.valueOf(i + 1), "");
|
||||
testnote = "用例第" + (i + 1) + "步,模糊匹配预期结果失败!";
|
||||
if (testcaseob.getFailcontinue() == 0) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
||||
if (testcase.getFailcontinue() == 0) {
|
||||
LogUtil.APP.warn("用例【"+testcase.getCaseSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
||||
break;
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
||||
LogUtil.APP.warn("用例【"+testcase.getCaseSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -155,52 +160,51 @@ public class ThreadForExecuteCase extends Thread {
|
|||
Pattern pattern = Pattern.compile(expectedresults.substring(REGULAR_MATCHING_SIGN.length()));
|
||||
Matcher matcher = pattern.matcher(testnote);
|
||||
if (matcher.find()) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcaseob.getSign() + " 第" + (i + 1) + "步,正则匹配预期结果成功!执行结果:" + testnote);
|
||||
caselog.caseLogDetail(taskid, caseid, "正则匹配预期结果成功!执行结果:" + testnote, "info", String.valueOf(i + 1), "");
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + " 第" + (i + 1) + "步,正则匹配预期结果成功!执行结果:" + testnote);
|
||||
caselog.insertTaskCaseLog(taskid, caseId, "正则匹配预期结果成功!执行结果:" + testnote, "info", String.valueOf(i + 1), "");
|
||||
} else {
|
||||
setcaseresult = 1;
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcaseob.getSign() + " 第" + (i + 1) + "步,正则匹配预期结果失败!预期结果:" + expectedresults.substring(REGULAR_MATCHING_SIGN.length()) + ",测试结果:" + testnote);
|
||||
caselog.caseLogDetail(taskid, caseid, "第" + (i + 1) + "步,正则匹配预期结果失败!预期结果:" + expectedresults.substring(REGULAR_MATCHING_SIGN.length()) + ",测试结果:" + testnote, "error", String.valueOf(i + 1), "");
|
||||
LogUtil.APP.warn("用例:" + testcase.getCaseSign() + " 第" + (i + 1) + "步,正则匹配预期结果失败!预期结果:" + expectedresults.substring(REGULAR_MATCHING_SIGN.length()) + ",测试结果:" + testnote);
|
||||
caselog.insertTaskCaseLog(taskid, caseId, "第" + (i + 1) + "步,正则匹配预期结果失败!预期结果:" + expectedresults.substring(REGULAR_MATCHING_SIGN.length()) + ",测试结果:" + testnote, "error", String.valueOf(i + 1), "");
|
||||
testnote = "用例第" + (i + 1) + "步,正则匹配预期结果失败!";
|
||||
if (testcaseob.getFailcontinue() == 0) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
||||
if (testcase.getFailcontinue() == 0) {
|
||||
LogUtil.APP.warn("用例【"+testcase.getCaseSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
||||
break;
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
||||
LogUtil.APP.warn("用例【"+testcase.getCaseSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
||||
}
|
||||
}
|
||||
}
|
||||
// 完全相等
|
||||
else {
|
||||
if (expectedresults.equals(testnote)) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcaseob.getSign() + " 第" + (i + 1) + "步,精确匹配预期结果成功!执行结果:" + testnote);
|
||||
caselog.caseLogDetail(taskid, caseid, "精确匹配预期结果成功!执行结果:" + testnote, "info", String.valueOf(i + 1), "");
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + " 第" + (i + 1) + "步,精确匹配预期结果成功!执行结果:" + testnote);
|
||||
caselog.insertTaskCaseLog(taskid, caseId, "精确匹配预期结果成功!执行结果:" + testnote, "info", String.valueOf(i + 1), "");
|
||||
} else {
|
||||
setcaseresult = 1;
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcaseob.getSign() + " 第" + (i + 1) + "步,精确匹配预期结果失败!预期结果:" + expectedresults + ",测试结果:" + testnote);
|
||||
caselog.caseLogDetail(taskid, caseid, "第" + (i + 1) + "步,精确匹配预期结果失败!预期结果:" + expectedresults + ",测试结果:" + testnote, "error", String.valueOf(i + 1), "");
|
||||
LogUtil.APP.warn("用例:" + testcase.getCaseSign() + " 第" + (i + 1) + "步,精确匹配预期结果失败!预期结果:" + expectedresults + ",测试结果:" + testnote);
|
||||
caselog.insertTaskCaseLog(taskid, caseId, "第" + (i + 1) + "步,精确匹配预期结果失败!预期结果:" + expectedresults + ",测试结果:" + testnote, "error", String.valueOf(i + 1), "");
|
||||
testnote = "用例第" + (i + 1) + "步,精确匹配预期结果失败!";
|
||||
if (testcaseob.getFailcontinue() == 0) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
||||
if (testcase.getFailcontinue() == 0) {
|
||||
LogUtil.APP.warn("用例【"+testcase.getCaseSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
||||
break;
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
||||
LogUtil.APP.warn("用例【"+testcase.getCaseSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.ERROR.error("用例:" + testcaseob.getSign() + "调用方法过程出错,方法名:" + functionname + " 请重新检查脚本方法名称以及参数!");
|
||||
caselog.caseLogDetail(taskid, caseid, "调用方法过程出错,方法名:" + functionname + " 请重新检查脚本方法名称以及参数!", "error", String.valueOf(i + 1), "");
|
||||
luckyclient.publicclass.LogUtil.ERROR.error(e, e);
|
||||
LogUtil.APP.error("用例:" + testcase.getCaseSign() + "调用方法过程出错,方法名:" + functionname + " 请重新检查脚本方法名称以及参数!",e);
|
||||
caselog.insertTaskCaseLog(taskid, caseId, "调用方法过程出错,方法名:" + functionname + " 请重新检查脚本方法名称以及参数!", "error", String.valueOf(i + 1), "");
|
||||
testnote = "CallCase调用出错!调用方法过程出错,方法名:" + functionname + " 请重新检查脚本方法名称以及参数!";
|
||||
setcaseresult = 1;
|
||||
e.printStackTrace();
|
||||
if (testcaseob.getFailcontinue() == 0) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
||||
if (testcase.getFailcontinue() == 0) {
|
||||
LogUtil.APP.error("用例【"+testcase.getCaseSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
||||
break;
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
||||
LogUtil.APP.error("用例【"+testcase.getCaseSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -208,32 +212,30 @@ public class ThreadForExecuteCase extends Thread {
|
|||
try {
|
||||
// 成功跟失败的用例走此流程
|
||||
if (!testnote.contains("CallCase调用出错!") && !testnote.contains("解析出错啦!")) {
|
||||
caselog.updateCaseDetail(taskid, caseid, setcaseresult);
|
||||
caselog.updateTaskCaseExecuteStatus(taskid, caseId, setcaseresult);
|
||||
} else {
|
||||
// 解析用例或是调用方法出错,全部把用例置为锁定
|
||||
luckyclient.publicclass.LogUtil.ERROR.error("用例:" + testcaseob.getSign() + "设置执行结果为锁定,请参考错误日志查找锁定用例的原因.....");
|
||||
caselog.caseLogDetail(taskid, caseid, "设置执行结果为锁定,请参考错误日志查找锁定用例的原因.....","error", "SETCASERESULT...", "");
|
||||
LogUtil.APP.warn("用例:" + testcase.getCaseSign() + "设置执行结果为锁定,请参考错误日志查找锁定用例的原因.....");
|
||||
caselog.insertTaskCaseLog(taskid, caseId, "设置执行结果为锁定,请参考错误日志查找锁定用例的原因.....","error", "SETCASERESULT...", "");
|
||||
setcaseresult = 2;
|
||||
caselog.updateCaseDetail(taskid, caseid, setcaseresult);
|
||||
caselog.updateTaskCaseExecuteStatus(taskid, caseId, setcaseresult);
|
||||
}
|
||||
if (0 == setcaseresult) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcaseob.getSign() + "执行结果成功......");
|
||||
caselog.caseLogDetail(taskid, caseid, "用例步骤执行全部成功......", "info", "ending", "");
|
||||
luckyclient.publicclass.LogUtil.APP.info("*********用例【" + testcaseob.getSign() + "】执行完成,测试结果:成功*********");
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + "执行结果成功......");
|
||||
caselog.insertTaskCaseLog(taskid, caseId, "用例步骤执行全部成功......", "info", "ending", "");
|
||||
LogUtil.APP.info("*********用例【" + testcase.getCaseSign() + "】执行完成,测试结果:成功*********");
|
||||
} else if (1 == setcaseresult) {
|
||||
luckyclient.publicclass.LogUtil.ERROR.error("用例:" + testcaseob.getSign() + "执行结果失败......");
|
||||
caselog.caseLogDetail(taskid, caseid, "用例执行结果失败......", "error", "ending", "");
|
||||
luckyclient.publicclass.LogUtil.APP.info("*********用例【" + testcaseob.getSign() + "】执行完成,测试结果:失败*********");
|
||||
LogUtil.APP.warn("用例:" + testcase.getCaseSign() + "执行结果失败......");
|
||||
caselog.insertTaskCaseLog(taskid, caseId, "用例执行结果失败......", "error", "ending", "");
|
||||
LogUtil.APP.info("*********用例【" + testcase.getCaseSign() + "】执行完成,测试结果:失败*********");
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.ERROR.error("用例:" + testcaseob.getSign() + "执行结果锁定......");
|
||||
caselog.caseLogDetail(taskid, caseid, "用例执行结果锁定......", "error", "ending", "");
|
||||
luckyclient.publicclass.LogUtil.APP.info("*********用例【" + testcaseob.getSign() + "】执行完成,测试结果:锁定*********");
|
||||
LogUtil.APP.warn("用例:" + testcase.getCaseSign() + "执行结果锁定......");
|
||||
caselog.insertTaskCaseLog(taskid, caseId, "用例执行结果锁定......", "error", "ending", "");
|
||||
LogUtil.APP.info("*********用例【" + testcase.getCaseSign() + "】执行完成,测试结果:锁定*********");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.ERROR.error("用例:" + testcaseob.getSign() + "设置执行结果过程出错......");
|
||||
caselog.caseLogDetail(taskid, caseid, "设置执行结果过程出错......", "error", "ending", "");
|
||||
luckyclient.publicclass.LogUtil.ERROR.error(e, e);
|
||||
e.printStackTrace();
|
||||
LogUtil.APP.error("用例:" + testcase.getCaseSign() + "设置执行结果过程出错......",e);
|
||||
caselog.insertTaskCaseLog(taskid, caseId, "设置执行结果过程出错......", "error", "ending", "");
|
||||
} finally {
|
||||
variable.clear(); // 一条用例结束后,清空变量存储空间
|
||||
TestControl.THREAD_COUNT--; // 多线程计数--,用于检测线程是否全部执行完
|
||||
|
|
|
@ -9,11 +9,13 @@ import java.util.regex.Pattern;
|
|||
import luckyclient.caserun.exinterface.analyticsteps.InterfaceAnalyticCase;
|
||||
import luckyclient.caserun.publicdispose.ActionManageForSteps;
|
||||
import luckyclient.caserun.publicdispose.ChangString;
|
||||
import luckyclient.planapi.api.GetServerAPI;
|
||||
import luckyclient.planapi.entity.ProjectCase;
|
||||
import luckyclient.planapi.entity.ProjectCasesteps;
|
||||
import luckyclient.planapi.entity.PublicCaseParams;
|
||||
import luckyclient.publicclass.InvokeMethod;
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
import luckyclient.serverapi.api.GetServerAPI;
|
||||
import luckyclient.serverapi.api.PostServerAPI;
|
||||
import luckyclient.serverapi.entity.ProjectCase;
|
||||
import luckyclient.serverapi.entity.ProjectCaseParams;
|
||||
import luckyclient.serverapi.entity.ProjectCaseSteps;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
@ -36,7 +38,7 @@ public class WebTestCaseDebug {
|
|||
* @param executor
|
||||
* @param sign 用于在WEB页面上调试用例时提供的接口
|
||||
*/
|
||||
public static void oneCaseDebug(String sign, String executor) {
|
||||
public static void oneCaseDebug(String caseIdStr, String userIdStr) {
|
||||
Map<String, String> variable = new HashMap<>(0);
|
||||
String packagename = null;
|
||||
String functionname = null;
|
||||
|
@ -45,16 +47,20 @@ public class WebTestCaseDebug {
|
|||
Object[] getParameterValues = null;
|
||||
String testnote = "初始化测试结果";
|
||||
int k = 0;
|
||||
ProjectCase testcaseob = GetServerAPI.cgetCaseBysign(sign);
|
||||
List<PublicCaseParams> pcplist = GetServerAPI.cgetParamsByProjectid(String.valueOf(testcaseob.getProjectid()));
|
||||
Integer caseId = Integer.valueOf(caseIdStr);
|
||||
Integer userId = Integer.valueOf(userIdStr);
|
||||
ProjectCase testcase = GetServerAPI.cGetCaseByCaseId(caseId);
|
||||
|
||||
String sign = testcase.getCaseSign();
|
||||
List<ProjectCaseParams> pcplist = GetServerAPI.cgetParamsByProjectid(String.valueOf(testcase.getProjectId()));
|
||||
// 把公共参数加入到MAP中
|
||||
for (PublicCaseParams pcp : pcplist) {
|
||||
variable.put(pcp.getParamsname(), pcp.getParamsvalue());
|
||||
for (ProjectCaseParams pcp : pcplist) {
|
||||
variable.put(pcp.getParamsName(), pcp.getParamsValue());
|
||||
}
|
||||
List<ProjectCasesteps> steps = GetServerAPI.getStepsbycaseid(testcaseob.getId());
|
||||
List<ProjectCaseSteps> steps = GetServerAPI.getStepsbycaseid(testcase.getCaseId());
|
||||
//进入循环,解析用例所有步骤
|
||||
for (int i = 0; i < steps.size(); i++) {
|
||||
Map<String, String> casescript = InterfaceAnalyticCase.analyticCaseStep(testcaseob, steps.get(i), "888888", null);
|
||||
Map<String, String> casescript = InterfaceAnalyticCase.analyticCaseStep(testcase, steps.get(i), "888888", null);
|
||||
try {
|
||||
packagename = casescript.get("PackageName");
|
||||
packagename = ChangString.changparams(packagename, variable, "包路径");
|
||||
|
@ -62,7 +68,7 @@ public class WebTestCaseDebug {
|
|||
functionname = ChangString.changparams(functionname, variable, "方法名");
|
||||
} catch (Exception e) {
|
||||
k = 0;
|
||||
GetServerAPI.cPostDebugLog(sign, executor, "ERROR", "解析包名或是方法名失败,请检查!");
|
||||
PostServerAPI.cPostDebugLog(userId, caseId, "ERROR", "解析包名或是方法名失败,请检查!",2);
|
||||
e.printStackTrace();
|
||||
break; //某一步骤失败后,此条用例置为失败退出
|
||||
}
|
||||
|
@ -86,7 +92,7 @@ public class WebTestCaseDebug {
|
|||
|
||||
String parameterValues = casescript.get("FunctionParams" + (j + 1));
|
||||
parameterValues = ChangString.changparams(parameterValues, variable, "用例参数");
|
||||
GetServerAPI.cPostDebugLog(sign, executor, "INFO", "解析包名:" + packagename + " 方法名:" + functionname + " 第" + (j + 1) + "个参数:" + parameterValues);
|
||||
PostServerAPI.cPostDebugLog(userId, caseId, "INFO", "解析包名:" + packagename + " 方法名:" + functionname + " 第" + (j + 1) + "个参数:" + parameterValues, 0);
|
||||
getParameterValues[j] = parameterValues;
|
||||
}
|
||||
} else {
|
||||
|
@ -94,29 +100,29 @@ public class WebTestCaseDebug {
|
|||
}
|
||||
//调用动态方法,执行测试用例
|
||||
try {
|
||||
GetServerAPI.cPostDebugLog(sign, executor, "INFO", "开始调用方法:" + functionname + " .....");
|
||||
PostServerAPI.cPostDebugLog(userId, caseId, "INFO", "开始调用方法:" + functionname + " .....",0);
|
||||
|
||||
testnote = InvokeMethod.callCase(packagename, functionname, getParameterValues, steps.get(i).getSteptype(), steps.get(i).getExtend());
|
||||
testnote = InvokeMethod.callCase(packagename, functionname, getParameterValues, steps.get(i).getStepType(), steps.get(i).getExtend());
|
||||
testnote = ActionManageForSteps.actionManage(casescript.get("Action"), testnote);
|
||||
if (null != expectedresults && !expectedresults.isEmpty()) {
|
||||
// 赋值传参
|
||||
if (expectedresults.length() > ASSIGNMENT_SIGN.length() && expectedresults.startsWith(ASSIGNMENT_SIGN)) {
|
||||
variable.put(expectedresults.substring(ASSIGNMENT_SIGN.length()), testnote);
|
||||
GetServerAPI.cPostDebugLog(sign, executor, "INFO", "将测试结果【" + testnote + "】赋值给变量【" + expectedresults.substring(ASSIGNMENT_SIGN.length()) + "】");
|
||||
PostServerAPI.cPostDebugLog(userId, caseId, "INFO", "将测试结果【" + testnote + "】赋值给变量【" + expectedresults.substring(ASSIGNMENT_SIGN.length()) + "】",0);
|
||||
}
|
||||
// 模糊匹配
|
||||
else if (expectedresults.length() > FUZZY_MATCHING_SIGN.length() && expectedresults.startsWith(FUZZY_MATCHING_SIGN)) {
|
||||
if (testnote.contains(expectedresults.substring(FUZZY_MATCHING_SIGN.length()))) {
|
||||
GetServerAPI.cPostDebugLog(sign, executor, "INFO", "模糊匹配预期结果成功!执行结果:" + testnote);
|
||||
PostServerAPI.cPostDebugLog(userId, caseId, "INFO", "模糊匹配预期结果成功!执行结果:" + testnote,0);
|
||||
} else {
|
||||
setcaseresult = 1;
|
||||
GetServerAPI.cPostDebugLog(sign, executor, "ERROR", "第" + (i + 1) + "步,模糊匹配预期结果失败!预期结果:" + expectedresults.substring(FUZZY_MATCHING_SIGN.length()) + ",测试结果:" + testnote);
|
||||
PostServerAPI.cPostDebugLog(userId, caseId, "ERROR", "第" + (i + 1) + "步,模糊匹配预期结果失败!预期结果:" + expectedresults.substring(FUZZY_MATCHING_SIGN.length()) + ",测试结果:" + testnote,0);
|
||||
testnote = "用例第" + (i + 1) + "步,模糊匹配预期结果失败!";
|
||||
if (testcaseob.getFailcontinue() == 0) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
||||
if (testcase.getFailcontinue() == 0) {
|
||||
LogUtil.APP.warn("用例【"+testcase.getCaseSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
||||
break;
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
||||
LogUtil.APP.warn("用例【"+testcase.getCaseSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -125,60 +131,58 @@ public class WebTestCaseDebug {
|
|||
Pattern pattern = Pattern.compile(expectedresults.substring(REGULAR_MATCHING_SIGN.length()));
|
||||
Matcher matcher = pattern.matcher(testnote);
|
||||
if (matcher.find()) {
|
||||
GetServerAPI.cPostDebugLog(sign, executor, "INFO", "正则匹配预期结果成功!执行结果:" + testnote);
|
||||
PostServerAPI.cPostDebugLog(userId, caseId, "INFO", "正则匹配预期结果成功!执行结果:" + testnote,0);
|
||||
} else {
|
||||
setcaseresult = 1;
|
||||
GetServerAPI.cPostDebugLog(sign, executor, "ERROR", "第" + (i + 1) + "步,正则匹配预期结果失败!预期结果:" + expectedresults.substring(REGULAR_MATCHING_SIGN.length()) + ",测试结果:" + testnote);
|
||||
PostServerAPI.cPostDebugLog(userId, caseId, "ERROR", "第" + (i + 1) + "步,正则匹配预期结果失败!预期结果:" + expectedresults.substring(REGULAR_MATCHING_SIGN.length()) + ",测试结果:" + testnote,0);
|
||||
testnote = "用例第" + (i + 1) + "步,正则匹配预期结果失败!";
|
||||
if (testcaseob.getFailcontinue() == 0) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
||||
if (testcase.getFailcontinue() == 0) {
|
||||
LogUtil.APP.warn("用例【"+testcase.getCaseSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
||||
break;
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
||||
LogUtil.APP.warn("用例【"+testcase.getCaseSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
||||
}
|
||||
}
|
||||
}
|
||||
// 完全相等
|
||||
else {
|
||||
if (expectedresults.equals(testnote)) {
|
||||
GetServerAPI.cPostDebugLog(sign, executor, "INFO", "精确匹配预期结果成功!执行结果:" + testnote);
|
||||
PostServerAPI.cPostDebugLog(userId, caseId, "INFO", "精确匹配预期结果成功!执行结果:" + testnote,0);
|
||||
} else {
|
||||
setcaseresult = 1;
|
||||
GetServerAPI.cPostDebugLog(sign, executor, "ERROR", "第" + (i + 1) + "步,精确匹配预期结果失败!预期结果:" + expectedresults + ",测试结果:" + testnote);
|
||||
PostServerAPI.cPostDebugLog(userId, caseId, "ERROR", "第" + (i + 1) + "步,精确匹配预期结果失败!预期结果:" + expectedresults + ",测试结果:" + testnote,0);
|
||||
testnote = "用例第" + (i + 1) + "步,精确匹配预期结果失败!";
|
||||
if (testcaseob.getFailcontinue() == 0) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
||||
if (testcase.getFailcontinue() == 0) {
|
||||
LogUtil.APP.warn("用例【"+testcase.getCaseSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
||||
break;
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
||||
LogUtil.APP.warn("用例【"+testcase.getCaseSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
setcaseresult = 1;
|
||||
GetServerAPI.cPostDebugLog(sign, executor, "ERROR", "调用方法过程出错,方法名:" + functionname + " 请重新检查脚本方法名称以及参数!");
|
||||
PostServerAPI.cPostDebugLog(userId, caseId, "ERROR", "调用方法过程出错,方法名:" + functionname + " 请重新检查脚本方法名称以及参数!",0);
|
||||
testnote = "CallCase调用出错!";
|
||||
e.printStackTrace();
|
||||
if (testcaseob.getFailcontinue() == 0) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
||||
if (testcase.getFailcontinue() == 0) {
|
||||
LogUtil.APP.warn("用例【"+testcase.getCaseSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
||||
break;
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
||||
LogUtil.APP.warn("用例【"+testcase.getCaseSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
||||
}
|
||||
}
|
||||
}
|
||||
variable.clear(); //清空传参MAP
|
||||
//如果调用方法过程中未出错,进入设置测试结果流程
|
||||
if (!testnote.contains("CallCase调用出错!") && !testnote.contains("解析出错啦!")) {
|
||||
GetServerAPI.cPostDebugLog(sign, executor, "INFOover", "用例 " + sign + "解析成功,并成功调用用例中方法,请继续查看执行结果!");
|
||||
} else {
|
||||
GetServerAPI.cPostDebugLog(sign, executor, "ERRORover", "用例 " + sign + "解析或是调用步骤中的方法出错!");
|
||||
if (testnote.contains("CallCase调用出错!") && testnote.contains("解析出错啦!")) {
|
||||
PostServerAPI.cPostDebugLog(userId, caseId, "ERRORover", "用例 " + sign + "解析或是调用步骤中的方法出错!",1);
|
||||
}
|
||||
if (0 == setcaseresult) {
|
||||
GetServerAPI.cPostDebugLog(sign, executor, "INFOover", "用例 " + sign + "步骤全部执行完成!");
|
||||
PostServerAPI.cPostDebugLog(userId, caseId, "INFOover", "用例 " + sign + "步骤全部执行完成!",1);
|
||||
} else {
|
||||
GetServerAPI.cPostDebugLog(sign, executor, "ERRORover", "用例 " + sign + "在执行过程中失败,请检查!");
|
||||
PostServerAPI.cPostDebugLog(userId, caseId, "ERRORover", "用例 " + sign + "在执行过程中失败,请检查!",1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,8 +6,9 @@ import java.util.regex.Matcher;
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
import luckyclient.dblog.LogOperation;
|
||||
import luckyclient.planapi.entity.ProjectCase;
|
||||
import luckyclient.planapi.entity.ProjectCasesteps;
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
import luckyclient.serverapi.entity.ProjectCase;
|
||||
import luckyclient.serverapi.entity.ProjectCaseSteps;
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
|
@ -29,17 +30,17 @@ public class InterfaceAnalyticCase{
|
|||
* @param caselog
|
||||
* @return
|
||||
*/
|
||||
public static Map<String,String> analyticCaseStep(ProjectCase projectcase,ProjectCasesteps step,String taskid,LogOperation caselog){
|
||||
public static Map<String,String> analyticCaseStep(ProjectCase projectcase,ProjectCaseSteps step,String taskid,LogOperation caselog){
|
||||
Map<String,String> params = new HashMap<String,String>(0);
|
||||
|
||||
try {
|
||||
String packagenage = step.getPath();
|
||||
String functionname = step.getOperation();
|
||||
String resultstr = step.getExpectedresult();
|
||||
String packagenage = step.getStepPath();
|
||||
String functionname = step.getStepOperation();
|
||||
String resultstr = step.getExpectedResult();
|
||||
params.put("Action", step.getAction());
|
||||
params.put("PackageName", packagenage.trim());
|
||||
params.put("FunctionName", functionname.trim());
|
||||
String stepParams = replaceSpi(step.getParameters(),0);
|
||||
String stepParams = replaceSpi(step.getStepParameters(),0);
|
||||
String[] temp=stepParams.split("\\|",-1);
|
||||
for(int i=0;i<temp.length;i++){
|
||||
if("".equals(temp[i])){
|
||||
|
@ -58,17 +59,16 @@ public class InterfaceAnalyticCase{
|
|||
}else{
|
||||
params.put("ExpectedResults", subComment(resultstr));
|
||||
}
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例编号:"+projectcase.getSign()+" 步骤编号:"+step.getStepnum()+" 解析自动化用例步骤脚本完成!");
|
||||
LogUtil.APP.info("用例编号:"+projectcase.getCaseSign()+" 步骤编号:"+step.getStepSerialNumber()+" 解析自动化用例步骤脚本完成!");
|
||||
if(null!=caselog){
|
||||
caselog.caseLogDetail(taskid, projectcase.getSign(),"步骤编号:"+step.getStepnum()+" 解析自动化用例步骤脚本完成!","info",String.valueOf(step.getStepnum()),"");
|
||||
caselog.insertTaskCaseLog(taskid, projectcase.getCaseId(),"步骤编号:"+step.getStepSerialNumber()+" 解析自动化用例步骤脚本完成!","info",String.valueOf(step.getStepSerialNumber()),"");
|
||||
}
|
||||
}catch(Exception e) {
|
||||
luckyclient.publicclass.LogUtil.ERROR.error("用例编号:"+projectcase.getSign()+" 步骤编号:"+step.getStepnum()+" 解析自动化用例步骤脚本出错!");
|
||||
if(null!=caselog){
|
||||
caselog.caseLogDetail(taskid, projectcase.getSign(),"步骤编号:"+step.getStepnum()+" 解析自动化用例步骤脚本出错!","error",String.valueOf(step.getStepnum()),"");
|
||||
caselog.insertTaskCaseLog(taskid, projectcase.getCaseId(),"步骤编号:"+step.getStepSerialNumber()+" 解析自动化用例步骤脚本出错!","error",String.valueOf(step.getStepSerialNumber()),"");
|
||||
}
|
||||
luckyclient.publicclass.LogUtil.ERROR.error(e,e);
|
||||
params.put("exception","用例编号:"+projectcase.getSign()+"|解析异常,用例步骤为空或是用例脚本错误!");
|
||||
LogUtil.APP.error("用例编号:"+projectcase.getCaseSign()+" 步骤编号:"+step.getStepSerialNumber()+" 解析自动化用例步骤脚本出错!",e);
|
||||
params.put("exception","用例编号:"+projectcase.getCaseSign()+"|解析异常,用例步骤为空或是用例脚本错误!");
|
||||
return params;
|
||||
}
|
||||
return params;
|
||||
|
@ -161,6 +161,9 @@ public class InterfaceAnalyticCase{
|
|||
*/
|
||||
private static String replaceSpi(String str,int flag){
|
||||
String replacestr="¦_rep;";
|
||||
if(null==str){
|
||||
str = "";
|
||||
}
|
||||
String result=str;
|
||||
if(str.contains("\\\\|")&&flag==0){
|
||||
result=str.replace("\\\\|", replacestr);
|
||||
|
|
|
@ -1,74 +0,0 @@
|
|||
package luckyclient.caserun.exinterface.testlink;
|
||||
|
||||
import luckyclient.caserun.exinterface.TestControl;
|
||||
import luckyclient.dblog.LogOperation;
|
||||
import luckyclient.planapi.api.GetServerAPI;
|
||||
import luckyclient.planapi.entity.TestTaskexcute;
|
||||
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||
* =================================================================
|
||||
*
|
||||
* @author: seagull
|
||||
* @date 2017年12月1日 上午9:29:40
|
||||
*
|
||||
*/
|
||||
public class BatchTestLinkCaseExecution {
|
||||
|
||||
/**
|
||||
* @param args
|
||||
* @throws ClassNotFoundException
|
||||
* 创建线程池,多线程执行用例
|
||||
*/
|
||||
|
||||
public static void batchCaseExecuteForTast(String projectname,String taskid,String batchcase) throws Exception{
|
||||
TestTaskexcute task=GetServerAPI.cgetTaskbyid(Integer.valueOf(taskid));
|
||||
int threadcount = task.getTestJob().getThreadCount();
|
||||
ThreadPoolExecutor threadExecute = new ThreadPoolExecutor(threadcount, 30, 3, TimeUnit.SECONDS,
|
||||
new ArrayBlockingQueue<Runnable>(1000),
|
||||
new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
//执行全部非成功状态用例
|
||||
if(batchcase.indexOf("ALLFAIL")>-1){
|
||||
LogOperation caselog = new LogOperation();
|
||||
String casemore = caselog.unSucCaseUpdate(taskid);
|
||||
String[] temp=casemore.split("\\#",-1);
|
||||
for(int i=0;i<temp.length;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++; //多线程计数++,用于检测线程是否全部执行完
|
||||
threadExecute.execute(new ThreadForTestLinkBatchCase(projectname,testCaseExternalId,version,taskid));
|
||||
}
|
||||
}else{ //批量执行用例
|
||||
String[] temp=batchcase.split("\\#",-1);
|
||||
for(int i=0;i<temp.length;i++){
|
||||
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++; //多线程计数++,用于检测线程是否全部执行完
|
||||
threadExecute.execute(new ThreadForTestLinkBatchCase(projectname,testCaseExternalId,version,taskid));
|
||||
}
|
||||
}
|
||||
//多线程计数,用于检测线程是否全部执行完
|
||||
int i=0;
|
||||
while(TestControl.THREAD_COUNT!=0){
|
||||
i++;
|
||||
if(i>600){
|
||||
break;
|
||||
}
|
||||
Thread.sleep(6000);
|
||||
}
|
||||
threadExecute.shutdown();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
// BatchTestCaseExecution.BatchCaseExecuteForTast("清算项目", "35", "ALLFAIL");
|
||||
}
|
||||
|
||||
}
|
|
@ -1,256 +0,0 @@
|
|||
package luckyclient.caserun.exinterface.testlink;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import br.eti.kinoshita.testlinkjavaapi.constants.ExecutionType;
|
||||
import br.eti.kinoshita.testlinkjavaapi.model.TestCase;
|
||||
import luckyclient.publicclass.DBOperation;
|
||||
import luckyclient.publicclass.InvokeMethod;
|
||||
import luckyclient.testlinkapi.InterfaceAnalyticTestLinkCase;
|
||||
import luckyclient.testlinkapi.TestCaseApi;
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||
* =================================================================
|
||||
* @ClassName: TestCaseDebug
|
||||
* @Description: 针对自动化用例在编写过程中,对用例脚本进行调试
|
||||
* @author: seagull
|
||||
* @date 2014年8月24日 上午9:29:40
|
||||
*
|
||||
*/
|
||||
public class TestLinkCaseDebug{
|
||||
|
||||
/**
|
||||
* @param 项目名
|
||||
* @param 用例编号
|
||||
* @param 用例版本号
|
||||
* 用于在testlink上配置好用例参数后,做单条用例调试
|
||||
*/
|
||||
public static void oneCaseDebug(String projectname,String testCaseExternalId,int version){
|
||||
Map<String,String> variable = new HashMap<String,String>(0);
|
||||
String packagename =null;
|
||||
String functionname = null;
|
||||
String expectedresults = null;
|
||||
Integer setresult = null;
|
||||
Object[] getParameterValues = null;
|
||||
String testnote = null;
|
||||
int k = 0;
|
||||
TestCase testcaseob = TestCaseApi.getTestCaseByExternalId(testCaseExternalId, version);
|
||||
if(testcaseob.getExecutionType()==ExecutionType.AUTOMATED){
|
||||
//进入循环,解析用例所有步骤
|
||||
for(int i=0;i<testcaseob.getSteps().size();i++){
|
||||
Map<String,String> casescript = InterfaceAnalyticTestLinkCase.analyticCaseStep(testcaseob, i+1,"888888",null);
|
||||
packagename = casescript.get("PackageName").toString();
|
||||
functionname = casescript.get("FunctionName").toString();
|
||||
//用例名称解析出现异常或是单个步骤参数解析异常
|
||||
if(functionname.indexOf("解析异常")>-1||k==1){
|
||||
k=0;
|
||||
testnote = "用例第"+(i+1)+"步解析出错啦!";
|
||||
break;
|
||||
}
|
||||
expectedresults = casescript.get("ExpectedResults").toString();
|
||||
if(expectedresults.indexOf(""")>-1||expectedresults.indexOf("'")>-1){
|
||||
expectedresults = expectedresults.replaceAll(""", "\"");
|
||||
expectedresults = expectedresults.replaceAll("'", "\'");
|
||||
}
|
||||
//判断方法是否带参数
|
||||
if(casescript.size()>4){
|
||||
//获取传入参数,放入对象中
|
||||
getParameterValues = new Object[casescript.size()-4];
|
||||
for(int j=0;j<casescript.size()-4;j++){
|
||||
if(casescript.get("FunctionParams"+(j+1))==null){
|
||||
k = 1;
|
||||
break;
|
||||
}
|
||||
if(casescript.get("FunctionParams"+(j+1)).indexOf("@")>-1
|
||||
&&casescript.get("FunctionParams"+(j+1)).indexOf("@@")<0){
|
||||
int keyexistidentity = 0;
|
||||
//取单个参数中引用变量次数
|
||||
int sumvariable = DBOperation.sumString(casescript.get("FunctionParams"+(j+1)), "@");
|
||||
String uservariable = null;
|
||||
String uservariable1 = null;
|
||||
String uservariable2 = null;
|
||||
|
||||
if(sumvariable==1){
|
||||
uservariable = casescript.get("FunctionParams"+(j+1)).substring(
|
||||
casescript.get("FunctionParams"+(j+1)).indexOf("@")+1);
|
||||
}else if(sumvariable==2){
|
||||
uservariable = casescript.get("FunctionParams"+(j+1)).substring(casescript.get("FunctionParams"+(j+1)).indexOf("@")+1,
|
||||
casescript.get("FunctionParams"+(j+1)).lastIndexOf("@"));
|
||||
uservariable1 = casescript.get("FunctionParams"+(j+1)).substring(
|
||||
casescript.get("FunctionParams"+(j+1)).lastIndexOf("@")+1);
|
||||
}else if(sumvariable==3){
|
||||
String temp = casescript.get("FunctionParams"+(j+1)).substring(casescript.get("FunctionParams"+(j+1)).indexOf("@")+1,
|
||||
casescript.get("FunctionParams"+(j+1)).lastIndexOf("@"));
|
||||
uservariable1 = temp.substring(temp.indexOf("@")+1);
|
||||
uservariable2 = casescript.get("FunctionParams"+(j+1)).substring(
|
||||
casescript.get("FunctionParams"+(j+1)).lastIndexOf("@")+1);
|
||||
uservariable = casescript.get("FunctionParams"+(j+1)).substring(casescript.get("FunctionParams"+(j+1)).indexOf("@")+1,
|
||||
casescript.get("FunctionParams"+(j+1)).indexOf(uservariable1)-1);
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.error("你好像在一个参数中引用了超过3个以上的变量哦!我处理不过来啦!");
|
||||
}
|
||||
@SuppressWarnings("rawtypes")
|
||||
Iterator keys = variable.keySet().iterator();
|
||||
String key = null;
|
||||
while(keys.hasNext()){
|
||||
key = (String)keys.next();
|
||||
if(uservariable.indexOf(key)>-1){
|
||||
keyexistidentity = 1;
|
||||
uservariable = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(sumvariable==2||sumvariable==3){
|
||||
keys = variable.keySet().iterator();
|
||||
while(keys.hasNext()){
|
||||
keyexistidentity = 0;
|
||||
key = (String)keys.next();
|
||||
if(uservariable.indexOf(key)>-1){
|
||||
keyexistidentity = 1;
|
||||
uservariable1 = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(sumvariable==3){
|
||||
keys = variable.keySet().iterator();
|
||||
while(keys.hasNext()){
|
||||
keyexistidentity = 0;
|
||||
key = (String)keys.next();
|
||||
if(uservariable.indexOf(key)>-1){
|
||||
keyexistidentity = 1;
|
||||
uservariable2 = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(keyexistidentity == 1){
|
||||
//拼装参数(传参+原有字符串)
|
||||
String parameterValues =casescript.get("FunctionParams"+(j+1)).replaceAll("@"+uservariable, variable.get(uservariable).toString());
|
||||
//处理第二个传参
|
||||
if(sumvariable==2||sumvariable==3){
|
||||
parameterValues = parameterValues.replaceAll("@"+uservariable1, variable.get(uservariable1).toString());
|
||||
}
|
||||
//处理第三个传参
|
||||
if(sumvariable==3){
|
||||
parameterValues = parameterValues.replaceAll("@"+uservariable2, variable.get(uservariable2).toString());
|
||||
}
|
||||
if(parameterValues.indexOf(""")>-1 || parameterValues.indexOf("'")>-1){
|
||||
parameterValues = parameterValues.replaceAll(""", "\"");
|
||||
parameterValues = parameterValues.replaceAll("'", "\'");
|
||||
}
|
||||
luckyclient.publicclass.LogUtil.APP.info("解析包名:"+packagename+" 方法名:"+functionname
|
||||
+" 第"+(j+1)+"个参数:"+parameterValues);
|
||||
getParameterValues[j] = parameterValues;
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.error("没有找到你要的变量哦,再找下吧!第一个变量名称是:"+uservariable+",第"
|
||||
+ "二个变量名称是:"+uservariable1+",第三个变量名称是:"+uservariable2);
|
||||
}
|
||||
|
||||
}else{
|
||||
String parameterValues1 = casescript.get("FunctionParams"+(j+1));
|
||||
if(parameterValues1.indexOf(""")>-1 || parameterValues1.indexOf("'")>-1 || parameterValues1.indexOf("@@")>-1){
|
||||
parameterValues1 = parameterValues1.replaceAll(""", "\"");
|
||||
parameterValues1 = parameterValues1.replaceAll("'", "\'");
|
||||
parameterValues1 = parameterValues1.replaceAll("@@", "@");
|
||||
}
|
||||
luckyclient.publicclass.LogUtil.APP.info("解析包名:"+packagename+" 方法名:"+functionname
|
||||
+" 第"+(j+1)+"个参数:"+parameterValues1);
|
||||
getParameterValues[j] = parameterValues1;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
getParameterValues = null;
|
||||
}
|
||||
//调用动态方法,执行测试用例
|
||||
try{
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始调用方法:"+functionname+" .....");
|
||||
if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("$=")>-1){
|
||||
String expectedResultVariable = casescript.get("ExpectedResults").toString().substring(2);
|
||||
String temptestnote = InvokeMethod.callCase(packagename,functionname,getParameterValues,0,"");
|
||||
variable.put(expectedResultVariable, temptestnote);
|
||||
}else if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("%=")>-1){
|
||||
testnote = InvokeMethod.callCase(packagename,functionname,getParameterValues,0,"");
|
||||
if(testnote.indexOf(expectedresults.substring(2))>-1){
|
||||
setresult = 0;
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例执行结果是:"+testnote+",与预期结果匹配成功!");
|
||||
}else{
|
||||
setresult = 1;
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例第"+(i+1)+"步执行结果与预期结果匹配失败!");
|
||||
luckyclient.publicclass.LogUtil.APP.error("预期结果:"+expectedresults+" 测试结果:"+testnote);
|
||||
testnote = "用例第"+(i+1)+"步执行结果与预期结果匹配失败!";
|
||||
break; //某一步骤失败后,此条用例置为失败退出
|
||||
}
|
||||
}else{ //把预期结果与测试结果做精确匹配
|
||||
testnote = InvokeMethod.callCase(packagename,functionname,getParameterValues,0,"");
|
||||
if(expectedresults.equals(testnote)){
|
||||
setresult = 0;
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例执行结果是:"+testnote+",与预期结果匹配成功!");
|
||||
}else{
|
||||
setresult = 1;
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例第"+(i+1)+"步执行结果与预期结果匹配失败!");
|
||||
luckyclient.publicclass.LogUtil.APP.error("预期结果:"+expectedresults+" 测试结果:"+testnote);
|
||||
testnote = "用例第"+(i+1)+"步执行结果与预期结果匹配失败!";
|
||||
break; //某一步骤失败后,此条用例置为失败退出
|
||||
}
|
||||
}
|
||||
int waitsec = Integer.parseInt(casescript.get("StepWait").toString());
|
||||
if(waitsec!=0){
|
||||
Thread.sleep(waitsec*1000);
|
||||
}
|
||||
}catch(Exception e){
|
||||
setresult = 1;
|
||||
luckyclient.publicclass.LogUtil.APP.error("调用方法过程出错,方法名:"+functionname+" 请重新检查脚本方法名称以及参数!");
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(),e);
|
||||
testnote = "CallCase调用出错!";
|
||||
e.printStackTrace();
|
||||
break;
|
||||
}
|
||||
}
|
||||
variable.clear(); //清空传参MAP
|
||||
//如果调用方法过程中未出错,进入设置测试结果流程
|
||||
if(testnote.indexOf("CallCase调用出错!")<=-1&&testnote.indexOf("解析出错啦!")<=-1){
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例 "+testCaseExternalId+"解析成功,并成功调用用例中方法,请继续查看执行结果!");
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例 "+testCaseExternalId+"解析或是调用步骤中的方法出错!");
|
||||
}
|
||||
if(setresult == 0){
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例 "+testCaseExternalId+"步骤全部执行成功!");
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例 "+testCaseExternalId+"在执行过程中失败,请检查日志!");
|
||||
}
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例 "+testCaseExternalId+"不是一个自动化的用例哦!先去把它设置一下吧!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param 项目名
|
||||
* @param 用例编号
|
||||
* @param 用例版本号
|
||||
* 用于在testlink上配置好用例参数后,做多条用例串行调试
|
||||
*/
|
||||
public static void moreCaseDebug(String projectname,Map<String,Integer> addtestcase){
|
||||
System.out.println(addtestcase.size());
|
||||
@SuppressWarnings("rawtypes")
|
||||
Iterator it=addtestcase.entrySet().iterator();
|
||||
while(it.hasNext()){
|
||||
@SuppressWarnings("rawtypes")
|
||||
Map.Entry entry=(Map.Entry)it.next();
|
||||
String testCaseExternalId = (String)entry.getKey();
|
||||
Integer version = (Integer)entry.getValue();
|
||||
try{
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始调用方法,项目名:"+projectname+",用例编号:"+testCaseExternalId+",用例版本:"+version);
|
||||
oneCaseDebug(projectname,testCaseExternalId,version);
|
||||
}catch(Exception e){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,471 +0,0 @@
|
|||
package luckyclient.caserun.exinterface.testlink;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import br.eti.kinoshita.testlinkjavaapi.constants.ExecutionType;
|
||||
import br.eti.kinoshita.testlinkjavaapi.model.TestCase;
|
||||
import luckyclient.caserun.exinterface.TestControl;
|
||||
import luckyclient.dblog.DbLink;
|
||||
import luckyclient.dblog.LogOperation;
|
||||
import luckyclient.publicclass.DBOperation;
|
||||
import luckyclient.publicclass.InvokeMethod;
|
||||
import luckyclient.testlinkapi.InterfaceAnalyticTestLinkCase;
|
||||
import luckyclient.testlinkapi.TestCaseApi;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||
* =================================================================
|
||||
*
|
||||
* @author: seagull
|
||||
* @date 2017年12月1日 上午9:29:40
|
||||
*
|
||||
*/
|
||||
public class TestLinkCaseExecution{
|
||||
/**
|
||||
* @param 项目名
|
||||
* @param 用例编号
|
||||
* @param 用例版本号
|
||||
* 用于在testlink上配置好用例参数后,做单条用例调试,并通过日志框架写日志到UTP上,用做UTP上单条用例运行
|
||||
*/
|
||||
@SuppressWarnings("static-access")
|
||||
public static void oneCaseExecuteForTast(String projectname,String testCaseExternalId,int version,String taskid){
|
||||
Map<String,String> variable = new HashMap<String,String>(0);
|
||||
TestControl.TASKID = taskid;
|
||||
DbLink.exetype = 0;
|
||||
LogOperation caselog = new LogOperation();
|
||||
String packagename =null;
|
||||
String functionname = null;
|
||||
String expectedresults = null;
|
||||
Integer setresult = null;
|
||||
Object[] getParameterValues = null;
|
||||
String testnote = null;
|
||||
int k = 0;
|
||||
LogOperation.deleteCaseLogDetail(testCaseExternalId, taskid);
|
||||
TestCase testcaseob = TestCaseApi.getTestCaseByExternalId(testCaseExternalId, version);
|
||||
if(testcaseob.getExecutionType()==ExecutionType.AUTOMATED){
|
||||
//进入循环,解析用例所有步骤
|
||||
for(int i=0;i<testcaseob.getSteps().size();i++){
|
||||
Map<String,String> casescript = InterfaceAnalyticTestLinkCase.analyticCaseStep(testcaseob, i+1,taskid,caselog);
|
||||
packagename = casescript.get("PackageName").toString();
|
||||
functionname = casescript.get("FunctionName").toString();
|
||||
//用例名称解析出现异常或是单个步骤参数解析异常
|
||||
if(functionname.indexOf("解析异常")>-1||k==1){
|
||||
k=0;
|
||||
testnote = "用例第"+(i+1)+"步解析出错啦!";
|
||||
break;
|
||||
}
|
||||
expectedresults = casescript.get("ExpectedResults").toString();
|
||||
if(expectedresults.indexOf(""")>-1||expectedresults.indexOf("'")>-1){
|
||||
expectedresults = expectedresults.replaceAll(""", "\"");
|
||||
expectedresults = expectedresults.replaceAll("'", "\'");
|
||||
}
|
||||
//判断方法是否带参数
|
||||
if(casescript.size()>4){
|
||||
//获取传入参数,放入对象中
|
||||
getParameterValues = new Object[casescript.size()-4];
|
||||
for(int j=0;j<casescript.size()-4;j++){
|
||||
if(casescript.get("FunctionParams"+(j+1))==null){
|
||||
k = 1;
|
||||
break;
|
||||
}
|
||||
if(casescript.get("FunctionParams"+(j+1)).indexOf("@")>-1
|
||||
&&casescript.get("FunctionParams"+(j+1)).indexOf("@@")<0){
|
||||
int keyexistidentity = 0;
|
||||
//取单个参数中引用变量次数
|
||||
int sumvariable = DBOperation.sumString(casescript.get("FunctionParams"+(j+1)), "@");
|
||||
String uservariable = null;
|
||||
String uservariable1 = null;
|
||||
String uservariable2 = null;
|
||||
|
||||
if(sumvariable==1){
|
||||
uservariable = casescript.get("FunctionParams"+(j+1)).substring(
|
||||
casescript.get("FunctionParams"+(j+1)).indexOf("@")+1);
|
||||
}else if(sumvariable==2){
|
||||
uservariable = casescript.get("FunctionParams"+(j+1)).substring(casescript.get("FunctionParams"+(j+1)).indexOf("@")+1,
|
||||
casescript.get("FunctionParams"+(j+1)).lastIndexOf("@"));
|
||||
uservariable1 = casescript.get("FunctionParams"+(j+1)).substring(
|
||||
casescript.get("FunctionParams"+(j+1)).lastIndexOf("@")+1);
|
||||
}else if(sumvariable==3){
|
||||
String temp = casescript.get("FunctionParams"+(j+1)).substring(casescript.get("FunctionParams"+(j+1)).indexOf("@")+1,
|
||||
casescript.get("FunctionParams"+(j+1)).lastIndexOf("@"));
|
||||
uservariable1 = temp.substring(temp.indexOf("@")+1);
|
||||
uservariable2 = casescript.get("FunctionParams"+(j+1)).substring(
|
||||
casescript.get("FunctionParams"+(j+1)).lastIndexOf("@")+1);
|
||||
uservariable = casescript.get("FunctionParams"+(j+1)).substring(casescript.get("FunctionParams"+(j+1)).indexOf("@")+1,
|
||||
casescript.get("FunctionParams"+(j+1)).indexOf(uservariable1)-1);
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.error("你好像在一个参数中引用了超过3个以上的变量哦!我处理不过来啦!");
|
||||
caselog.caseLogDetail(taskid, testCaseExternalId, "你好像在一个参数中引用了超过2个以上的变量哦!我处理不过来啦!", "error",String.valueOf(i+1), "");
|
||||
}
|
||||
@SuppressWarnings("rawtypes")
|
||||
Iterator keys = variable.keySet().iterator();
|
||||
String key = null;
|
||||
while(keys.hasNext()){
|
||||
key = (String)keys.next();
|
||||
if(uservariable.indexOf(key)>-1){
|
||||
keyexistidentity = 1;
|
||||
uservariable = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(sumvariable==2||sumvariable==3){
|
||||
keys = variable.keySet().iterator();
|
||||
while(keys.hasNext()){
|
||||
keyexistidentity = 0;
|
||||
key = (String)keys.next();
|
||||
if(uservariable.indexOf(key)>-1){
|
||||
keyexistidentity = 1;
|
||||
uservariable1 = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(sumvariable==3){
|
||||
keys = variable.keySet().iterator();
|
||||
while(keys.hasNext()){
|
||||
keyexistidentity = 0;
|
||||
key = (String)keys.next();
|
||||
if(uservariable.indexOf(key)>-1){
|
||||
keyexistidentity = 1;
|
||||
uservariable2 = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(keyexistidentity == 1){
|
||||
//拼装参数(传参+原有字符串)
|
||||
String parameterValues =casescript.get("FunctionParams"+(j+1)).replaceAll("@"+uservariable, variable.get(uservariable).toString());
|
||||
//处理第二个传参
|
||||
if(sumvariable==2||sumvariable==3){
|
||||
parameterValues = parameterValues.replaceAll("@"+uservariable1, variable.get(uservariable1).toString());
|
||||
}
|
||||
//处理第三个传参
|
||||
if(sumvariable==3){
|
||||
parameterValues = parameterValues.replaceAll("@"+uservariable2, variable.get(uservariable2).toString());
|
||||
}
|
||||
if(parameterValues.indexOf(""")>-1 || parameterValues.indexOf("'")>-1){
|
||||
parameterValues = parameterValues.replaceAll(""", "\"");
|
||||
parameterValues = parameterValues.replaceAll("'", "\'");
|
||||
}
|
||||
luckyclient.publicclass.LogUtil.APP.info("解析包名:"+packagename+" 方法名:"+functionname
|
||||
+" 第"+(j+1)+"个参数:"+parameterValues);
|
||||
caselog.caseLogDetail(taskid, testCaseExternalId, "解析包名:"+packagename+" 方法名:"+functionname
|
||||
+" 第"+(j+1)+"个参数:"+parameterValues, "info",String.valueOf(i+1), "");
|
||||
getParameterValues[j] = parameterValues;
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.error("没有找到你要的变量哦,再找下吧!第一个变量名称是:"+uservariable+",第"
|
||||
+ "二个变量名称是:"+uservariable1+",第三个变量名称是:"+uservariable2);
|
||||
caselog.caseLogDetail(taskid, testCaseExternalId, "没有找到你要的变量哦,再找下吧!第二变量名称是:"+uservariable+",第"
|
||||
+ "二个变量名称是:"+uservariable1+",第三个变量名称是:"+uservariable2, "error",String.valueOf(i+1), "");
|
||||
}
|
||||
|
||||
}else{
|
||||
String parameterValues1 = casescript.get("FunctionParams"+(j+1));
|
||||
if(parameterValues1.indexOf(""")>-1 || parameterValues1.indexOf("'")>-1 || parameterValues1.indexOf("@@")>-1){
|
||||
parameterValues1 = parameterValues1.replaceAll(""", "\"");
|
||||
parameterValues1 = parameterValues1.replaceAll("'", "\'");
|
||||
parameterValues1 = parameterValues1.replaceAll("@@", "@");
|
||||
}
|
||||
luckyclient.publicclass.LogUtil.APP.info("解析包名:"+packagename+" 方法名:"+functionname
|
||||
+" 第"+(j+1)+"个参数:"+parameterValues1);
|
||||
caselog.caseLogDetail(taskid, testCaseExternalId, "解析包名:"+packagename+" 方法名:"+functionname
|
||||
+" 第"+(j+1)+"个参数:"+parameterValues1, "info",String.valueOf(i+1), "");
|
||||
getParameterValues[j] = parameterValues1;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
getParameterValues = null;
|
||||
}
|
||||
//调用动态方法,执行测试用例
|
||||
try{
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始调用方法:"+functionname+" .....");
|
||||
caselog.caseLogDetail(taskid, testCaseExternalId, "开始调用方法:"+functionname+" .....", "info",String.valueOf(i+1), "");
|
||||
if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("$=")>-1){
|
||||
String expectedResultVariable = casescript.get("ExpectedResults").toString().substring(2);
|
||||
String temptestnote = InvokeMethod.callCase(packagename,functionname,getParameterValues,0,"");
|
||||
variable.put(expectedResultVariable, temptestnote);
|
||||
}else if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("%=")>-1){
|
||||
testnote = InvokeMethod.callCase(packagename,functionname,getParameterValues,0,"");
|
||||
if(testnote.indexOf(expectedresults.substring(2))>-1){
|
||||
setresult = 0;
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例执行结果是:"+testnote+",与预期结果匹配成功!");
|
||||
caselog.caseLogDetail(taskid, testCaseExternalId, "用例执行结果是:"+testnote+",与预期结果匹配成功!", "info",String.valueOf(i+1), "");
|
||||
}else{
|
||||
setresult = 1;
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例第"+(i+1)+"步执行结果与预期结果匹配失败!");
|
||||
caselog.caseLogDetail(taskid, testCaseExternalId, "用例第"+(i+1)+"步执行结果与预期结果匹配失败!预期结果:"+expectedresults+" 测试结果:"+testnote, "error",String.valueOf(i+1), "");
|
||||
luckyclient.publicclass.LogUtil.APP.error("预期结果:"+expectedresults+" 测试结果:"+testnote);
|
||||
testnote = "用例第"+(i+1)+"步执行结果与预期结果匹配失败!";
|
||||
break; //某一步骤失败后,此条用例置为失败退出
|
||||
}
|
||||
}else{ //把预期结果与测试结果做精确匹配
|
||||
testnote = InvokeMethod.callCase(packagename,functionname,getParameterValues,0,"");
|
||||
if(expectedresults.equals(testnote)){
|
||||
setresult = 0;
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例执行结果是:"+testnote+",与预期结果匹配成功!");
|
||||
caselog.caseLogDetail(taskid, testCaseExternalId, "用例执行结果是:"+testnote+",与预期结果匹配成功!", "info",String.valueOf(i+1), "");
|
||||
}else{
|
||||
setresult = 1;
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例第"+(i+1)+"步执行结果与预期结果匹配失败!");
|
||||
caselog.caseLogDetail(taskid, testCaseExternalId, "用例第"+(i+1)+"步执行结果与预期结果匹配失败!预期结果:"
|
||||
+expectedresults+" 测试结果:"+testnote, "error",String.valueOf(i+1), "");
|
||||
luckyclient.publicclass.LogUtil.APP.error("预期结果:"+expectedresults+" 测试结果:"+testnote);
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append("用例第"+(i+1)+"步执行结果与预期结果匹配失败!预期结果:"+expectedresults+" 测试结果:");
|
||||
stringBuilder.append(testnote);
|
||||
|
||||
break; //某一步骤失败后,此条用例置为失败退出
|
||||
}
|
||||
}
|
||||
int waitsec = Integer.parseInt(casescript.get("StepWait").toString());
|
||||
if(waitsec!=0){
|
||||
Thread.sleep(waitsec*1000);
|
||||
}
|
||||
}catch(Exception e){
|
||||
luckyclient.publicclass.LogUtil.APP.error("调用方法过程出错,方法名:"+functionname+" 请重新检查脚本方法名称以及参数!");
|
||||
caselog.caseLogDetail(taskid, testCaseExternalId, "调用方法过程出错,方法名:"+functionname+" 请重新检查脚本方法名称以及参数!", "error",String.valueOf(i+1), "");
|
||||
luckyclient.publicclass.LogUtil.APP.error(e,e);
|
||||
testnote = "CallCase调用出错!";
|
||||
setresult = 1;
|
||||
e.printStackTrace();
|
||||
break;
|
||||
}
|
||||
}
|
||||
variable.clear(); //清空传参MAP
|
||||
//如果调用方法过程中未出错,进入设置测试结果流程
|
||||
if(testnote.indexOf("CallCase调用出错!")<=-1&&testnote.indexOf("解析出错啦!")<=-1){
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例 "+testCaseExternalId+"解析成功,并成功调用用例中方法,请继续查看执行结果!");
|
||||
caselog.caseLogDetail(taskid, testCaseExternalId, "解析成功,并成功调用用例中方法,请继续查看执行结果!", "info","SETCASERESULT...", "");
|
||||
//TCResult = TestCaseApi.setTCResult(projectname,testCaseExternalId, testnote, version,setresult);
|
||||
caselog.updateCaseDetail(taskid, testCaseExternalId, setresult);
|
||||
}else{
|
||||
setresult = 1;
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例 "+testCaseExternalId+"解析或是调用步骤中的方法出错!");
|
||||
caselog.caseLogDetail(taskid, testCaseExternalId, "解析或是调用步骤中的方法出错!", "error","SETCASERESULT...", "");
|
||||
// TCResult = TestCaseApi.setTCResult(projectname,testCaseExternalId, testnote, version,2);
|
||||
caselog.updateCaseDetail(taskid, testCaseExternalId, 2);
|
||||
}
|
||||
if(0==setresult){
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例 "+testCaseExternalId+"步骤全部执行成功!");
|
||||
caselog.caseLogDetail(taskid, testCaseExternalId, "步骤全部执行成功!", "info","EXECUTECASESUC...", "");
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例 "+testCaseExternalId+"在执行过程中失败,请检查日志!");
|
||||
caselog.caseLogDetail(taskid, testCaseExternalId, "在执行过程中失败,请检查日志!", "error","EXECUTECASESUC...", "");
|
||||
}
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例 "+testCaseExternalId+"不是一个自动化的用例哦!先去把它设置一下吧!");
|
||||
caselog.caseLogDetail(taskid, testCaseExternalId, "不是一个自动化的用例哦!先去把它设置一下吧!", "error","EXECUTECASEFAIL...", "");
|
||||
}
|
||||
LogOperation.updateTastdetail(taskid, 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param 项目名
|
||||
* @param 用例编号
|
||||
* @param 用例版本号
|
||||
* 用于在UI的测试过程中,需要调用接口的测试用例
|
||||
*/
|
||||
protected static String oneCaseExecuteForWebDriver(String testCaseExternalId,int version,String taskid,LogOperation caselog){
|
||||
Map<String,String> variable = new HashMap<String,String>(0);
|
||||
String packagename =null;
|
||||
String functionname = null;
|
||||
String expectedresults = null;
|
||||
Integer setresult = null;
|
||||
Object[] getParameterValues = null;
|
||||
String testnote = null;
|
||||
int k = 0;
|
||||
TestCase testcaseob = TestCaseApi.getTestCaseByExternalId(testCaseExternalId, version);
|
||||
if(testcaseob.getExecutionType()==ExecutionType.AUTOMATED){
|
||||
//进入循环,解析用例所有步骤
|
||||
for(int i=0;i<testcaseob.getSteps().size();i++){
|
||||
Map<String,String> casescript = InterfaceAnalyticTestLinkCase.analyticCaseStep(testcaseob, i+1,taskid,caselog);
|
||||
packagename = casescript.get("PackageName").toString();
|
||||
functionname = casescript.get("FunctionName").toString();
|
||||
//用例名称解析出现异常或是单个步骤参数解析异常
|
||||
if(functionname.indexOf("解析异常")>-1||k==1){
|
||||
k=0;
|
||||
testnote = "用例第"+(i+1)+"步解析出错啦!";
|
||||
break;
|
||||
}
|
||||
expectedresults = casescript.get("ExpectedResults").toString();
|
||||
if(expectedresults.indexOf(""")>-1||expectedresults.indexOf("'")>-1){
|
||||
expectedresults = expectedresults.replaceAll(""", "\"");
|
||||
expectedresults = expectedresults.replaceAll("'", "\'");
|
||||
}
|
||||
//判断方法是否带参数
|
||||
if(casescript.size()>4){
|
||||
//获取传入参数,放入对象中
|
||||
getParameterValues = new Object[casescript.size()-4];
|
||||
for(int j=0;j<casescript.size()-4;j++){
|
||||
if(casescript.get("FunctionParams"+(j+1))==null){
|
||||
k = 1;
|
||||
break;
|
||||
}
|
||||
if(casescript.get("FunctionParams"+(j+1)).indexOf("@")>-1
|
||||
&&casescript.get("FunctionParams"+(j+1)).indexOf("@@")<0){
|
||||
int keyexistidentity = 0;
|
||||
//取单个参数中引用变量次数
|
||||
int sumvariable = DBOperation.sumString(casescript.get("FunctionParams"+(j+1)), "@");
|
||||
String uservariable = null;
|
||||
String uservariable1 = null;
|
||||
String uservariable2 = null;
|
||||
|
||||
if(sumvariable==1){
|
||||
uservariable = casescript.get("FunctionParams"+(j+1)).substring(
|
||||
casescript.get("FunctionParams"+(j+1)).indexOf("@")+1);
|
||||
}else if(sumvariable==2){
|
||||
uservariable = casescript.get("FunctionParams"+(j+1)).substring(casescript.get("FunctionParams"+(j+1)).indexOf("@")+1,
|
||||
casescript.get("FunctionParams"+(j+1)).lastIndexOf("@"));
|
||||
uservariable1 = casescript.get("FunctionParams"+(j+1)).substring(
|
||||
casescript.get("FunctionParams"+(j+1)).lastIndexOf("@")+1);
|
||||
}else if(sumvariable==3){
|
||||
String temp = casescript.get("FunctionParams"+(j+1)).substring(casescript.get("FunctionParams"+(j+1)).indexOf("@")+1,
|
||||
casescript.get("FunctionParams"+(j+1)).lastIndexOf("@"));
|
||||
uservariable1 = temp.substring(temp.indexOf("@")+1);
|
||||
uservariable2 = casescript.get("FunctionParams"+(j+1)).substring(
|
||||
casescript.get("FunctionParams"+(j+1)).lastIndexOf("@")+1);
|
||||
uservariable = casescript.get("FunctionParams"+(j+1)).substring(casescript.get("FunctionParams"+(j+1)).indexOf("@")+1,
|
||||
casescript.get("FunctionParams"+(j+1)).indexOf(uservariable1)-1);
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.error("你好像在一个参数中引用了超过3个以上的变量哦!我处理不过来啦!");
|
||||
}
|
||||
@SuppressWarnings("rawtypes")
|
||||
Iterator keys = variable.keySet().iterator();
|
||||
String key = null;
|
||||
while(keys.hasNext()){
|
||||
key = (String)keys.next();
|
||||
if(uservariable.indexOf(key)>-1){
|
||||
keyexistidentity = 1;
|
||||
uservariable = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(sumvariable==2||sumvariable==3){
|
||||
keys = variable.keySet().iterator();
|
||||
while(keys.hasNext()){
|
||||
keyexistidentity = 0;
|
||||
key = (String)keys.next();
|
||||
if(uservariable1.indexOf(key)>-1){
|
||||
keyexistidentity = 1;
|
||||
uservariable1 = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(sumvariable==3){
|
||||
keys = variable.keySet().iterator();
|
||||
while(keys.hasNext()){
|
||||
keyexistidentity = 0;
|
||||
key = (String)keys.next();
|
||||
if(uservariable2.indexOf(key)>-1){
|
||||
keyexistidentity = 1;
|
||||
uservariable2 = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(keyexistidentity == 1){
|
||||
//拼装参数(传参+原有字符串)
|
||||
String parameterValues =casescript.get("FunctionParams"+(j+1)).replaceAll("@"+uservariable, variable.get(uservariable).toString());
|
||||
//处理第二个传参
|
||||
if(sumvariable==2||sumvariable==3){
|
||||
parameterValues = parameterValues.replaceAll("@"+uservariable1, variable.get(uservariable1).toString());
|
||||
}
|
||||
//处理第三个传参
|
||||
if(sumvariable==3){
|
||||
parameterValues = parameterValues.replaceAll("@"+uservariable2, variable.get(uservariable2).toString());
|
||||
}
|
||||
if(parameterValues.indexOf(""")>-1 || parameterValues.indexOf("'")>-1){
|
||||
parameterValues = parameterValues.replaceAll(""", "\"");
|
||||
parameterValues = parameterValues.replaceAll("'", "\'");
|
||||
}
|
||||
luckyclient.publicclass.LogUtil.APP.info("解析包名:"+packagename+" 方法名:"+functionname
|
||||
+" 第"+(j+1)+"个参数:"+parameterValues);
|
||||
getParameterValues[j] = parameterValues;
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.error("没有找到你要的变量哦,再找下吧!第一个变量名称是:"+uservariable+",第"
|
||||
+ "二个变量名称是:"+uservariable1+",第三个变量名称是:"+uservariable2);
|
||||
}
|
||||
|
||||
}else{
|
||||
String parameterValues1 = casescript.get("FunctionParams"+(j+1));
|
||||
if(parameterValues1.indexOf(""")>-1 || parameterValues1.indexOf("'")>-1 || parameterValues1.indexOf("@@")>-1){
|
||||
parameterValues1 = parameterValues1.replaceAll(""", "\"");
|
||||
parameterValues1 = parameterValues1.replaceAll("'", "\'");
|
||||
parameterValues1 = parameterValues1.replaceAll("@@", "@");
|
||||
}
|
||||
luckyclient.publicclass.LogUtil.APP.info("解析包名:"+packagename+" 方法名:"+functionname
|
||||
+" 第"+(j+1)+"个参数:"+parameterValues1);
|
||||
getParameterValues[j] = parameterValues1;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
getParameterValues = null;
|
||||
}
|
||||
//调用动态方法,执行测试用例
|
||||
try{
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始调用方法:"+functionname+" .....");
|
||||
if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("$=")>-1){
|
||||
String expectedResultVariable = casescript.get("ExpectedResults").toString().substring(2);
|
||||
String temptestnote = InvokeMethod.callCase(packagename,functionname,getParameterValues,0,"");
|
||||
variable.put(expectedResultVariable, temptestnote);
|
||||
}else if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("%=")>-1){
|
||||
testnote = InvokeMethod.callCase(packagename,functionname,getParameterValues,0,"");
|
||||
if(testnote.indexOf(expectedresults.substring(2))>-1){
|
||||
setresult = 0;
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例执行结果是:"+testnote+",与预期结果匹配成功!");
|
||||
}else{
|
||||
setresult = 1;
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例第"+(i+1)+"步执行结果与预期结果匹配失败!");
|
||||
luckyclient.publicclass.LogUtil.APP.error("预期结果:"+expectedresults+" 测试结果:"+testnote);
|
||||
testnote = "用例第"+(i+1)+"步执行结果与预期结果匹配失败!";
|
||||
break; //某一步骤失败后,此条用例置为失败退出
|
||||
}
|
||||
}else{ //把预期结果与测试结果做精确匹配
|
||||
testnote = InvokeMethod.callCase(packagename,functionname,getParameterValues,0,"");
|
||||
if("".equals(expectedresults)||testnote.equals(expectedresults)){
|
||||
setresult = 0;
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例执行结果是:"+testnote+",与预期结果匹配成功!");
|
||||
}else{
|
||||
setresult = 1;
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例第"+(i+1)+"步执行结果与预期结果匹配失败!");
|
||||
luckyclient.publicclass.LogUtil.APP.error("预期结果:"+expectedresults+" 测试结果:"+testnote);
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append("用例第"+(i+1)+"步执行结果与预期结果匹配失败!预期结果:"+expectedresults+" 测试结果:");
|
||||
stringBuilder.append(testnote);
|
||||
testnote = stringBuilder.toString();
|
||||
break; //某一步骤失败后,此条用例置为失败退出
|
||||
}
|
||||
}
|
||||
int waitsec = Integer.parseInt(casescript.get("StepWait").toString());
|
||||
if(waitsec!=0){
|
||||
Thread.sleep(waitsec*1000);
|
||||
}
|
||||
}catch(Exception e){
|
||||
luckyclient.publicclass.LogUtil.APP.error("调用方法过程出错,方法名:"+functionname+" 请重新检查脚本方法名称以及参数!");
|
||||
luckyclient.publicclass.LogUtil.APP.error(e,e);
|
||||
testnote = "CallCase调用出错!";
|
||||
setresult = 1;
|
||||
e.printStackTrace();
|
||||
break;
|
||||
}
|
||||
}
|
||||
variable.clear(); //清空传参MAP
|
||||
if(0==setresult){
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例 "+testcaseob.getFullExternalId()+"步骤全部执行成功!");
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例 "+testcaseob.getFullExternalId()+"在执行过程中失败,请检查日志!");
|
||||
}
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例 "+testcaseob.getFullExternalId()+"不是一个自动化的用例哦!先去把它设置一下吧!");
|
||||
}
|
||||
return testnote;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
package luckyclient.caserun.exinterface.testlink;
|
||||
|
||||
import luckyclient.caserun.exinterface.TestControl;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||
* =================================================================
|
||||
*
|
||||
* @author: seagull
|
||||
* @date 2017年12月1日 上午9:29:40
|
||||
*
|
||||
*/
|
||||
public class ThreadForTestLinkBatchCase extends Thread{
|
||||
|
||||
private String projectname;
|
||||
private String testCaseExternalId;
|
||||
private int version;
|
||||
private String tastid;
|
||||
|
||||
public ThreadForTestLinkBatchCase(String projectname,String testCaseExternalId,int version,String tastid){
|
||||
this.projectname = projectname;
|
||||
this.testCaseExternalId = testCaseExternalId;
|
||||
this.version = version;
|
||||
this.tastid = tastid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(){
|
||||
TestLinkCaseExecution.oneCaseExecuteForTast(projectname, testCaseExternalId, version, tastid);
|
||||
TestControl.THREAD_COUNT--; //多线程计数--,用于检测线程是否全部执行完
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,294 +0,0 @@
|
|||
package luckyclient.caserun.exinterface.testlink;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import br.eti.kinoshita.testlinkjavaapi.model.TestCase;
|
||||
import luckyclient.caserun.exinterface.TestControl;
|
||||
import luckyclient.dblog.LogOperation;
|
||||
import luckyclient.publicclass.DBOperation;
|
||||
import luckyclient.publicclass.InvokeMethod;
|
||||
import luckyclient.testlinkapi.InterfaceAnalyticTestLinkCase;
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||
* =================================================================
|
||||
* @ClassName: ThreadForExecuteCase
|
||||
* @Description: 线程池方式执行用例
|
||||
* @author: seagull
|
||||
* @date 2015年4月13日 上午9:29:40
|
||||
*
|
||||
*/
|
||||
public class ThreadForTestLinkExecuteCase extends Thread{
|
||||
private String caseid;
|
||||
private TestCase testcaseob;
|
||||
private String tastid;
|
||||
|
||||
public ThreadForTestLinkExecuteCase(String projectname,String caseid,TestCase testcaseob,String tastid){
|
||||
this.caseid = caseid;
|
||||
this.testcaseob = testcaseob;
|
||||
this.tastid = tastid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(){
|
||||
Map<String,String> variable = new HashMap<String,String>(0);
|
||||
LogOperation caselog = new LogOperation();
|
||||
String functionname = null;
|
||||
String packagename =null;
|
||||
String expectedresults = null;
|
||||
Integer setresult = null;
|
||||
Object[] getParameterValues = null;
|
||||
String testnote = null;
|
||||
int k = 0;
|
||||
//进入循环,解析单个用例所有步骤
|
||||
System.out.println(caseid);
|
||||
//插入开始执行的用例
|
||||
caselog.addCaseDetail(tastid, testcaseob.getFullExternalId(), testcaseob.getVersion().toString(), testcaseob.getName(), 4);
|
||||
for(int i=0;i<testcaseob.getSteps().size();i++){
|
||||
//解析单个步骤中的脚本
|
||||
Map<String,String> casescript = InterfaceAnalyticTestLinkCase.analyticCaseStep(testcaseob, i+1,tastid,caselog);
|
||||
try{
|
||||
packagename = casescript.get("PackageName").toString();
|
||||
functionname = casescript.get("FunctionName").toString();
|
||||
}catch(Exception e){
|
||||
k=0;
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:"+testcaseob.getFullExternalId()+"解析包名或是方法名失败,请检查!");
|
||||
caselog.caseLogDetail(tastid, caseid, "解析包名或是方法名失败,请检查!","error",String.valueOf(i+1),"");
|
||||
e.printStackTrace();
|
||||
break; //某一步骤失败后,此条用例置为失败退出
|
||||
}
|
||||
//用例名称解析出现异常或是单个步骤参数解析异常
|
||||
if(functionname.indexOf("解析异常")>-1||k==1){
|
||||
k=0;
|
||||
testnote = "用例第"+(i+1)+"步解析出错啦!";
|
||||
break;
|
||||
}
|
||||
expectedresults = casescript.get("ExpectedResults").toString();
|
||||
if(expectedresults.indexOf(""")>-1||expectedresults.indexOf("'")>-1){
|
||||
expectedresults = expectedresults.replaceAll(""", "\"");
|
||||
expectedresults = expectedresults.replaceAll("'", "\'");
|
||||
}
|
||||
//判断方法是否带参数
|
||||
if(casescript.size()>4){
|
||||
//获取传入参数,放入对象中
|
||||
getParameterValues = new Object[casescript.size()-4];
|
||||
for(int j=0;j<casescript.size()-4;j++){
|
||||
if(casescript.get("FunctionParams"+(j+1))==null){
|
||||
k = 1;
|
||||
break;
|
||||
}
|
||||
if(casescript.get("FunctionParams"+(j+1)).indexOf("@")>-1
|
||||
&&casescript.get("FunctionParams"+(j+1)).indexOf("@@")<0){
|
||||
int keyexistidentity = 0;
|
||||
//取单个参数中引用变量次数
|
||||
int sumvariable = DBOperation.sumString(casescript.get("FunctionParams"+(j+1)), "@");
|
||||
String uservariable = null;
|
||||
String uservariable1 = null;
|
||||
String uservariable2 = null;
|
||||
|
||||
if(sumvariable==1){
|
||||
uservariable = casescript.get("FunctionParams"+(j+1)).substring(
|
||||
casescript.get("FunctionParams"+(j+1)).indexOf("@")+1);
|
||||
}else if(sumvariable==2){
|
||||
uservariable = casescript.get("FunctionParams"+(j+1)).substring(casescript.get("FunctionParams"+(j+1)).indexOf("@")+1,
|
||||
casescript.get("FunctionParams"+(j+1)).lastIndexOf("@"));
|
||||
uservariable1 = casescript.get("FunctionParams"+(j+1)).substring(
|
||||
casescript.get("FunctionParams"+(j+1)).lastIndexOf("@")+1);
|
||||
}else if(sumvariable==3){
|
||||
String temp = casescript.get("FunctionParams"+(j+1)).substring(casescript.get("FunctionParams"+(j+1)).indexOf("@")+1,
|
||||
casescript.get("FunctionParams"+(j+1)).lastIndexOf("@"));
|
||||
uservariable1 = temp.substring(temp.indexOf("@")+1);
|
||||
uservariable2 = casescript.get("FunctionParams"+(j+1)).substring(
|
||||
casescript.get("FunctionParams"+(j+1)).lastIndexOf("@")+1);
|
||||
uservariable = casescript.get("FunctionParams"+(j+1)).substring(casescript.get("FunctionParams"+(j+1)).indexOf("@")+1,
|
||||
casescript.get("FunctionParams"+(j+1)).indexOf(uservariable1)-1);
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.error("你好像在一个参数中引用了超过3个以上的变量哦!我处理不过来啦!");
|
||||
caselog.caseLogDetail(tastid, caseid, "你好像在一个参数中引用了超过2个以上的变量哦!我处理不过来啦!","error",String.valueOf(i+1),"");
|
||||
}
|
||||
@SuppressWarnings("rawtypes")
|
||||
Iterator keys = variable.keySet().iterator();
|
||||
String key = null;
|
||||
while(keys.hasNext()){
|
||||
key = (String)keys.next();
|
||||
if(uservariable.indexOf(key)>-1){
|
||||
keyexistidentity = 1;
|
||||
uservariable = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(sumvariable==2||sumvariable==3){
|
||||
keys = variable.keySet().iterator();
|
||||
while(keys.hasNext()){
|
||||
keyexistidentity = 0;
|
||||
key = (String)keys.next();
|
||||
if(uservariable.indexOf(key)>-1){
|
||||
keyexistidentity = 1;
|
||||
uservariable1 = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(sumvariable==3){
|
||||
keys = variable.keySet().iterator();
|
||||
while(keys.hasNext()){
|
||||
keyexistidentity = 0;
|
||||
key = (String)keys.next();
|
||||
if(uservariable.indexOf(key)>-1){
|
||||
keyexistidentity = 1;
|
||||
uservariable2 = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(keyexistidentity == 1){
|
||||
//拼装参数(传参+原有字符串)
|
||||
String parameterValues =casescript.get("FunctionParams"+(j+1)).replaceAll("@"+uservariable, variable.get(uservariable).toString());
|
||||
//处理第二个传参
|
||||
if(sumvariable==2||sumvariable==3){
|
||||
parameterValues = parameterValues.replaceAll("@"+uservariable1, variable.get(uservariable1).toString());
|
||||
}
|
||||
//处理第三个传参
|
||||
if(sumvariable==3){
|
||||
parameterValues = parameterValues.replaceAll("@"+uservariable2, variable.get(uservariable2).toString());
|
||||
}
|
||||
if(parameterValues.indexOf(""")>-1 || parameterValues.indexOf("'")>-1){
|
||||
parameterValues = parameterValues.replaceAll(""", "\"");
|
||||
parameterValues = parameterValues.replaceAll("'", "\'");
|
||||
}
|
||||
luckyclient.publicclass.LogUtil.APP.info("解析包名:"+packagename+" 方法名:"+functionname
|
||||
+" 第"+(j+1)+"个参数:"+parameterValues);
|
||||
caselog.caseLogDetail(tastid, caseid, "解析包名:"+packagename+" 方法名:"+functionname
|
||||
+" 第"+(j+1)+"个参数:"+parameterValues,"info",String.valueOf(i+1),"");
|
||||
getParameterValues[j] = parameterValues;
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.error("没有找到你要的变量哦,再找下吧!第一个变量名称是:"+uservariable+",第"
|
||||
+ "二个变量名称是:"+uservariable1+",第三个变量名称是:"+uservariable2);
|
||||
caselog.caseLogDetail(tastid, caseid, "没有找到你要的变量哦,再找下吧!第二变量名称是:"+uservariable+",第"
|
||||
+ "二个变量名称是:"+uservariable1,"error",String.valueOf(i+1),"");
|
||||
}
|
||||
|
||||
}else{
|
||||
String parameterValues1 = casescript.get("FunctionParams"+(j+1));
|
||||
if(parameterValues1.indexOf(""")>-1 || parameterValues1.indexOf("'")>-1 || parameterValues1.indexOf("@@")>-1){
|
||||
parameterValues1 = parameterValues1.replaceAll(""", "\"");
|
||||
parameterValues1 = parameterValues1.replaceAll("'", "\'");
|
||||
parameterValues1 = parameterValues1.replaceAll("@@", "@");
|
||||
}
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:"+testcaseob.getFullExternalId()+"解析包名:"+packagename+" 方法名:"+functionname
|
||||
+" 第"+(j+1)+"个参数:"+parameterValues1);
|
||||
caselog.caseLogDetail(tastid, caseid,"解析包名:"+packagename+" 方法名:"+functionname
|
||||
+" 第"+(j+1)+"个参数:"+parameterValues1,"info",String.valueOf(i+1),"");
|
||||
getParameterValues[j] = parameterValues1;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
getParameterValues = null;
|
||||
}
|
||||
//调用动态方法,执行测试用例
|
||||
try{
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:"+testcaseob.getFullExternalId()+"开始调用方法:"+functionname+" .....");
|
||||
caselog.caseLogDetail(tastid, caseid,"开始调用方法:"+functionname+" .....","info",String.valueOf(i+1),"");
|
||||
//把预期结果前两个字符判断是否是要把结果存入变量
|
||||
if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("$=")>-1){
|
||||
String expectedResultVariable = casescript.get("ExpectedResults").toString().substring(2);
|
||||
String temptestnote = InvokeMethod.callCase(packagename,functionname,getParameterValues,0,"");
|
||||
variable.put(expectedResultVariable, temptestnote);
|
||||
//把预期结果与测试结果做模糊匹配
|
||||
}else if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("%=")>-1){
|
||||
testnote = InvokeMethod.callCase(packagename,functionname,getParameterValues,0,"");
|
||||
if(testnote.indexOf(expectedresults.substring(2))>-1){
|
||||
setresult = 0;
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:"+testcaseob.getFullExternalId()+"执行结果是:"+testnote+",与预期结果匹配成功!");
|
||||
caselog.caseLogDetail(tastid, caseid,"执行结果是:"+testnote+",与预期结果匹配成功!","info",String.valueOf(i+1),"");
|
||||
}else{
|
||||
setresult = 1;
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:"+testcaseob.getFullExternalId()+"第"+(i+1)+"步执行结果与预期结果匹配失败!");
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:"+testcaseob.getFullExternalId()+"预期结果:"+expectedresults+" 测试结果:"+testnote);
|
||||
caselog.caseLogDetail(tastid, caseid,"第"+(i+1)+"步执行结果与预期结果匹配失败!"+"预期结果:"+expectedresults+" 测试结果:"+testnote,"error",String.valueOf(i+1),"");
|
||||
testnote = "用例第"+(i+1)+"步执行结果与预期结果匹配失败!";
|
||||
break; //某一步骤失败后,此条用例置为失败退出
|
||||
}
|
||||
}else{ //把预期结果与测试结果做精确匹配
|
||||
testnote = InvokeMethod.callCase(packagename,functionname,getParameterValues,0,"");
|
||||
if(expectedresults.equals(testnote)){
|
||||
setresult = 0;
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:"+testcaseob.getFullExternalId()+"执行结果是:"+testnote+",与预期结果匹配成功!");
|
||||
caselog.caseLogDetail(tastid, caseid,"执行结果是:"+testnote+",与预期结果匹配成功!","info",String.valueOf(i+1),"");
|
||||
}else{
|
||||
setresult = 1;
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:"+testcaseob.getFullExternalId()+"第"+(i+1)+"步执行结果与预期结果匹配失败!");
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:"+testcaseob.getFullExternalId()+"预期结果:"+expectedresults+" 测试结果:"+testnote);
|
||||
caselog.caseLogDetail(tastid, caseid,"第"+(i+1)+"步执行结果与预期结果匹配失败!"+"预期结果:"+expectedresults+" 测试结果:"+testnote,"error",String.valueOf(i+1),"");
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append("用例第"+(i+1)+"步执行结果与预期结果匹配失败!预期结果:"+expectedresults+" 测试结果:");
|
||||
stringBuilder.append(testnote);
|
||||
testnote = stringBuilder.toString();
|
||||
break; //某一步骤失败后,此条用例置为失败退出
|
||||
}
|
||||
}
|
||||
int waitsec = Integer.parseInt(casescript.get("StepWait").toString());
|
||||
if(waitsec!=0){
|
||||
Thread.sleep(waitsec*1000);
|
||||
}
|
||||
}catch(Exception e){
|
||||
luckyclient.publicclass.LogUtil.ERROR.error("用例:"+testcaseob.getFullExternalId()+"调用方法过程出错,方法名:"+functionname+" 请重新检查脚本方法名称以及参数!");
|
||||
caselog.caseLogDetail(tastid, caseid,"调用方法过程出错,方法名:"+functionname+" 请重新检查脚本方法名称以及参数!","error",String.valueOf(i+1),"");
|
||||
luckyclient.publicclass.LogUtil.ERROR.error(e,e);
|
||||
testnote = "CallCase调用出错!调用方法过程出错,方法名:"+functionname+" 请重新检查脚本方法名称以及参数!";
|
||||
setresult = 1;
|
||||
e.printStackTrace();
|
||||
break;
|
||||
}
|
||||
}
|
||||
//如果调用方法过程中未出错,进入设置测试结果流程
|
||||
try{
|
||||
//成功跟失败的用例走此流程
|
||||
if(testnote.indexOf("CallCase调用出错!")<=-1&&testnote.indexOf("解析出错啦!")<=-1){
|
||||
//luckyclient.publicclass.LogUtil.APP.info("用例:"+testcaseob.getFullExternalId()+"开始设置测试用例执行结果 .....");
|
||||
//caselog.caseLogDetail(tastid, caseid,"开始设置测试用例执行结果 .....","info","SETCASERESULT...");
|
||||
//TCResult = TestCaseApi.setTCResult(projectname,caseid, testnote, testcaseob.getVersion(),setresult);
|
||||
caselog.updateCaseDetail(tastid, caseid, setresult);
|
||||
}else{
|
||||
//解析用例或是调用方法出错,全部把用例置为锁定
|
||||
luckyclient.publicclass.LogUtil.ERROR.error("用例:"+testcaseob.getFullExternalId()+"设置执行结果为锁定,请参考错误日志查找锁定用例的原因.....");
|
||||
caselog.caseLogDetail(tastid, caseid,"设置执行结果为锁定,请参考错误日志查找锁定用例的原因.....","error","SETCASERESULT...","");
|
||||
//TCResult = TestCaseApi.setTCResult(projectname,caseid, testnote, testcaseob.getVersion(),2);
|
||||
setresult = 2;
|
||||
caselog.updateCaseDetail(tastid, caseid, setresult);
|
||||
}
|
||||
if(setresult==0){
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:"+testcaseob.getFullExternalId()+"执行结果成功......");
|
||||
caselog.caseLogDetail(tastid, caseid,"用例步骤执行全部成功......","info","ending","");
|
||||
luckyclient.publicclass.LogUtil.APP.info("******************************分割线*************************************");
|
||||
}else if(setresult==1){
|
||||
luckyclient.publicclass.LogUtil.ERROR.error("用例:"+testcaseob.getFullExternalId()+"执行结果失败......");
|
||||
caselog.caseLogDetail(tastid, caseid,"用例执行结果失败......","error","ending","");
|
||||
luckyclient.publicclass.LogUtil.APP.info("******************************分割线*************************************");
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.ERROR.error("用例:"+testcaseob.getFullExternalId()+"执行结果锁定......");
|
||||
caselog.caseLogDetail(tastid, caseid,"用例执行结果锁定......","error","ending","");
|
||||
luckyclient.publicclass.LogUtil.APP.info("******************************分割线*************************************");
|
||||
}
|
||||
}catch(Exception e){
|
||||
luckyclient.publicclass.LogUtil.ERROR.error("用例:"+testcaseob.getFullExternalId()+"设置执行结果过程出错......");
|
||||
caselog.caseLogDetail(tastid, caseid,"设置执行结果过程出错......","error","ending","");
|
||||
luckyclient.publicclass.LogUtil.ERROR.error(e,e);
|
||||
e.printStackTrace();
|
||||
}finally{
|
||||
variable.clear(); //一条用例结束后,清空变量存储空间
|
||||
TestControl.THREAD_COUNT--; //多线程计数--,用于检测线程是否全部执行完
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -9,6 +9,8 @@ import org.openqa.selenium.TakesScreenshot;
|
|||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.remote.Augmenter;
|
||||
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
|
@ -38,11 +40,11 @@ public class BaseWebDrive {
|
|||
try {
|
||||
FileUtils.copyFile(scrFile, new File(pngpath));
|
||||
} catch (IOException e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("截图操作失败,抛出异常请查看日志...", e);
|
||||
LogUtil.APP.error("截图操作失败,抛出异常请查看日志...", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
scrFile.deleteOnExit();
|
||||
luckyclient.publicclass.LogUtil.APP
|
||||
LogUtil.APP
|
||||
.info("已对当前界面进行截图操作,可通过用例执行界面的日志明细查看,也可以前往客户端上查看...【" + pngpath + "】");
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -7,10 +7,11 @@ import org.openqa.selenium.WebDriver;
|
|||
import luckyclient.caserun.exwebdriver.ex.WebCaseExecution;
|
||||
import luckyclient.dblog.DbLink;
|
||||
import luckyclient.dblog.LogOperation;
|
||||
import luckyclient.planapi.api.GetServerAPI;
|
||||
import luckyclient.planapi.entity.ProjectCase;
|
||||
import luckyclient.planapi.entity.ProjectCasesteps;
|
||||
import luckyclient.planapi.entity.PublicCaseParams;
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
import luckyclient.serverapi.api.GetServerAPI;
|
||||
import luckyclient.serverapi.entity.ProjectCase;
|
||||
import luckyclient.serverapi.entity.ProjectCaseParams;
|
||||
import luckyclient.serverapi.entity.ProjectCaseSteps;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
@ -32,13 +33,13 @@ public class CaseLocalDebug{
|
|||
LogOperation caselog = new LogOperation();
|
||||
try {
|
||||
ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId);
|
||||
List<PublicCaseParams> pcplist=GetServerAPI.cgetParamsByProjectid(String.valueOf(testcase.getProjectid()));
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始执行用例:【"+testCaseExternalId+"】......");
|
||||
List<ProjectCasesteps> steps=GetServerAPI.getStepsbycaseid(testcase.getId());
|
||||
List<ProjectCaseParams> pcplist=GetServerAPI.cgetParamsByProjectid(String.valueOf(testcase.getProjectId()));
|
||||
LogUtil.APP.info("开始执行用例:【"+testCaseExternalId+"】......");
|
||||
List<ProjectCaseSteps> steps=GetServerAPI.getStepsbycaseid(testcase.getCaseId());
|
||||
WebCaseExecution.caseExcution(testcase,steps, "888888",wd,caselog,pcplist);
|
||||
luckyclient.publicclass.LogUtil.APP.info("当前用例:【"+testcase.getSign()+"】执行完成......进入下一条");
|
||||
LogUtil.APP.info("当前用例:【"+testcase.getCaseSign()+"】执行完成......进入下一条");
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.ERROR.info("用户执行过程中抛出异常!", e);
|
||||
LogUtil.APP.info("用户执行过程中抛出异常!", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
//关闭浏览器
|
||||
|
@ -55,7 +56,7 @@ public class CaseLocalDebug{
|
|||
System.out.println("当前调试用例总共:"+addtestcase.size());
|
||||
for(String testCaseExternalId:addtestcase) {
|
||||
try{
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始调用方法,项目名:"+projectname+",用例编号:" + testCaseExternalId);
|
||||
LogUtil.APP.info("开始调用方法,项目名:"+projectname+",用例编号:" + testCaseExternalId);
|
||||
oneCasedebug(wd,testCaseExternalId);
|
||||
}catch(Exception e){
|
||||
continue;
|
||||
|
|
|
@ -1,5 +1,27 @@
|
|||
package luckyclient.caserun.exwebdriver;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openqa.selenium.Alert;
|
||||
import org.openqa.selenium.Cookie;
|
||||
import org.openqa.selenium.JavascriptExecutor;
|
||||
import org.openqa.selenium.Keys;
|
||||
import org.openqa.selenium.NoSuchWindowException;
|
||||
import org.openqa.selenium.Point;
|
||||
import org.openqa.selenium.TimeoutException;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.interactions.Actions;
|
||||
import org.openqa.selenium.support.ui.ExpectedCondition;
|
||||
import org.openqa.selenium.support.ui.FluentWait;
|
||||
import org.openqa.selenium.support.ui.Select;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
@ -7,19 +29,6 @@ import com.alibaba.fastjson.JSONObject;
|
|||
import luckyclient.caserun.exwebdriver.ocr.Ocr;
|
||||
import luckyclient.caserun.publicdispose.ChangString;
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openqa.selenium.*;
|
||||
import org.openqa.selenium.interactions.Actions;
|
||||
import org.openqa.selenium.support.ui.ExpectedCondition;
|
||||
import org.openqa.selenium.support.ui.FluentWait;
|
||||
import org.openqa.selenium.support.ui.Select;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
@ -43,21 +52,21 @@ public class EncapsulateOperation {
|
|||
case "selectbyvisibletext":
|
||||
select.selectByVisibleText(operationValue);
|
||||
result = "下拉框对象通过VisibleText属性选择...【VisibleText属性值:" + operationValue + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break;
|
||||
case "selectbyvalue":
|
||||
select.selectByValue(operationValue);
|
||||
result = "下拉框对象通过Value属性选择...【Value属性值:" + operationValue + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break;
|
||||
case "selectbyindex":
|
||||
select.selectByIndex(Integer.valueOf(operationValue));
|
||||
result = "下拉框对象通过Index属性选择...【Index属性值:" + operationValue + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break;
|
||||
case "isselect":
|
||||
result = "获取到的值是【" + we.isSelected() + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info("判断对象是否已经被选择...【结果值:" + we.isSelected() + "】");
|
||||
LogUtil.APP.info("判断对象是否已经被选择...【结果值:" + we.isSelected() + "】");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -71,23 +80,23 @@ public class EncapsulateOperation {
|
|||
switch (operation) {
|
||||
case "gettext":
|
||||
result = "获取到的值是【" + we.getText() + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info("getText获取对象text属性...【text属性值:" + result + "】");
|
||||
LogUtil.APP.info("getText获取对象text属性...【text属性值:" + result + "】");
|
||||
break; // 获取输入框内容
|
||||
case "gettagname":
|
||||
result = "获取到的值是【" + we.getTagName() + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info("getTagName获取对象tagname属性...【tagname属性值:" + result + "】");
|
||||
LogUtil.APP.info("getTagName获取对象tagname属性...【tagname属性值:" + result + "】");
|
||||
break;
|
||||
case "getattribute":
|
||||
result = "获取到的值是【" + we.getAttribute(value) + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info("getAttribute获取对象【" + value + "】属性...【" + value + "属性值:" + result + "】");
|
||||
LogUtil.APP.info("getAttribute获取对象【" + value + "】属性...【" + value + "属性值:" + result + "】");
|
||||
break;
|
||||
case "getcssvalue":
|
||||
result = "获取到的值是【" + we.getCssValue(value) + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info("getCssValue获取对象【" + value + "】属性...【" + value + "属性值:" + result + "】");
|
||||
LogUtil.APP.info("getCssValue获取对象【" + value + "】属性...【" + value + "属性值:" + result + "】");
|
||||
break;
|
||||
case "getcaptcha":
|
||||
result = "获取到的值是【" + Ocr.getCAPTCHA(wd, we) + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info("getcaptcha获取验证码...【验证码值:" + result + "】");
|
||||
LogUtil.APP.info("getcaptcha获取验证码...【验证码值:" + result + "】");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -104,41 +113,41 @@ public class EncapsulateOperation {
|
|||
case "mouselkclick":
|
||||
action.click(we).perform();
|
||||
result = "mouselkclick鼠标左键点击对象...【对象定位属性:" + property + "; 定位属性值:" + propertyValue + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break;
|
||||
case "mouserkclick":
|
||||
action.contextClick(we).perform();
|
||||
result = "mouserkclick鼠标右键点击对象...【对象定位属性:" + property + "; 定位属性值:" + propertyValue + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break;
|
||||
case "mousedclick":
|
||||
action.doubleClick(we).perform();
|
||||
result = "mousedclick鼠标双击对象...【对象定位属性:" + property + "; 定位属性值:" + propertyValue + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break;
|
||||
case "mouseclickhold":
|
||||
action.clickAndHold(we).perform();
|
||||
result = "mouseclickhold鼠标点击对象后不释放...【对象定位属性:" + property + "; 定位属性值:" + propertyValue + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break;
|
||||
case "mousedrag":
|
||||
int[] location = getLocationFromParam(operationValue, ",");
|
||||
// String[] temp = operationValue.split(",", -1);
|
||||
action.dragAndDropBy(we, location[0], location[1]).perform();
|
||||
result = "mousedrag鼠标移动至对象相对坐标...【对象定位属性:" + property + "; 定位属性值:" + propertyValue + "; 相对坐标(x,y):" + location[0] + "," + location[1] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break;
|
||||
case "mouseto":
|
||||
int[] location1 = getLocationFromParam(operationValue, ",");
|
||||
// String[] temp1 = operationValue.split(",", -1);
|
||||
action.moveToElement(we, location1[0], location1[1]).perform();
|
||||
result = "mouseto鼠标移动至对象相对坐标...【对象定位属性:" + property + "; 定位属性值:" + propertyValue + "; 相对坐标(x,y):" + location1[0] + "," + location1[1] + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break;
|
||||
case "mouserelease":
|
||||
action.release(we).perform();
|
||||
result = "mouserelease鼠标释放...";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -155,61 +164,61 @@ public class EncapsulateOperation {
|
|||
case "mouselkclick":
|
||||
action.click().perform();
|
||||
result = "mouselkclick鼠标左键点击当前位置...";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break;
|
||||
case "mouserkclick":
|
||||
action.contextClick().perform();
|
||||
result = "mouserkclick鼠标右键点击当前位置...";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break;
|
||||
case "mousedclick":
|
||||
action.doubleClick().perform();
|
||||
result = "mousedclick鼠标双击当前位置...";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break;
|
||||
case "mouseclickhold":
|
||||
action.clickAndHold().perform();
|
||||
result = "mouseclickhold鼠标点击当前位置后不释放...";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break;
|
||||
case "mouseto":
|
||||
int[] location = getLocationFromParam(operationValue, ",");
|
||||
// String[] temp1 = operationValue.split(",", -1);
|
||||
action.moveByOffset(location[0], location[1]).perform();
|
||||
result = "mouseto鼠标移动至对象相对坐标...坐标x:" + location[0] + " 坐标y:" + location[1];
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break;
|
||||
case "mouserelease":
|
||||
action.release().perform();
|
||||
result = "mouserelease鼠标释放...";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break;
|
||||
case "mousekey":
|
||||
switch (operationValue) {
|
||||
case "tab":
|
||||
action.sendKeys(Keys.TAB).perform();
|
||||
result = "键盘操作TAB键...";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break;
|
||||
case "space":
|
||||
action.sendKeys(Keys.SPACE).perform();
|
||||
result = "键盘操作SPACE键...";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break;
|
||||
case "ctrl":
|
||||
action.sendKeys(Keys.CONTROL).perform();
|
||||
result = "键盘操作CONTROL键...";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break;
|
||||
case "shift":
|
||||
action.sendKeys(Keys.SHIFT).perform();
|
||||
result = "键盘操作SHIFT键...";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break;
|
||||
case "enter":
|
||||
action.sendKeys(Keys.ENTER).perform();
|
||||
result = "键盘操作ENTER键...";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -228,30 +237,30 @@ public class EncapsulateOperation {
|
|||
case "click":
|
||||
we.click();
|
||||
result = "click点击对象...【对象定位属性:" + property + "; 定位属性值:" + propertyValue + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break;
|
||||
case "sendkeys":
|
||||
we.sendKeys(operationValue);
|
||||
result = "sendKeys对象输入...【对象定位属性:" + property + "; 定位属性值:" + propertyValue + "; 操作值:" + operationValue + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break;
|
||||
case "clear":
|
||||
we.clear();
|
||||
result = "clear清空输入框...【对象定位属性:" + property + "; 定位属性值:" + propertyValue + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break; // 清空输入框
|
||||
case "gotoframe":
|
||||
wd.switchTo().frame(we);
|
||||
result = "gotoframe切换Frame...【对象定位属性:" + property + "; 定位属性值:" + propertyValue + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break;
|
||||
case "isenabled":
|
||||
result = "获取到的值是【" + we.isEnabled() + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break;
|
||||
case "isdisplayed":
|
||||
result = "获取到的值是【" + we.isDisplayed() + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break;
|
||||
case "exjsob":
|
||||
JavascriptExecutor jse = (JavascriptExecutor) wd;
|
||||
|
@ -291,16 +300,16 @@ public class EncapsulateOperation {
|
|||
case "alertaccept":
|
||||
alert.accept();
|
||||
result = "弹出框对象点击同意...";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break;
|
||||
case "alertdismiss":
|
||||
alert.dismiss();
|
||||
result = "弹出框对象点击取消...";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break;
|
||||
case "alertgettext":
|
||||
result = "获取到的值是【" + alert.getText() + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info("弹出框对象通过getText获取对象text属性...【Text属性值:" + alert.getText() + "】");
|
||||
LogUtil.APP.info("弹出框对象通过getText获取对象text属性...【Text属性值:" + alert.getText() + "】");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -315,14 +324,14 @@ public class EncapsulateOperation {
|
|||
case "open":
|
||||
wd.get(operationValue);
|
||||
result = "Open页面...【" + operationValue + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break;
|
||||
case "addcookie":
|
||||
List<Cookie> cookies = buildCookie(operationValue);
|
||||
if (null != cookies && cookies.size() > 0) {
|
||||
for (Cookie cookie : cookies) {
|
||||
wd.manage().addCookie(cookie);
|
||||
luckyclient.publicclass.LogUtil.APP.info("添加Cookie:【"+cookie+"】成功!");
|
||||
LogUtil.APP.info("添加Cookie:【"+cookie+"】成功!");
|
||||
}
|
||||
}
|
||||
result = "添加cookie...【" + operationValue + "】";
|
||||
|
@ -343,7 +352,7 @@ public class EncapsulateOperation {
|
|||
case "gotodefaultcontent":
|
||||
wd.switchTo().defaultContent();
|
||||
result = "gotodefaultcontent切换至默认页面位置...";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break;
|
||||
case "gotoparentframe":
|
||||
wd.switchTo().parentFrame();
|
||||
|
@ -352,7 +361,7 @@ public class EncapsulateOperation {
|
|||
break;
|
||||
case "gettitle":
|
||||
result = "获取到的值是【" + wd.getTitle() + "】";
|
||||
luckyclient.publicclass.LogUtil.APP.info("获取页面Title...【" + wd.getTitle() + "】");
|
||||
LogUtil.APP.info("获取页面Title...【" + wd.getTitle() + "】");
|
||||
break;
|
||||
case "getwindowhandle":
|
||||
result = getTargetWindowHandle(wd, operationValue);
|
||||
|
@ -371,10 +380,10 @@ public class EncapsulateOperation {
|
|||
// 设置元素出现最大时长30秒
|
||||
wd.manage().timeouts().implicitlyWait(Integer.valueOf(operationValue), TimeUnit.SECONDS);
|
||||
result = "当前任务操作等待【" + operationValue + "】秒...";
|
||||
luckyclient.publicclass.LogUtil.APP.info(result);
|
||||
LogUtil.APP.info(result);
|
||||
break;
|
||||
} catch (NumberFormatException e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("等待时间转换出错!");
|
||||
LogUtil.APP.error("等待时间转换出错!");
|
||||
e.printStackTrace();
|
||||
result = "【等待时间转换出错,请检查参数】";
|
||||
break;
|
||||
|
@ -387,13 +396,13 @@ public class EncapsulateOperation {
|
|||
|
||||
private static List<Cookie> buildCookie(String operationValue) {
|
||||
if (StringUtils.isBlank(operationValue)) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("获取Cookie值:operationValue为空!");
|
||||
LogUtil.APP.info("获取Cookie值:operationValue为空!");
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
JSONArray objects = JSON.parseArray(operationValue);
|
||||
if (null == objects) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("格式化Cookie字符串成JSONArray,对象为空!");
|
||||
LogUtil.APP.info("格式化Cookie字符串成JSONArray,对象为空!");
|
||||
return null;
|
||||
}
|
||||
List<Cookie> result = new ArrayList<>(objects.size());
|
||||
|
@ -410,16 +419,16 @@ public class EncapsulateOperation {
|
|||
//String expire = jsonObject.getString("expire");
|
||||
if (!StringUtils.isBlank(name) && !StringUtils.isBlank(val)) {
|
||||
Cookie cookie = new Cookie(name, val, domain, path, null);
|
||||
luckyclient.publicclass.LogUtil.APP.info("解析Cookie成功:【"+cookie+"】");
|
||||
LogUtil.APP.info("解析Cookie成功:【"+cookie+"】");
|
||||
result.add(cookie);
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.error("cookie:" + jsonObject + "错误,name或是val为空!");
|
||||
LogUtil.APP.warn("cookie:" + jsonObject + "错误,name或是val为空!");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
luckyclient.publicclass.LogUtil.APP.error("格式化Cookie对象出错,请检查您的格式是否正确!【"+operationValue+"】");
|
||||
LogUtil.APP.error("格式化Cookie对象出错,请检查您的格式是否正确!【"+operationValue+"】");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -456,7 +465,7 @@ public class EncapsulateOperation {
|
|||
} else {
|
||||
result = "获取窗口句柄值失败,WebDriver为空";
|
||||
}
|
||||
if (result.contains("获取窗口句柄值失败")) LogUtil.APP.error(result);
|
||||
if (result.contains("获取窗口句柄值失败")) LogUtil.APP.warn(result);
|
||||
else LogUtil.APP.info("获取窗口句柄值成功,目标窗口句柄值为【" + result + "】");
|
||||
return result;
|
||||
}
|
||||
|
@ -549,7 +558,7 @@ public class EncapsulateOperation {
|
|||
try {
|
||||
if (null == Wait(driver).until(windowToBeAvailableAndSwitchToIt(target))) {
|
||||
result = "切换窗口句柄失败,未找到句柄值为【" + target + "】的对象";
|
||||
LogUtil.APP.error(result);
|
||||
LogUtil.APP.warn(result);
|
||||
} else {
|
||||
result = "切换窗口句柄成功,找到句柄值为【" + target + "】的对象";
|
||||
LogUtil.APP.info(result);
|
||||
|
|
|
@ -1,35 +1,13 @@
|
|||
package luckyclient.caserun.exwebdriver;
|
||||
|
||||
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 static void main(String[] args) throws InterruptedException, IOException {
|
||||
// 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);*/
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@ import org.openqa.selenium.firefox.FirefoxDriver;
|
|||
import org.openqa.selenium.firefox.FirefoxOptions;
|
||||
import org.openqa.selenium.ie.InternetExplorerDriver;
|
||||
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
|
@ -38,13 +40,13 @@ public class WebDriverInitialization{
|
|||
File directory = new File("");
|
||||
String drivenpath=directory.getCanonicalPath()+File.separator+"BrowserDriven"+File.separator;
|
||||
WebDriver webDriver = null;
|
||||
luckyclient.publicclass.LogUtil.APP.info("准备初始化WebDriver对象...检查到当前操作系统是:"+os);
|
||||
LogUtil.APP.info("准备初始化WebDriver对象...检查到当前操作系统是:"+os);
|
||||
if(drivertype==0){
|
||||
if(os.startsWith("win")){
|
||||
System.setProperty("webdriver.ie.driver",drivenpath+"IEDriverServer.exe");
|
||||
webDriver = new InternetExplorerDriver();
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.error("当前操作系统无法进行IE浏览器的Web UI测试,请选择火狐或是谷歌浏览器!");
|
||||
LogUtil.APP.warn("当前操作系统无法进行IE浏览器的Web UI测试,请选择火狐或是谷歌浏览器!");
|
||||
}
|
||||
}else if(drivertype==1){
|
||||
FirefoxOptions options = new FirefoxOptions();
|
||||
|
@ -54,7 +56,7 @@ public class WebDriverInitialization{
|
|||
options.addArguments("start-maximized");
|
||||
System.setProperty("webdriver.gecko.driver",drivenpath+"geckodriver_mac");
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.info("检测到当前系统环境是Linux,默认使用headless方式运行Firefox浏览器的Web UI自动化...");
|
||||
LogUtil.APP.info("检测到当前系统环境是Linux,默认使用headless方式运行Firefox浏览器的Web UI自动化...");
|
||||
//无界面参数
|
||||
options.setHeadless(true);
|
||||
//禁用沙盒
|
||||
|
@ -71,7 +73,7 @@ public class WebDriverInitialization{
|
|||
options.addArguments("start-maximized");
|
||||
System.setProperty("webdriver.chrome.driver",drivenpath+"chromedriver_mac");
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.info("检测到当前系统环境是Linux,默认使用headless方式运行Chrome浏览器的Web UI自动化...");
|
||||
LogUtil.APP.info("检测到当前系统环境是Linux,默认使用headless方式运行Chrome浏览器的Web UI自动化...");
|
||||
//无界面参数
|
||||
options.setHeadless(true);
|
||||
//禁用沙盒
|
||||
|
@ -85,11 +87,10 @@ public class WebDriverInitialization{
|
|||
System.setProperty("webdriver.edge.driver",drivenpath+"MicrosoftWebDriver.exe");
|
||||
webDriver = new EdgeDriver();
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.error("当前操作系统无法进行Edge浏览器的Web UI测试,请选择火狐或是谷歌浏览器!");
|
||||
LogUtil.APP.warn("当前操作系统无法进行Edge浏览器的Web UI测试,请选择火狐或是谷歌浏览器!");
|
||||
}
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.error("浏览器类型标识:"+drivertype);
|
||||
luckyclient.publicclass.LogUtil.APP.error("获取到的浏览器类型标识未定义,默认IE浏览器进行执行....");
|
||||
LogUtil.APP.warn("浏览器类型标识:"+drivertype+",获取到的浏览器类型标识未定义,默认IE浏览器进行执行....");
|
||||
System.setProperty("webdriver.ie.driver",drivenpath+"IEDriverServer.exe");
|
||||
webDriver = new InternetExplorerDriver();
|
||||
}
|
||||
|
|
|
@ -4,47 +4,48 @@ import java.io.IOException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import luckyclient.planapi.entity.*;
|
||||
import org.apache.log4j.PropertyConfigurator;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebDriverException;
|
||||
|
||||
import br.eti.kinoshita.testlinkjavaapi.model.TestCase;
|
||||
import luckyclient.caserun.exinterface.TestControl;
|
||||
import luckyclient.caserun.exwebdriver.ex.WebCaseExecution;
|
||||
import luckyclient.caserun.exwebdriver.extestlink.WebCaseExecutionTestLink;
|
||||
import luckyclient.dblog.DbLink;
|
||||
import luckyclient.dblog.LogOperation;
|
||||
import luckyclient.jenkinsapi.BuildingInitialization;
|
||||
import luckyclient.jenkinsapi.RestartServerInitialization;
|
||||
import luckyclient.mail.HtmlMail;
|
||||
import luckyclient.mail.MailSendInitialization;
|
||||
import luckyclient.planapi.api.GetServerAPI;
|
||||
import luckyclient.testlinkapi.TestBuildApi;
|
||||
import luckyclient.testlinkapi.TestCaseApi;
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
import luckyclient.serverapi.api.GetServerAPI;
|
||||
import luckyclient.serverapi.entity.ProjectCase;
|
||||
import luckyclient.serverapi.entity.ProjectCaseParams;
|
||||
import luckyclient.serverapi.entity.ProjectCaseSteps;
|
||||
import luckyclient.serverapi.entity.TaskExecute;
|
||||
import luckyclient.serverapi.entity.TaskScheduling;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||
* =================================================================
|
||||
*
|
||||
* @author: seagull
|
||||
*
|
||||
* @date 2017年12月1日 上午9:29:40
|
||||
*
|
||||
*/
|
||||
public class WebTestControl{
|
||||
|
||||
public class WebTestControl {
|
||||
|
||||
/**
|
||||
* @param args
|
||||
* @throws ClassNotFoundException
|
||||
* 控制台模式调度计划执行用例
|
||||
* 控制台模式调度计划执行用例
|
||||
*/
|
||||
|
||||
public static void manualExecutionPlan(String planname){
|
||||
//不记日志到数据库
|
||||
DbLink.exetype = 1;
|
||||
|
||||
public static void manualExecutionPlan(String planname) {
|
||||
// 不记日志到数据库
|
||||
DbLink.exetype = 1;
|
||||
String taskid = "888888";
|
||||
WebDriver wd = null;
|
||||
try {
|
||||
|
@ -54,134 +55,111 @@ public class WebTestControl{
|
|||
e.printStackTrace();
|
||||
}
|
||||
LogOperation caselog = new LogOperation();
|
||||
List<ProjectCase> testCases=GetServerAPI.getCasesbyplanname(planname);
|
||||
List<PublicCaseParams> pcplist = new ArrayList<PublicCaseParams>();
|
||||
if(testCases.size()!=0){
|
||||
pcplist=GetServerAPI.cgetParamsByProjectid(String.valueOf(testCases.get(0).getProjectid()));
|
||||
List<ProjectCase> testCases = GetServerAPI.getCasesbyplanname(planname);
|
||||
List<ProjectCaseParams> pcplist = new ArrayList<ProjectCaseParams>();
|
||||
if (testCases.size() != 0) {
|
||||
pcplist = GetServerAPI.cgetParamsByProjectid(String.valueOf(testCases.get(0).getProjectId()));
|
||||
}
|
||||
luckyclient.publicclass.LogUtil.APP.info("当前计划中读取到用例共 "+testCases.size()+" 个");
|
||||
int i=0;
|
||||
for(ProjectCase testcase:testCases){
|
||||
List<ProjectCasesteps> steps=GetServerAPI.getStepsbycaseid(testcase.getId());
|
||||
if(steps.size()==0){
|
||||
LogUtil.APP.info("当前计划中读取到用例共 " + testCases.size() + " 个");
|
||||
int i = 0;
|
||||
for (ProjectCase testcase : testCases) {
|
||||
List<ProjectCaseSteps> steps = GetServerAPI.getStepsbycaseid(testcase.getCaseId());
|
||||
if (steps.size() == 0) {
|
||||
continue;
|
||||
}
|
||||
i++;
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始执行第"+i+"条用例:【"+testcase.getSign()+"】......");
|
||||
LogUtil.APP.info("开始执行第" + i + "条用例:【" + testcase.getCaseSign() + "】......");
|
||||
try {
|
||||
//插入开始执行的用例
|
||||
caselog.addCaseDetail(taskid, testcase.getSign(), "1", testcase.getName(), 4);
|
||||
WebCaseExecution.caseExcution(testcase,steps,taskid,wd,caselog,pcplist);
|
||||
WebCaseExecution.caseExcution(testcase, steps, taskid, wd, caselog, pcplist);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||
LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
luckyclient.publicclass.LogUtil.APP.info("当前用例:【"+testcase.getSign()+"】执行完成......进入下一条");
|
||||
LogUtil.APP.info("当前用例:【" + testcase.getCaseSign() + "】执行完成......进入下一条");
|
||||
}
|
||||
luckyclient.publicclass.LogUtil.APP.info("当前项目测试计划中的用例已经全部执行完成...");
|
||||
//关闭浏览器
|
||||
wd.quit();
|
||||
LogUtil.APP.info("当前项目测试计划中的用例已经全部执行完成...");
|
||||
// 关闭浏览器
|
||||
wd.quit();
|
||||
}
|
||||
|
||||
public static void taskExecutionPlan(String taskid,TestTaskexcute task) throws InterruptedException {
|
||||
|
||||
public static void taskExecutionPlan(TaskExecute task) throws InterruptedException {
|
||||
// 记录日志到数据库
|
||||
DbLink.exetype = 0;
|
||||
DbLink.exetype = 0;
|
||||
String taskid = task.getTaskId().toString();
|
||||
TestControl.TASKID = taskid;
|
||||
String restartstatus = RestartServerInitialization.restartServerRun(taskid);
|
||||
String buildstatus = BuildingInitialization.buildingRun(taskid);
|
||||
List<PublicCaseParams> pcplist=GetServerAPI.cgetParamsByProjectid(task.getTestJob().getProjectid().toString());
|
||||
String projectname=task.getTestJob().getPlanproj();
|
||||
task=GetServerAPI.cgetTaskbyid(Integer.valueOf(taskid));
|
||||
String jobname = task.getTestJob().getTaskName();
|
||||
List<ProjectCaseParams> pcplist = GetServerAPI.cgetParamsByProjectid(task.getProjectId().toString());
|
||||
TaskScheduling taskScheduling = GetServerAPI.cGetTaskSchedulingByTaskId(task.getTaskId());
|
||||
String projectname = taskScheduling.getProject().getProjectName();
|
||||
task = GetServerAPI.cgetTaskbyid(Integer.valueOf(taskid));
|
||||
String jobname = taskScheduling.getSchedulingName();
|
||||
int drivertype = LogOperation.querydrivertype(taskid);
|
||||
TestJobs testJob = task.getTestJob();
|
||||
int[] tastcount=null;
|
||||
// 判断是否要自动重启TOMCAT
|
||||
int[] tastcount = null;
|
||||
// 判断是否要自动重启TOMCAT
|
||||
if (restartstatus.indexOf("Status:true") > -1) {
|
||||
// 判断是否构建是否成功
|
||||
if (buildstatus.indexOf("Status:true") > -1) {
|
||||
WebDriver wd = null;
|
||||
try {
|
||||
wd = WebDriverInitialization.setWebDriverForTask(drivertype);
|
||||
wd = WebDriverInitialization.setWebDriverForTask(drivertype);
|
||||
} catch (WebDriverException e1) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("初始化WebDriver出错 WebDriverException!", e1);
|
||||
LogUtil.APP.error("初始化WebDriver出错 WebDriverException!", e1);
|
||||
e1.printStackTrace();
|
||||
} catch (IOException e2) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("初始化WebDriver出错 IOException!", e2);
|
||||
LogUtil.APP.error("初始化WebDriver出错 IOException!", e2);
|
||||
e2.printStackTrace();
|
||||
}
|
||||
LogOperation caselog = new LogOperation();
|
||||
LogOperation caselog = new LogOperation();
|
||||
|
||||
if(task.getTestJob().getProjecttype()==1){
|
||||
TestBuildApi.getBuild(projectname);
|
||||
TestCase[] testCases = TestCaseApi.getplantestcase(projectname, taskid,"");
|
||||
luckyclient.publicclass.LogUtil.APP.info("当前计划中读取到用例共 " + testCases.length + " 个");
|
||||
LogOperation.updateTastStatus(taskid,testCases.length);
|
||||
|
||||
for (TestCase testcase : testCases) {
|
||||
if (testcase.getSteps().size() == 0) {
|
||||
continue;
|
||||
}
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始执行用例:【" + testcase.getFullExternalId() + "】......");
|
||||
try {
|
||||
WebCaseExecutionTestLink.caseExcution(projectname, testcase, taskid, wd, caselog);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
luckyclient.publicclass.LogUtil.APP.info("当前用例:【" + testcase.getFullExternalId() + "】执行完成......进入下一条");
|
||||
List<ProjectCase> cases = GetServerAPI.getCasesbyplanId(taskScheduling.getPlanId());
|
||||
LogUtil.APP.info("当前计划中读取到用例共 " + cases.size() + " 个");
|
||||
LogOperation.updateTaskExecuteStatus(taskid, cases.size());
|
||||
|
||||
for (ProjectCase testcase : cases) {
|
||||
List<ProjectCaseSteps> steps = GetServerAPI.getStepsbycaseid(testcase.getCaseId());
|
||||
if (steps.size() == 0) {
|
||||
continue;
|
||||
}
|
||||
tastcount = LogOperation.updateTastdetail(taskid, testCases.length);
|
||||
}else if(task.getTestJob().getProjecttype()==0){
|
||||
List<ProjectCase> cases=GetServerAPI.getCasesbyplanid(task.getTestJob().getPlanid());
|
||||
luckyclient.publicclass.LogUtil.APP.info("当前计划中读取到用例共 " + cases.size() + " 个");
|
||||
LogOperation.updateTastStatus(taskid,cases.size());
|
||||
|
||||
for (ProjectCase testcase : cases) {
|
||||
List<ProjectCasesteps> steps=GetServerAPI.getStepsbycaseid(testcase.getId());
|
||||
if (steps.size() == 0) {
|
||||
continue;
|
||||
}
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始执行用例:【" + testcase.getSign() + "】......");
|
||||
try {
|
||||
//插入开始执行的用例
|
||||
caselog.addCaseDetail(taskid, testcase.getSign(), "1", testcase.getName(), 4);
|
||||
WebCaseExecution.caseExcution(testcase, steps, taskid, wd, caselog,pcplist);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
luckyclient.publicclass.LogUtil.APP.info("当前用例:【" + testcase.getSign() + "】执行完成......进入下一条");
|
||||
LogUtil.APP.info("开始执行用例:【" + testcase.getCaseSign() + "】......");
|
||||
try {
|
||||
// 插入开始执行的用例
|
||||
caselog.insertTaskCaseExecute(taskid, taskScheduling.getProjectId(),testcase.getCaseId(),testcase.getCaseSign(), testcase.getCaseName(), 4);
|
||||
WebCaseExecution.caseExcution(testcase, steps, taskid, wd, caselog, pcplist);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
tastcount = LogOperation.updateTastdetail(taskid, cases.size());
|
||||
LogUtil.APP.info("当前用例:【" + testcase.getCaseSign() + "】执行完成......进入下一条");
|
||||
}
|
||||
tastcount = LogOperation.updateTaskExecuteData(taskid, cases.size());
|
||||
|
||||
String testtime = LogOperation.getTestTime(taskid);
|
||||
luckyclient.publicclass.LogUtil.APP.info("当前项目【" + projectname + "】测试计划中的用例已经全部执行完成...");
|
||||
LogUtil.APP.info("当前项目【" + projectname + "】测试计划中的用例已经全部执行完成...");
|
||||
MailSendInitialization.sendMailInitialization(HtmlMail.htmlSubjectFormat(jobname),
|
||||
HtmlMail.htmlContentFormat(tastcount, taskid, buildstatus, restartstatus, testtime,jobname), taskid, testJob, tastcount);
|
||||
HtmlMail.htmlContentFormat(tastcount, taskid, buildstatus, restartstatus, testtime, jobname),
|
||||
taskid, taskScheduling, tastcount);
|
||||
// 关闭浏览器
|
||||
wd.quit();
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("项目构建失败,自动化测试自动退出!请前往JENKINS中检查项目构建情况。");
|
||||
MailSendInitialization.sendMailInitialization(jobname,
|
||||
"构建项目过程中失败,自动化测试自动退出!请前去JENKINS查看构建情况!", taskid, testJob, tastcount);
|
||||
LogUtil.APP.warn("项目构建失败,自动化测试自动退出!请前往JENKINS中检查项目构建情况。");
|
||||
MailSendInitialization.sendMailInitialization(jobname, "构建项目过程中失败,自动化测试自动退出!请前去JENKINS查看构建情况!", taskid,
|
||||
taskScheduling, tastcount);
|
||||
}
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("项目TOMCAT重启失败,自动化测试自动退出!请检查项目TOMCAT运行情况。");
|
||||
MailSendInitialization.sendMailInitialization(jobname,
|
||||
"项目TOMCAT重启失败,自动化测试自动退出!请检查项目TOMCAT运行情况!", taskid, testJob, tastcount);
|
||||
LogUtil.APP.warn("项目TOMCAT重启失败,自动化测试自动退出!请检查项目TOMCAT运行情况。");
|
||||
MailSendInitialization.sendMailInitialization(jobname, "项目TOMCAT重启失败,自动化测试自动退出!请检查项目TOMCAT运行情况!", taskid,
|
||||
taskScheduling, tastcount);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
try {
|
||||
PropertyConfigurator.configure(System.getProperty("user.dir")
|
||||
+ "\\log4j.conf");
|
||||
//ManualExecutionPlan("automation test");
|
||||
PropertyConfigurator.configure(System.getProperty("user.dir") + "\\log4j.conf");
|
||||
// ManualExecutionPlan("automation test");
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -10,11 +10,12 @@ import luckyclient.caserun.exinterface.TestControl;
|
|||
import luckyclient.caserun.exwebdriver.WebDriverInitialization;
|
||||
import luckyclient.dblog.DbLink;
|
||||
import luckyclient.dblog.LogOperation;
|
||||
import luckyclient.planapi.api.GetServerAPI;
|
||||
import luckyclient.planapi.entity.ProjectCase;
|
||||
import luckyclient.planapi.entity.ProjectCasesteps;
|
||||
import luckyclient.planapi.entity.PublicCaseParams;
|
||||
import luckyclient.planapi.entity.TestTaskexcute;
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
import luckyclient.serverapi.api.GetServerAPI;
|
||||
import luckyclient.serverapi.entity.ProjectCase;
|
||||
import luckyclient.serverapi.entity.ProjectCaseParams;
|
||||
import luckyclient.serverapi.entity.ProjectCaseSteps;
|
||||
import luckyclient.serverapi.entity.TaskExecute;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
@ -42,46 +43,41 @@ public class WebBatchExecute{
|
|||
e1.printStackTrace();
|
||||
}
|
||||
LogOperation caselog = new LogOperation();
|
||||
TestTaskexcute task=GetServerAPI.cgetTaskbyid(Integer.valueOf(taskid));
|
||||
List<PublicCaseParams> pcplist=GetServerAPI.cgetParamsByProjectid(task.getTestJob().getProjectid().toString());
|
||||
TaskExecute task=GetServerAPI.cgetTaskbyid(Integer.valueOf(taskid));
|
||||
List<ProjectCaseParams> pcplist=GetServerAPI.cgetParamsByProjectid(task.getProjectId().toString());
|
||||
//执行全部非成功状态用例
|
||||
if(batchcase.indexOf("ALLFAIL")>-1){
|
||||
String casemore = caselog.unSucCaseUpdate(taskid);
|
||||
String[] temp=casemore.split("\\#",-1);
|
||||
for(int i=0;i<temp.length;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.getId());
|
||||
List<Integer> caseIdList = caselog.getCaseListForUnSucByTaskId(taskid);
|
||||
for(int i=0;i<caseIdList.size();i++){
|
||||
ProjectCase testcase = GetServerAPI.cGetCaseByCaseId(caseIdList.get(i));
|
||||
List<ProjectCaseSteps> steps=GetServerAPI.getStepsbycaseid(testcase.getCaseId());
|
||||
//删除旧的日志
|
||||
LogOperation.deleteCaseLogDetail(testCaseExternalId, taskid);
|
||||
LogOperation.deleteTaskCaseLog(testcase.getCaseId(), taskid);
|
||||
try {
|
||||
WebCaseExecution.caseExcution(testcase, steps, taskid,wd,caselog,pcplist);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||
LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}else{ //批量执行用例
|
||||
String[] temp=batchcase.split("\\#",-1);
|
||||
String[] temp=batchcase.split("\\#");
|
||||
for(int i=0;i<temp.length;i++){
|
||||
String testCaseExternalId = temp[i].substring(0, temp[i].indexOf("%"));
|
||||
//int version = Integer.parseInt(temp[i].substring(temp[i].indexOf("%")+1,temp[i].length()));
|
||||
ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId);
|
||||
List<ProjectCasesteps> steps=GetServerAPI.getStepsbycaseid(testcase.getId());
|
||||
ProjectCase testcase = GetServerAPI.cGetCaseByCaseId(Integer.valueOf(temp[i]));
|
||||
List<ProjectCaseSteps> steps=GetServerAPI.getStepsbycaseid(testcase.getCaseId());
|
||||
//删除旧的日志
|
||||
LogOperation.deleteCaseLogDetail(testCaseExternalId, taskid);
|
||||
LogOperation.deleteTaskCaseLog(testcase.getCaseId(), taskid);
|
||||
try {
|
||||
WebCaseExecution.caseExcution(testcase, steps,taskid,wd,caselog,pcplist);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||
LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
LogOperation.updateTastdetail(taskid, 0);
|
||||
LogOperation.updateTaskExecuteData(taskid, 0);
|
||||
//关闭浏览器
|
||||
wd.quit();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,16 @@
|
|||
package luckyclient.caserun.exwebdriver.ex;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
|
||||
import luckyclient.caserun.exinterface.TestCaseExecution;
|
||||
import luckyclient.caserun.exinterface.analyticsteps.InterfaceAnalyticCase;
|
||||
import luckyclient.caserun.exwebdriver.BaseWebDrive;
|
||||
|
@ -8,20 +19,10 @@ import luckyclient.caserun.publicdispose.ActionManageForSteps;
|
|||
import luckyclient.caserun.publicdispose.ChangString;
|
||||
import luckyclient.caserun.publicdispose.ParamsManageForSteps;
|
||||
import luckyclient.dblog.LogOperation;
|
||||
import luckyclient.planapi.entity.ProjectCase;
|
||||
import luckyclient.planapi.entity.ProjectCasesteps;
|
||||
import luckyclient.planapi.entity.PublicCaseParams;
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import luckyclient.serverapi.entity.ProjectCase;
|
||||
import luckyclient.serverapi.entity.ProjectCaseParams;
|
||||
import luckyclient.serverapi.entity.ProjectCaseSteps;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
@ -38,21 +39,22 @@ public class WebCaseExecution extends TestCaseExecution {
|
|||
private static String casenote = "备注初始化";
|
||||
private static String imagname = "";
|
||||
|
||||
public static void caseExcution(ProjectCase testcase, List<ProjectCasesteps> steps, String taskid, WebDriver wd, LogOperation caselog, List<PublicCaseParams> pcplist) throws InterruptedException {
|
||||
// 把公共参数加入到MAP中
|
||||
for (PublicCaseParams pcp : pcplist) {
|
||||
variable.put(pcp.getParamsname(), pcp.getParamsvalue());
|
||||
public static void caseExcution(ProjectCase testcase, List<ProjectCaseSteps> steps, String taskid, WebDriver wd, LogOperation caselog, List<ProjectCaseParams> pcplist) throws InterruptedException {
|
||||
caselog.updateTaskCaseExecuteStatus(taskid, testcase.getCaseId(), 3);
|
||||
// 把公共参数加入到MAP中
|
||||
for (ProjectCaseParams pcp : pcplist) {
|
||||
variable.put(pcp.getParamsName(), pcp.getParamsValue());
|
||||
}
|
||||
// 加入全局变量
|
||||
variable.putAll(ParamsManageForSteps.GLOBAL_VARIABLE);
|
||||
// 0:成功 1:失败 2:锁定 其他:锁定
|
||||
int setcaseresult = 0;
|
||||
for (ProjectCasesteps step : steps) {
|
||||
for (ProjectCaseSteps step : steps) {
|
||||
Map<String, String> params;
|
||||
String result;
|
||||
|
||||
// 根据步骤类型来分析步骤参数
|
||||
if (1 == step.getSteptype()){
|
||||
if (1 == step.getStepType()){
|
||||
params = WebDriverAnalyticCase.analyticCaseStep(testcase, step, taskid, caselog);
|
||||
}else{
|
||||
params = InterfaceAnalyticCase.analyticCaseStep(testcase, step, taskid, caselog);
|
||||
|
@ -65,10 +67,10 @@ public class WebCaseExecution extends TestCaseExecution {
|
|||
}
|
||||
|
||||
// 根据步骤类型来执行步骤
|
||||
if (1 == step.getSteptype()){
|
||||
result = runWebStep(params, variable, wd, taskid, testcase.getSign(), step.getStepnum(), caselog);
|
||||
if (1 == step.getStepType()){
|
||||
result = runWebStep(params, variable, wd, taskid, testcase.getCaseId(), step.getStepSerialNumber(), caselog);
|
||||
}else{
|
||||
result = TestCaseExecution.runStep(params, variable, taskid, testcase.getSign(), step, caselog);
|
||||
result = TestCaseExecution.runStep(params, variable, taskid, testcase.getCaseSign(), step, caselog);
|
||||
}
|
||||
|
||||
String expectedResults = params.get("ExpectedResults");
|
||||
|
@ -80,26 +82,26 @@ public class WebCaseExecution extends TestCaseExecution {
|
|||
if (0 != stepresult) {
|
||||
setcaseresult = stepresult;
|
||||
if (testcase.getFailcontinue() == 0) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcase.getSign()+"】第【"+step.getStepnum()+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
||||
LogUtil.APP.warn("用例【"+testcase.getCaseSign()+"】第【"+step.getStepSerialNumber()+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
||||
break;
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcase.getSign()+"】第【"+step.getStepnum()+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
||||
LogUtil.APP.warn("用例【"+testcase.getCaseSign()+"】第【"+step.getStepSerialNumber()+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
variable.clear();
|
||||
caselog.updateCaseDetail(taskid, testcase.getSign(), setcaseresult);
|
||||
caselog.updateTaskCaseExecuteStatus(taskid, testcase.getCaseId(), setcaseresult);
|
||||
if (setcaseresult == 0) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例【" + testcase.getSign() + "】全部步骤执行结果成功...");
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "用例全部步骤执行结果成功", "info", "ending", "");
|
||||
LogUtil.APP.info("用例【" + testcase.getCaseSign() + "】全部步骤执行结果成功...");
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "用例全部步骤执行结果成功", "info", "ending", "");
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【" + testcase.getSign() + "】步骤执行过程中失败或是锁定...请查看具体原因!" + casenote);
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "用例执行过程中失败或是锁定" + casenote, "error", "ending", "");
|
||||
LogUtil.APP.warn("用例【" + testcase.getCaseSign() + "】步骤执行过程中失败或是锁定...请查看具体原因!" + casenote);
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "用例执行过程中失败或是锁定" + casenote, "error", "ending", "");
|
||||
}
|
||||
}
|
||||
|
||||
public static String runWebStep(Map<String, String> params, Map<String, String> variable, WebDriver wd, String taskid, String casenum, int stepno, LogOperation caselog) {
|
||||
public static String runWebStep(Map<String, String> params, Map<String, String> variable, WebDriver wd, String taskid, Integer caseId, int stepno, LogOperation caselog) {
|
||||
String result = "";
|
||||
String property;
|
||||
String propertyValue;
|
||||
|
@ -118,11 +120,11 @@ public class WebCaseExecution extends TestCaseExecution {
|
|||
operation = ChangString.changparams(operation, variable, "操作");
|
||||
operationValue = ChangString.changparams(operationValue, variable, "操作参数");
|
||||
|
||||
luckyclient.publicclass.LogUtil.APP.info("二次解析用例过程完成,等待进行对象操作......");
|
||||
caselog.caseLogDetail(taskid, casenum, "对象操作:" + operation + "; 操作值:" + operationValue, "info", String.valueOf(stepno), "");
|
||||
LogUtil.APP.info("二次解析用例过程完成,等待进行对象操作......");
|
||||
caselog.insertTaskCaseLog(taskid, caseId, "对象操作:" + operation + "; 操作值:" + operationValue, "info", String.valueOf(stepno), "");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
luckyclient.publicclass.LogUtil.APP.error("二次解析用例过程抛出异常!---" + e.getMessage());
|
||||
LogUtil.APP.error("二次解析用例过程抛出异常!---" + e.getMessage());
|
||||
return "步骤执行失败:解析用例失败!";
|
||||
}
|
||||
|
||||
|
@ -143,7 +145,7 @@ public class WebCaseExecution extends TestCaseExecution {
|
|||
WebElement we = isElementExist(wd, property, propertyValue);
|
||||
// 判断此元素是否存在
|
||||
if (null == we) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("定位对象失败,isElementExist为null!");
|
||||
LogUtil.APP.warn("定位对象失败,isElementExist为null!");
|
||||
return "步骤执行失败:定位的元素不存在!";
|
||||
}
|
||||
|
||||
|
@ -167,16 +169,16 @@ public class WebCaseExecution extends TestCaseExecution {
|
|||
result = EncapsulateOperation.driverOperation(wd, operation, operationValue);
|
||||
}
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("元素操作过程失败!");
|
||||
LogUtil.APP.warn("元素操作过程失败!");
|
||||
result = "步骤执行失败:元素操作过程失败!";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("元素定位过程或是操作过程失败或异常!" + e.getMessage());
|
||||
LogUtil.APP.error("元素定位过程或是操作过程失败或异常!" + e.getMessage());
|
||||
return "步骤执行失败:元素定位过程或是操作过程失败或异常!" + e.getMessage();
|
||||
}
|
||||
|
||||
if (result.contains("步骤执行失败:")) caselog.caseLogDetail(taskid, casenum, result, "error", String.valueOf(stepno), "");
|
||||
else caselog.caseLogDetail(taskid, casenum, result, "info", String.valueOf(stepno), "");
|
||||
if (result.contains("步骤执行失败:")) caselog.insertTaskCaseLog(taskid, caseId, result, "error", String.valueOf(stepno), "");
|
||||
else caselog.insertTaskCaseLog(taskid, caseId, result, "info", String.valueOf(stepno), "");
|
||||
|
||||
if (result.contains("获取到的值是【") && result.contains("】")) {
|
||||
result = result.substring(result.indexOf("获取到的值是【") + "获取到的值是【".length(), result.length() - 1);
|
||||
|
@ -216,13 +218,13 @@ public class WebCaseExecution extends TestCaseExecution {
|
|||
return we;
|
||||
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("当前对象定位失败:" + e.getMessage());
|
||||
LogUtil.APP.error("当前对象定位失败:" + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int judgeResult(ProjectCase testcase, ProjectCasesteps step, Map<String, String> params, WebDriver driver, String taskid, String expect, String result, LogOperation caselog) throws InterruptedException {
|
||||
public static int judgeResult(ProjectCase testcase, ProjectCaseSteps step, Map<String, String> params, WebDriver driver, String taskid, String expect, String result, LogOperation caselog) throws InterruptedException {
|
||||
int setresult = 0;
|
||||
java.text.DateFormat timeformat = new java.text.SimpleDateFormat("MMdd-hhmmss");
|
||||
imagname = timeformat.format(new Date());
|
||||
|
@ -231,35 +233,35 @@ public class WebCaseExecution extends TestCaseExecution {
|
|||
if (null != result && !result.contains("步骤执行失败:")) {
|
||||
// 有预期结果
|
||||
if (null != expect && !expect.isEmpty()) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("期望结果为【" + expect + "】");
|
||||
LogUtil.APP.info("期望结果为【" + expect + "】");
|
||||
// 赋值传参模式
|
||||
if (expect.length() > ASSIGNMENT_SIGN.length() && expect.startsWith(ASSIGNMENT_SIGN)) {
|
||||
variable.put(expect.substring(ASSIGNMENT_SIGN.length()), result);
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,将测试结果【" + result + "】赋值给变量【" + expect.substring(ASSIGNMENT_SIGN.length()) + "】");
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "将测试结果【" + result + "】赋值给变量【" + expect.substring(ASSIGNMENT_SIGN.length()) + "】", "info", String.valueOf(step.getStepnum()), "");
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,将测试结果【" + result + "】赋值给变量【" + expect.substring(ASSIGNMENT_SIGN.length()) + "】");
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "将测试结果【" + result + "】赋值给变量【" + expect.substring(ASSIGNMENT_SIGN.length()) + "】", "info", String.valueOf(step.getStepSerialNumber()), "");
|
||||
}
|
||||
// 赋值全局变量
|
||||
else if (expect.length() > ASSIGNMENT_GLOBALSIGN.length() && expect.startsWith(ASSIGNMENT_GLOBALSIGN)) {
|
||||
variable.put(expect.substring(ASSIGNMENT_GLOBALSIGN.length()), result);
|
||||
ParamsManageForSteps.GLOBAL_VARIABLE.put(expect.substring(ASSIGNMENT_GLOBALSIGN.length()), result);
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,将测试结果【" + result + "】赋值给全局变量【" + expect.substring(ASSIGNMENT_GLOBALSIGN.length()) + "】");
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "将测试结果【" + result + "】赋值给全局变量【" + expect.substring(ASSIGNMENT_GLOBALSIGN.length()) + "】", "info", String.valueOf(step.getStepnum()), "");
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,将测试结果【" + result + "】赋值给全局变量【" + expect.substring(ASSIGNMENT_GLOBALSIGN.length()) + "】");
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "将测试结果【" + result + "】赋值给全局变量【" + expect.substring(ASSIGNMENT_GLOBALSIGN.length()) + "】", "info", String.valueOf(step.getStepSerialNumber()), "");
|
||||
}
|
||||
// WebUI检查模式
|
||||
else if (1 == step.getSteptype() && params.get("checkproperty") != null && params.get("checkproperty_value") != null) {
|
||||
else if (1 == step.getStepType() && params.get("checkproperty") != null && params.get("checkproperty_value") != null) {
|
||||
String checkproperty = params.get("checkproperty");
|
||||
String checkPropertyValue = params.get("checkproperty_value");
|
||||
|
||||
WebElement we = isElementExist(driver, checkproperty, checkPropertyValue);
|
||||
if (null != we) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,在当前页面中找到预期结果中对象。当前步骤执行成功!");
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "在当前页面中找到预期结果中对象。当前步骤执行成功!", "info", String.valueOf(step.getStepnum()), "");
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,在当前页面中找到预期结果中对象。当前步骤执行成功!");
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "在当前页面中找到预期结果中对象。当前步骤执行成功!", "info", String.valueOf(step.getStepSerialNumber()), "");
|
||||
} else {
|
||||
casenote = "第" + step.getStepnum() + "步,没有在当前页面中找到预期结果中对象。执行失败!";
|
||||
casenote = "第" + step.getStepSerialNumber() + "步,没有在当前页面中找到预期结果中对象。执行失败!";
|
||||
setresult = 1;
|
||||
BaseWebDrive.webScreenShot(driver, imagname);
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,没有在当前页面中找到预期结果中对象。当前步骤执行失败!");
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "在当前页面中没有找到预期结果中对象。当前步骤执行失败!" + "checkproperty【" + checkproperty + "】 checkproperty_value【" + checkPropertyValue + "】", "error", String.valueOf(step.getStepnum()), imagname);
|
||||
LogUtil.APP.warn("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,没有在当前页面中找到预期结果中对象。当前步骤执行失败!");
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "在当前页面中没有找到预期结果中对象。当前步骤执行失败!" + "checkproperty【" + checkproperty + "】 checkproperty_value【" + checkPropertyValue + "】", "error", String.valueOf(step.getStepSerialNumber()), imagname);
|
||||
}
|
||||
}
|
||||
// 其它匹配模式
|
||||
|
@ -267,14 +269,14 @@ public class WebCaseExecution extends TestCaseExecution {
|
|||
// 模糊匹配预期结果模式
|
||||
if (expect.length() > FUZZY_MATCHING_SIGN.length() && expect.startsWith(FUZZY_MATCHING_SIGN)) {
|
||||
if (result.contains(expect.substring(FUZZY_MATCHING_SIGN.length()))) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,模糊匹配预期结果成功!执行结果:" + result);
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "模糊匹配预期结果成功!执行结果:" + result, "info", String.valueOf(step.getStepnum()), "");
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,模糊匹配预期结果成功!执行结果:" + result);
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "模糊匹配预期结果成功!执行结果:" + result, "info", String.valueOf(step.getStepSerialNumber()), "");
|
||||
} else {
|
||||
casenote = "第" + step.getStepnum() + "步,模糊匹配预期结果失败!";
|
||||
casenote = "第" + step.getStepSerialNumber() + "步,模糊匹配预期结果失败!";
|
||||
setresult = 1;
|
||||
BaseWebDrive.webScreenShot(driver, imagname);
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,模糊匹配预期结果失败!预期结果:" + expect.substring(FUZZY_MATCHING_SIGN.length()) + ",测试结果:" + result);
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "模糊匹配预期结果失败!预期结果:" + expect.substring(FUZZY_MATCHING_SIGN.length()) + ",测试结果:" + result, "error", String.valueOf(step.getStepnum()), imagname);
|
||||
LogUtil.APP.warn("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,模糊匹配预期结果失败!预期结果:" + expect.substring(FUZZY_MATCHING_SIGN.length()) + ",测试结果:" + result);
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "模糊匹配预期结果失败!预期结果:" + expect.substring(FUZZY_MATCHING_SIGN.length()) + ",测试结果:" + result, "error", String.valueOf(step.getStepSerialNumber()), imagname);
|
||||
}
|
||||
}
|
||||
// 正则匹配预期结果模式
|
||||
|
@ -282,27 +284,27 @@ public class WebCaseExecution extends TestCaseExecution {
|
|||
Pattern pattern = Pattern.compile(expect.substring(REGULAR_MATCHING_SIGN.length()));
|
||||
Matcher matcher = pattern.matcher(result);
|
||||
if (matcher.find()) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,正则匹配预期结果成功!执行结果:" + result);
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "正则匹配预期结果成功!", "info", String.valueOf(step.getStepnum()), "");
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,正则匹配预期结果成功!执行结果:" + result);
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "正则匹配预期结果成功!", "info", String.valueOf(step.getStepSerialNumber()), "");
|
||||
} else {
|
||||
casenote = "第" + step.getStepnum() + "步,正则匹配预期结果失败!";
|
||||
casenote = "第" + step.getStepSerialNumber() + "步,正则匹配预期结果失败!";
|
||||
setresult = 1;
|
||||
BaseWebDrive.webScreenShot(driver, imagname);
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,正则匹配预期结果失败!预期结果:" + expect.substring(REGULAR_MATCHING_SIGN.length()) + ",测试结果:" + result);
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "正则匹配预期结果失败!预期结果:" + expect.substring(REGULAR_MATCHING_SIGN.length()) + ",测试结果:" + result, "error", String.valueOf(step.getStepnum()), imagname);
|
||||
LogUtil.APP.warn("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,正则匹配预期结果失败!预期结果:" + expect.substring(REGULAR_MATCHING_SIGN.length()) + ",测试结果:" + result);
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "正则匹配预期结果失败!预期结果:" + expect.substring(REGULAR_MATCHING_SIGN.length()) + ",测试结果:" + result, "error", String.valueOf(step.getStepSerialNumber()), imagname);
|
||||
}
|
||||
}
|
||||
// 精确匹配预期结果模式
|
||||
else {
|
||||
if (expect.equals(result)) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,精确匹配预期结果成功!执行结果:" + result);
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "精确匹配预期结果成功!", "info", String.valueOf(step.getStepnum()), "");
|
||||
LogUtil.APP.info("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,精确匹配预期结果成功!执行结果:" + result);
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "精确匹配预期结果成功!", "info", String.valueOf(step.getStepSerialNumber()), "");
|
||||
} else {
|
||||
casenote = "第" + step.getStepnum() + "步,精确匹配预期结果失败!";
|
||||
casenote = "第" + step.getStepSerialNumber() + "步,精确匹配预期结果失败!";
|
||||
setresult = 1;
|
||||
BaseWebDrive.webScreenShot(driver, imagname);
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,精确匹配预期结果失败!预期结果是:【"+expect+"】 执行结果:【"+ result+"】");
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "精确匹配预期结果失败!预期结果是:【"+expect+"】 执行结果:【"+ result+"】", "error", String.valueOf(step.getStepnum()), imagname);
|
||||
LogUtil.APP.warn("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,精确匹配预期结果失败!预期结果是:【"+expect+"】 执行结果:【"+ result+"】");
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "精确匹配预期结果失败!预期结果是:【"+expect+"】 执行结果:【"+ result+"】", "error", String.valueOf(step.getStepSerialNumber()), imagname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -311,15 +313,11 @@ public class WebCaseExecution extends TestCaseExecution {
|
|||
casenote = (null != result) ? result : "";
|
||||
setresult = 2;
|
||||
BaseWebDrive.webScreenShot(driver, imagname);
|
||||
LogUtil.APP.error("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,执行结果:" + casenote);
|
||||
caselog.caseLogDetail(taskid, testcase.getSign(), "当前步骤在执行过程中解析|定位元素|操作对象失败!" + casenote, "error", String.valueOf(step.getStepnum()), imagname);
|
||||
LogUtil.APP.warn("用例:" + testcase.getCaseSign() + " 第" + step.getStepSerialNumber() + "步,执行结果:" + casenote);
|
||||
caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "当前步骤在执行过程中解析|定位元素|操作对象失败!" + casenote, "error", String.valueOf(step.getStepSerialNumber()), imagname);
|
||||
}
|
||||
|
||||
return setresult;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
}
|
|
@ -6,8 +6,9 @@ import java.util.regex.Matcher;
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
import luckyclient.dblog.LogOperation;
|
||||
import luckyclient.planapi.entity.ProjectCase;
|
||||
import luckyclient.planapi.entity.ProjectCasesteps;
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
import luckyclient.serverapi.entity.ProjectCase;
|
||||
import luckyclient.serverapi.entity.ProjectCaseSteps;
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
|
@ -33,29 +34,29 @@ public class WebDriverAnalyticCase {
|
|||
* @author Seagull
|
||||
* @date 2019年1月17日
|
||||
*/
|
||||
public static Map<String,String> analyticCaseStep(ProjectCase projectcase,ProjectCasesteps step,String taskid,LogOperation caselog){
|
||||
public static Map<String,String> analyticCaseStep(ProjectCase projectcase,ProjectCaseSteps step,String taskid,LogOperation caselog){
|
||||
Map<String,String> params = new HashMap<String,String>(0);
|
||||
|
||||
String resultstr = null;
|
||||
try {
|
||||
if(null!=step.getPath()&&step.getPath().indexOf("=")>-1){
|
||||
String property = step.getPath().substring(0, step.getPath().indexOf("="));
|
||||
String propertyValue = step.getPath().substring(step.getPath().indexOf("=")+1, step.getPath().length());
|
||||
if(null!=step.getStepPath()&&step.getStepPath().indexOf("=")>-1){
|
||||
String property = step.getStepPath().substring(0, step.getStepPath().indexOf("="));
|
||||
String propertyValue = step.getStepPath().substring(step.getStepPath().indexOf("=")+1, step.getStepPath().length());
|
||||
//set属性
|
||||
params.put("property", property.trim().toLowerCase());
|
||||
//set属性值
|
||||
params.put("property_value", propertyValue.trim());
|
||||
luckyclient.publicclass.LogUtil.APP.info("对象属性解析结果:property:"+property.trim()+"; property_value:"+propertyValue.trim());
|
||||
LogUtil.APP.info("对象属性解析结果:property:"+property.trim()+"; property_value:"+propertyValue.trim());
|
||||
}
|
||||
//set操作方法
|
||||
params.put("operation", step.getOperation().toLowerCase());
|
||||
if(null!=step.getParameters()&&!"".equals(step.getParameters())){
|
||||
params.put("operation", step.getStepOperation().toLowerCase());
|
||||
if(null!=step.getStepParameters()&&!"".equals(step.getStepParameters())){
|
||||
//set属性值
|
||||
params.put("operation_value", step.getParameters());
|
||||
params.put("operation_value", step.getStepParameters());
|
||||
}
|
||||
luckyclient.publicclass.LogUtil.APP.info("对象操作解析结果:operation:"+step.getOperation().toLowerCase()+"; operation_value:"+step.getParameters());
|
||||
LogUtil.APP.info("对象操作解析结果:operation:"+step.getStepOperation().toLowerCase()+"; operation_value:"+step.getStepParameters());
|
||||
//获取预期结果字符串
|
||||
resultstr = step.getExpectedresult();
|
||||
resultstr = step.getExpectedResult();
|
||||
|
||||
//set预期结果
|
||||
if(null==resultstr||"".equals(resultstr)){
|
||||
|
@ -70,20 +71,19 @@ public class WebDriverAnalyticCase {
|
|||
params.put("checkproperty_value", expectedResults.substring(expectedResults.indexOf("=")+1, expectedResults.lastIndexOf(")")));
|
||||
}
|
||||
params.put("ExpectedResults", expectedResults);
|
||||
luckyclient.publicclass.LogUtil.APP.info("预期结果解析:ExpectedResults:"+expectedResults);
|
||||
LogUtil.APP.info("预期结果解析:ExpectedResults:"+expectedResults);
|
||||
}
|
||||
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例编号:"+projectcase.getSign()+" 步骤编号:"+step.getStepnum()+" 解析自动化用例步骤脚本完成!");
|
||||
LogUtil.APP.info("用例编号:"+projectcase.getCaseSign()+" 步骤编号:"+step.getStepSerialNumber()+" 解析自动化用例步骤脚本完成!");
|
||||
if(null!=caselog){
|
||||
caselog.caseLogDetail(taskid, projectcase.getSign(),"步骤编号:"+step.getStepnum()+" 解析自动化用例步骤脚本完成!","info",String.valueOf(step.getStepnum()),"");
|
||||
caselog.insertTaskCaseLog(taskid, projectcase.getCaseId(),"步骤编号:"+step.getStepSerialNumber()+" 解析自动化用例步骤脚本完成!","info",String.valueOf(step.getStepSerialNumber()),"");
|
||||
}
|
||||
}catch(Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例编号:"+projectcase.getSign()+" 步骤编号:"+step.getStepnum()+" 解析自动化用例步骤脚本出错!");
|
||||
LogUtil.APP.error("用例编号:"+projectcase.getCaseSign()+" 步骤编号:"+step.getStepSerialNumber()+" 解析自动化用例步骤脚本出错!",e);
|
||||
if(null!=caselog){
|
||||
caselog.caseLogDetail(taskid, projectcase.getSign(),"步骤编号:"+step.getStepnum()+" 解析自动化用例步骤脚本出错!","error",String.valueOf(step.getStepnum()),"");
|
||||
caselog.insertTaskCaseLog(taskid, projectcase.getCaseId(),"步骤编号:"+step.getStepSerialNumber()+" 解析自动化用例步骤脚本出错!","error",String.valueOf(step.getStepSerialNumber()),"");
|
||||
}
|
||||
luckyclient.publicclass.LogUtil.APP.error(e,e);
|
||||
params.put("exception","用例编号:"+projectcase.getSign()+"|解析异常,用例步骤为空或是用例脚本错误!");
|
||||
params.put("exception","用例编号:"+projectcase.getCaseSign()+"|解析异常,用例步骤为空或是用例脚本错误!");
|
||||
return params;
|
||||
}
|
||||
return params;
|
||||
|
|
|
@ -9,10 +9,11 @@ import luckyclient.caserun.exinterface.TestControl;
|
|||
import luckyclient.caserun.exwebdriver.WebDriverInitialization;
|
||||
import luckyclient.dblog.DbLink;
|
||||
import luckyclient.dblog.LogOperation;
|
||||
import luckyclient.planapi.api.GetServerAPI;
|
||||
import luckyclient.planapi.entity.ProjectCase;
|
||||
import luckyclient.planapi.entity.ProjectCasesteps;
|
||||
import luckyclient.planapi.entity.PublicCaseParams;
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
import luckyclient.serverapi.api.GetServerAPI;
|
||||
import luckyclient.serverapi.entity.ProjectCase;
|
||||
import luckyclient.serverapi.entity.ProjectCaseParams;
|
||||
import luckyclient.serverapi.entity.ProjectCaseSteps;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
@ -27,7 +28,7 @@ import luckyclient.planapi.entity.PublicCaseParams;
|
|||
*/
|
||||
public class WebOneCaseExecute{
|
||||
|
||||
public static void oneCaseExecuteForTast(String projectname,String testCaseExternalId,int version,String taskid){
|
||||
public static void oneCaseExecuteForTast(String projectname,Integer caseId,int version,String taskid){
|
||||
//记录日志到数据库
|
||||
DbLink.exetype = 0;
|
||||
TestControl.TASKID = taskid;
|
||||
|
@ -36,24 +37,25 @@ public class WebOneCaseExecute{
|
|||
try {
|
||||
wd = WebDriverInitialization.setWebDriverForTask(drivertype);
|
||||
} catch (IOException e1) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("初始化WebDriver出错!", e1);
|
||||
LogUtil.APP.error("初始化WebDriver出错!", e1);
|
||||
e1.printStackTrace();
|
||||
}
|
||||
LogOperation caselog = new LogOperation();
|
||||
ProjectCase testcase = GetServerAPI.cGetCaseByCaseId(caseId);
|
||||
//删除旧的日志
|
||||
LogOperation.deleteCaseLogDetail(testCaseExternalId, taskid);
|
||||
ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId);
|
||||
List<PublicCaseParams> pcplist=GetServerAPI.cgetParamsByProjectid(String.valueOf(testcase.getProjectid()));
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始执行用例:【"+testCaseExternalId+"】......");
|
||||
LogOperation.deleteTaskCaseLog(testcase.getCaseId(), taskid);
|
||||
|
||||
List<ProjectCaseParams> pcplist=GetServerAPI.cgetParamsByProjectid(String.valueOf(testcase.getProjectId()));
|
||||
LogUtil.APP.info("开始执行用例:【"+testcase.getCaseSign()+"】......");
|
||||
try {
|
||||
List<ProjectCasesteps> steps=GetServerAPI.getStepsbycaseid(testcase.getId());
|
||||
List<ProjectCaseSteps> steps=GetServerAPI.getStepsbycaseid(testcase.getCaseId());
|
||||
WebCaseExecution.caseExcution(testcase, steps, taskid,wd,caselog,pcplist);
|
||||
luckyclient.publicclass.LogUtil.APP.info("当前用例:【"+testcase.getSign()+"】执行完成......进入下一条");
|
||||
LogUtil.APP.info("当前用例:【"+testcase.getCaseSign()+"】执行完成......进入下一条");
|
||||
} catch (InterruptedException e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||
LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
LogOperation.updateTastdetail(taskid, 0);
|
||||
LogOperation.updateTaskExecuteData(taskid, 0);
|
||||
//关闭浏览器
|
||||
wd.quit();
|
||||
}
|
||||
|
|
|
@ -1,83 +0,0 @@
|
|||
package luckyclient.caserun.exwebdriver.extestlink;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
|
||||
import br.eti.kinoshita.testlinkjavaapi.model.TestCase;
|
||||
import luckyclient.caserun.exinterface.TestControl;
|
||||
import luckyclient.caserun.exwebdriver.WebDriverInitialization;
|
||||
import luckyclient.dblog.DbLink;
|
||||
import luckyclient.dblog.LogOperation;
|
||||
import luckyclient.testlinkapi.TestBuildApi;
|
||||
import luckyclient.testlinkapi.TestCaseApi;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||
* =================================================================
|
||||
*
|
||||
* @author: seagull
|
||||
* @date 2017年12月1日 上午9:29:40
|
||||
*
|
||||
*/
|
||||
public class WebBatchExecuteTestLink{
|
||||
|
||||
public static void batchCaseExecuteForTast(String projectname,String taskid,String batchcase) throws IOException{
|
||||
//记录日志到数据库
|
||||
DbLink.exetype = 0;
|
||||
TestControl.TASKID = taskid;
|
||||
int drivertype = LogOperation.querydrivertype(taskid);
|
||||
WebDriver wd = null;
|
||||
try {
|
||||
wd = WebDriverInitialization.setWebDriverForTask(drivertype);
|
||||
} catch (MalformedURLException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
LogOperation caselog = new LogOperation();
|
||||
TestBuildApi.getBuild(projectname);
|
||||
//执行全部非成功状态用例
|
||||
if(batchcase.indexOf("ALLFAIL")>-1){
|
||||
String casemore = caselog.unSucCaseUpdate(taskid);
|
||||
String[] temp=casemore.split("\\#",-1);
|
||||
for(int i=0;i<temp.length;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));
|
||||
TestCase testcase = TestCaseApi.getTestCaseByExternalId(testCaseExternalId, version);
|
||||
//删除旧的用例
|
||||
LogOperation.deleteCaseDetail(testCaseExternalId, taskid);
|
||||
//删除旧的日志
|
||||
LogOperation.deleteCaseLogDetail(testCaseExternalId, taskid);
|
||||
try {
|
||||
WebCaseExecutionTestLink.caseExcution(projectname,testcase, taskid,wd,caselog);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}else{ //批量执行用例
|
||||
String[] temp=batchcase.split("\\#",-1);
|
||||
for(int i=0;i<temp.length;i++){
|
||||
String testCaseExternalId = temp[i].substring(0, temp[i].indexOf("%"));
|
||||
int version = Integer.parseInt(temp[i].substring(temp[i].indexOf("%")+1,temp[i].length()));
|
||||
TestCase testcase = TestCaseApi.getTestCaseByExternalId(testCaseExternalId, version);
|
||||
try {
|
||||
WebCaseExecutionTestLink.caseExcution(projectname,testcase, taskid,wd,caselog);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
//关闭浏览器
|
||||
wd.quit();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,413 +0,0 @@
|
|||
package luckyclient.caserun.exwebdriver.extestlink;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
|
||||
import br.eti.kinoshita.testlinkjavaapi.model.TestCase;
|
||||
import br.eti.kinoshita.testlinkjavaapi.model.TestCaseStep;
|
||||
import luckyclient.caserun.exinterface.testlink.TestLinkCaseExecution;
|
||||
import luckyclient.caserun.exwebdriver.BaseWebDrive;
|
||||
import luckyclient.caserun.exwebdriver.EncapsulateOperation;
|
||||
import luckyclient.dblog.LogOperation;
|
||||
import luckyclient.publicclass.DBOperation;
|
||||
import luckyclient.testlinkapi.WebDriverAnalyticTestLinkCase;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||
* =================================================================
|
||||
*
|
||||
* @author: seagull
|
||||
* @date 2017年12月1日 上午9:29:40
|
||||
*
|
||||
*/
|
||||
public class WebCaseExecutionTestLink extends TestLinkCaseExecution{
|
||||
static Map<String, String> variable = new HashMap<String, String>();
|
||||
|
||||
public static void caseExcution(String projectname, TestCase testcase, String taskid, WebDriver wd,LogOperation caselog)
|
||||
throws InterruptedException {
|
||||
// 0:成功 1:失败 2:锁定 其他:锁定
|
||||
int setresult = 0;
|
||||
String casenote = "备注初始化";
|
||||
String imagname = "";
|
||||
//插入开始执行的用例
|
||||
caselog.addCaseDetail(taskid, testcase.getFullExternalId(), testcase.getVersion().toString(), testcase.getName(), 4);
|
||||
|
||||
for (TestCaseStep step : testcase.getSteps()) {
|
||||
Map<String, String> params = WebDriverAnalyticTestLinkCase.analyticCaseStep(testcase, step.getNumber(), taskid,caselog);
|
||||
|
||||
if(params.get("exception")!=null&¶ms.get("exception").toString().indexOf("解析异常")>-1){
|
||||
setresult = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
String result = WebCaseExecutionTestLink.runStep(params, wd, taskid, testcase.getFullExternalId(), step.getNumber(), caselog);
|
||||
|
||||
String expectedResults = params.get("ExpectedResults").toString();
|
||||
// 运行结果正常
|
||||
if (result.indexOf("出错") < 0 && result.indexOf("失败") < 0) {
|
||||
// 获取步骤间等待时间
|
||||
int waitsec = Integer.parseInt(params.get("StepWait").toString());
|
||||
if (waitsec != 0) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("操作休眠【"+waitsec+"】秒");
|
||||
Thread.sleep(waitsec * 1000);
|
||||
}
|
||||
// 有预期结果
|
||||
if (!"".equals(expectedResults)) {
|
||||
// 判断传参
|
||||
luckyclient.publicclass.LogUtil.APP.info("expectedResults=【"+expectedResults+"】");
|
||||
if (expectedResults.length() > 2 && expectedResults.substring(0, 2).indexOf("$=") > -1) {
|
||||
String expectedResultVariable = expectedResults.substring(2);
|
||||
variable.put(expectedResultVariable, result);
|
||||
continue;
|
||||
}
|
||||
|
||||
// 判断预期结果-检查模式
|
||||
if (params.get("checkproperty") != null && params.get("checkproperty_value") != null) {
|
||||
String checkproperty = params.get("checkproperty").toString();
|
||||
String checkPropertyValue = params.get("checkproperty_value").toString();
|
||||
|
||||
WebElement we = isElementExist(wd, checkproperty, checkPropertyValue);
|
||||
if (we != null) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getFullExternalId() + " 第" + step.getNumber()
|
||||
+ "步,在当前页面中找到预期结果中对象。当前步骤执行成功!");
|
||||
caselog.caseLogDetail(taskid, testcase.getFullExternalId(), "在当前页面中找到预期结果中对象。当前步骤执行成功!",
|
||||
"info", String.valueOf(step.getNumber()),"");
|
||||
continue;
|
||||
} else {
|
||||
casenote = "第" + step.getNumber() + "步,没有在当前页面中找到预期结果中对象。执行失败!";
|
||||
setresult = 1;
|
||||
java.text.DateFormat timeformat = new java.text.SimpleDateFormat("MMdd-hhmmss");
|
||||
imagname = timeformat.format(new Date());
|
||||
BaseWebDrive.webScreenShot(wd,imagname);
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getFullExternalId() + " 第" + step.getNumber()
|
||||
+ "步,没有在当前页面中找到预期结果中对象。当前步骤执行失败!");
|
||||
caselog.caseLogDetail(taskid, testcase.getFullExternalId(), "在当前页面中没有找到预期结果中对象。当前步骤执行失败!"
|
||||
+ "checkproperty【"+checkproperty+"】 checkproperty_value【"+checkPropertyValue+"】","error", String.valueOf(step.getNumber()),imagname);
|
||||
break;
|
||||
}
|
||||
|
||||
}else{
|
||||
// 模糊匹配预期结果模式
|
||||
if (expectedResults.length()>2 && expectedResults.substring(0, 2).indexOf("%=")>-1) {
|
||||
if(result.indexOf(expectedResults.substring(2))>-1){
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getFullExternalId() + " 第" + step.getNumber()
|
||||
+ "步,模糊匹配预期结果成功!执行结果:"+result);
|
||||
caselog.caseLogDetail(taskid, testcase.getFullExternalId(), "步骤模糊匹配预期结果成功!",
|
||||
"info", String.valueOf(step.getNumber()),"");
|
||||
continue;
|
||||
}else{
|
||||
casenote = "第" + step.getNumber() + "步,模糊匹配预期结果失败!";
|
||||
setresult = 1;
|
||||
java.text.DateFormat timeformat = new java.text.SimpleDateFormat("MMdd-hhmmss");
|
||||
imagname = timeformat.format(new Date());
|
||||
BaseWebDrive.webScreenShot(wd,imagname);
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getFullExternalId() + " 第" + step.getNumber()
|
||||
+ "步,模糊匹配预期结果失败!执行结果:"+result);
|
||||
caselog.caseLogDetail(taskid, testcase.getFullExternalId(), "步骤模糊匹配预期结果失败!执行结果:"+result,
|
||||
"error", String.valueOf(step.getNumber()),imagname);
|
||||
break;
|
||||
}
|
||||
// 直接匹配预期结果模式
|
||||
}else if(expectedResults.equals(result)) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getFullExternalId() + " 第" + step.getNumber()
|
||||
+ "步,直接匹配预期结果成功!执行结果:"+result);
|
||||
caselog.caseLogDetail(taskid, testcase.getFullExternalId(), "步骤直接匹配预期结果成功!",
|
||||
"info", String.valueOf(step.getNumber()),"");
|
||||
continue;
|
||||
} else {
|
||||
casenote = "第" + step.getNumber() + "步,直接匹配预期结果失败!";
|
||||
setresult = 1;
|
||||
java.text.DateFormat timeformat = new java.text.SimpleDateFormat("MMdd-hhmmss");
|
||||
imagname = timeformat.format(new Date());
|
||||
BaseWebDrive.webScreenShot(wd,imagname);
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getFullExternalId() + " 第" + step.getNumber()
|
||||
+ "步,直接匹配预期结果失败!执行结果:"+result);
|
||||
caselog.caseLogDetail(taskid, testcase.getFullExternalId(), "步骤直接匹配预期结果失败!执行结果:"+result,
|
||||
"error", String.valueOf(step.getNumber()),imagname);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
casenote = result;
|
||||
setresult = 2;
|
||||
java.text.DateFormat timeformat = new java.text.SimpleDateFormat("MMdd-hhmmss");
|
||||
imagname = timeformat.format(new Date());
|
||||
BaseWebDrive.webScreenShot(wd,imagname);
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getFullExternalId() + " 第" + step.getNumber() + "步,"+result);
|
||||
caselog.caseLogDetail(taskid, testcase.getFullExternalId(), "当前步骤在执行过程中解析|定位元素|操作对象失败!"+result,
|
||||
"error", String.valueOf(step.getNumber()),imagname);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
variable.clear();
|
||||
caselog.updateCaseDetail(taskid, testcase.getFullExternalId(), setresult);
|
||||
if(setresult==0){
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例【"+testcase.getFullExternalId()+"】全部步骤执行结果成功...");
|
||||
caselog.caseLogDetail(taskid, testcase.getFullExternalId(), "用例全部步骤执行结果成功","info", "ending","");
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcase.getFullExternalId()+"】步骤执行过程中失败或是锁定...请查看具体原因!"+casenote);
|
||||
caselog.caseLogDetail(taskid, testcase.getFullExternalId(), "用例执行过程中失败或是锁定"+casenote,"error", "ending","");
|
||||
}
|
||||
//LogOperation.UpdateTastdetail(taskid, 0);
|
||||
}
|
||||
|
||||
private static String runStep(Map<String, String> params, WebDriver wd,String taskid,String casenum,int stepno,LogOperation caselog) {
|
||||
String result = "";
|
||||
String property;
|
||||
String propertyValue;
|
||||
String operation;
|
||||
String operationValue;
|
||||
|
||||
try {
|
||||
property = params.get("property");
|
||||
propertyValue = params.get("property_value");
|
||||
operation = params.get("operation");
|
||||
operationValue = params.get("operation_value");
|
||||
|
||||
// 用例名称解析出现异常或是单个步骤参数解析异常
|
||||
if (propertyValue != null && property.indexOf("解析异常") > -1) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("当前步骤解析出现异常或是对象为空!---"+property);
|
||||
return "用例解析出错啦!";
|
||||
}
|
||||
|
||||
// 处理值传递
|
||||
if (propertyValue != null && propertyValue.indexOf("@") > -1 && propertyValue.indexOf("[@") < 0
|
||||
&& propertyValue.indexOf("@@") < 0) {
|
||||
propertyValue = settingParameter(propertyValue);
|
||||
// 判断传参是否存在问题
|
||||
if (propertyValue.indexOf("Set parameter error") > -1) {
|
||||
caselog.caseLogDetail(taskid, casenum, "当前步骤解析出现异常或是对象为空!---"+property,
|
||||
"error", String.valueOf(stepno),"");
|
||||
return "处理传参过程出错:" + propertyValue;
|
||||
}
|
||||
}else if(propertyValue != null && (propertyValue.indexOf(""")>-1
|
||||
|| propertyValue.indexOf("'")>-1 || propertyValue.indexOf("@@")>-1)){
|
||||
propertyValue = propertyValue.replaceAll(""", "\"");
|
||||
propertyValue = propertyValue.replaceAll("'", "\'");
|
||||
propertyValue = propertyValue.replaceAll("@@", "@");
|
||||
}
|
||||
|
||||
if (operationValue != null && operationValue.indexOf("@") > -1 && operationValue.indexOf("@@") < 0) {
|
||||
operationValue = settingParameter(operationValue);
|
||||
if (operationValue.indexOf("Set parameter error") > -1) {
|
||||
return "处理传参过程出错:" + propertyValue;
|
||||
}
|
||||
}else if(operationValue != null && (operationValue.indexOf(""")>-1
|
||||
|| operationValue.indexOf("'")>-1 || operationValue.indexOf("@@")>-1)){
|
||||
operationValue = operationValue.replaceAll(""", "\"");
|
||||
operationValue = operationValue.replaceAll("'", "\'");
|
||||
operationValue = operationValue.replaceAll("@@", "@");
|
||||
}
|
||||
|
||||
luckyclient.publicclass.LogUtil.APP.info("二次解析用例过程完成,等待进行对象操作......");
|
||||
caselog.caseLogDetail(taskid, casenum, "对象操作:"+operation+"; 操作值:"+operationValue,"info", String.valueOf(stepno),"");
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
luckyclient.publicclass.LogUtil.APP.error("二次解析用例过程抛出异常!---"+e.getMessage());
|
||||
return "解析用例失败!";
|
||||
}
|
||||
|
||||
try {
|
||||
//调用接口用例
|
||||
if(operation!=null&&operationValue!=null&&"runcase".equals(operation)){
|
||||
String[] temp=operationValue.split(",",-1);
|
||||
String ex = TestLinkCaseExecution.oneCaseExecuteForWebDriver(temp[0], Integer.valueOf(temp[1]),taskid,caselog);
|
||||
if(ex.indexOf("CallCase调用出错!")<=-1&&ex.indexOf("解析出错啦!")<=-1&&ex.indexOf("匹配失败")<=-1){
|
||||
return ex;
|
||||
}else{
|
||||
return "调用接口用例过程失败";
|
||||
}
|
||||
}
|
||||
|
||||
WebElement we = null;
|
||||
// 页面元素层
|
||||
if (property != null && propertyValue != null) {
|
||||
we = isElementExist(wd, property, propertyValue);
|
||||
// 判断此元素是否存在
|
||||
if (we == null) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("定位对象失败,isElementExist为null!");
|
||||
return "isElementExist定位元素过程失败!";
|
||||
}
|
||||
|
||||
if (operation.indexOf("select") > -1) {
|
||||
result = EncapsulateOperation.selectOperation(we, operation, operationValue);
|
||||
} else if (operation.indexOf("get") > -1){
|
||||
result = EncapsulateOperation.getOperation(wd, we, operation,operationValue);
|
||||
} else if (operation.indexOf("mouse") > -1){
|
||||
result = EncapsulateOperation.actionWeOperation(wd, we, operation, operationValue, property, propertyValue);
|
||||
} else {
|
||||
result = EncapsulateOperation.objectOperation(wd, we, operation, operationValue, property, propertyValue);
|
||||
}
|
||||
// Driver层操作
|
||||
} else if (property == null && operation != null) {
|
||||
// 处理弹出框事件
|
||||
if (operation.indexOf("alert") > -1){
|
||||
result = EncapsulateOperation.alertOperation(wd, operation);
|
||||
}else if(operation.indexOf("mouse") > -1){
|
||||
result = EncapsulateOperation.actionOperation(wd, operation, operationValue);
|
||||
}else{
|
||||
result = EncapsulateOperation.driverOperation(wd, operation, operationValue);
|
||||
}
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.error("元素操作过程失败!");
|
||||
result = "元素操作过程失败!";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("元素定位过程或是操作过程失败或异常!"+e.getMessage());
|
||||
return "元素定位过程或是操作过程失败或异常!" + e.getMessage();
|
||||
}
|
||||
caselog.caseLogDetail(taskid, casenum, result,"info", String.valueOf(stepno),"");
|
||||
|
||||
if(result.indexOf("获取到的值是【")>-1&&result.indexOf("】")>-1){
|
||||
result = result.substring(7, result.length()-1);
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static String settingParameter(String parameter) {
|
||||
int keyexistidentity = 0;
|
||||
if (parameter.indexOf(""") > -1 || parameter.indexOf("'") > -1) {
|
||||
parameter = parameter.replaceAll(""", "\"");
|
||||
parameter = parameter.replaceAll("'", "\'");
|
||||
}
|
||||
//处理参数字符串中带@的情况
|
||||
if(parameter.indexOf("\\@")>-1){
|
||||
return parameter.replace("\\@", "@");
|
||||
}
|
||||
|
||||
// 取单个参数中引用变量次数
|
||||
int sumvariable = DBOperation.sumString(parameter, "@");
|
||||
String uservariable = null;
|
||||
String uservariable1 = null;
|
||||
String uservariable2 = null;
|
||||
|
||||
if (sumvariable == 1) {
|
||||
uservariable = parameter.substring(parameter.indexOf("@") + 1);
|
||||
} else if (sumvariable == 2) {
|
||||
uservariable = parameter.substring(parameter.indexOf("@") + 1, parameter.lastIndexOf("@"));
|
||||
uservariable1 = parameter.substring(parameter.lastIndexOf("@") + 1);
|
||||
} else if (sumvariable == 3) {
|
||||
String temp = parameter.substring(parameter.indexOf("@") + 1, parameter.lastIndexOf("@"));
|
||||
uservariable1 = temp.substring(temp.indexOf("@") + 1);
|
||||
uservariable2 = parameter.substring(parameter.lastIndexOf("@") + 1);
|
||||
uservariable = parameter.substring(parameter.indexOf("@") + 1, parameter.indexOf(uservariable1) - 1);
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("你好像在一个参数中引用了超过3个以上的变量哦!我处理不过来啦!");
|
||||
return "你好像在一个参数中引用了超过3个以上的变量哦!我处理不过来啦!【Set parameter error】";
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
Iterator keys = variable.keySet().iterator();
|
||||
String key = null;
|
||||
while (keys.hasNext()) {
|
||||
key = (String) keys.next();
|
||||
if (uservariable.indexOf(key) > -1) {
|
||||
keyexistidentity = 1;
|
||||
uservariable = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (sumvariable == 2 || sumvariable == 3) {
|
||||
keys = variable.keySet().iterator();
|
||||
while (keys.hasNext()) {
|
||||
keyexistidentity = 0;
|
||||
key = (String) keys.next();
|
||||
if (uservariable1.indexOf(key) > -1) {
|
||||
keyexistidentity = 1;
|
||||
uservariable1 = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sumvariable == 3) {
|
||||
keys = variable.keySet().iterator();
|
||||
while (keys.hasNext()) {
|
||||
keyexistidentity = 0;
|
||||
key = (String) keys.next();
|
||||
if (uservariable2.indexOf(key) > -1) {
|
||||
keyexistidentity = 1;
|
||||
uservariable2 = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (keyexistidentity == 1) {
|
||||
// 拼装参数(传参+原有字符串)
|
||||
String parameterValues = parameter.replaceAll("@" + uservariable, variable.get(uservariable).toString());
|
||||
// 处理第二个传参
|
||||
if (sumvariable == 2 || sumvariable == 3) {
|
||||
parameterValues = parameterValues.replaceAll("@" + uservariable1,
|
||||
variable.get(uservariable1).toString());
|
||||
}
|
||||
// 处理第三个传参
|
||||
if (sumvariable == 3) {
|
||||
parameterValues = parameterValues.replaceAll("@" + uservariable2,
|
||||
variable.get(uservariable2).toString());
|
||||
}
|
||||
|
||||
return parameterValues;
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("没有找到你要的变量哦,再找下吧!第一个变量名称是:" + uservariable + ",第" + "二个变量名称是:" + uservariable1
|
||||
+ ",第三个变量名称是:" + uservariable2);
|
||||
return "【Set parameter error】没有找到你要的变量哦,再找下吧!第一个变量名称是:" + uservariable + ",第" + "二个变量名称是:" + uservariable1
|
||||
+ ",第三个变量名称是:" + uservariable2;
|
||||
}
|
||||
}
|
||||
|
||||
public static WebElement isElementExist(WebDriver wd, String property, String propertyValue) {
|
||||
try {
|
||||
WebElement we = null;
|
||||
|
||||
// 处理WebElement对象定位
|
||||
switch (property) {
|
||||
case "id":
|
||||
we = wd.findElement(By.id(propertyValue));
|
||||
break;
|
||||
case "name":
|
||||
we = wd.findElement(By.name(propertyValue));
|
||||
break;
|
||||
case "xpath":
|
||||
we = wd.findElement(By.xpath(propertyValue));
|
||||
break;
|
||||
case "linktext":
|
||||
we = wd.findElement(By.linkText(propertyValue));
|
||||
break;
|
||||
case "tagname":
|
||||
we = wd.findElement(By.tagName(propertyValue));
|
||||
break;
|
||||
case "cssselector":
|
||||
we = wd.findElement(By.cssSelector(propertyValue));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return we;
|
||||
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("当前对象定位失败:"+e.getMessage());
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
package luckyclient.caserun.exwebdriver.extestlink;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
|
||||
import br.eti.kinoshita.testlinkjavaapi.model.TestCase;
|
||||
import luckyclient.caserun.exinterface.TestControl;
|
||||
import luckyclient.caserun.exwebdriver.WebDriverInitialization;
|
||||
import luckyclient.dblog.DbLink;
|
||||
import luckyclient.dblog.LogOperation;
|
||||
import luckyclient.testlinkapi.TestBuildApi;
|
||||
import luckyclient.testlinkapi.TestCaseApi;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||
* =================================================================
|
||||
*
|
||||
* @author: seagull
|
||||
* @date 2017年12月1日 上午9:29:40
|
||||
*
|
||||
*/
|
||||
public class WebOneCaseExecuteTestLink{
|
||||
|
||||
public static void oneCaseExecuteForTast(String projectname,String testCaseExternalId,int version,String taskid){
|
||||
//记录日志到数据库
|
||||
DbLink.exetype = 0;
|
||||
TestControl.TASKID = taskid;
|
||||
int drivertype = LogOperation.querydrivertype(taskid);
|
||||
WebDriver wd = null;
|
||||
try {
|
||||
wd = WebDriverInitialization.setWebDriverForTask(drivertype);
|
||||
} catch (IOException e1) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("初始化WebDriver出错!", e1);
|
||||
e1.printStackTrace();
|
||||
}
|
||||
LogOperation caselog = new LogOperation();
|
||||
//删除旧的用例
|
||||
LogOperation.deleteCaseDetail(testCaseExternalId, taskid);
|
||||
//删除旧的日志
|
||||
LogOperation.deleteCaseLogDetail(testCaseExternalId, taskid);
|
||||
TestBuildApi.getBuild(projectname);
|
||||
TestCase testcase = TestCaseApi.getTestCaseByExternalId(testCaseExternalId, version);
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始执行用例:【"+testCaseExternalId+"】......");
|
||||
try {
|
||||
WebCaseExecutionTestLink.caseExcution(projectname,testcase, taskid,wd,caselog);
|
||||
luckyclient.publicclass.LogUtil.APP.info("当前用例:【"+testcase.getFullExternalId()+"】执行完成......进入下一条");
|
||||
} catch (InterruptedException e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
//关闭浏览器
|
||||
wd.quit();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package luckyclient.caserun.publicdispose;
|
||||
|
||||
import luckyclient.driven.SubString;
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
|
||||
/**
|
||||
* 动作关键字处理
|
||||
|
@ -21,10 +22,10 @@ public class ActionManageForSteps {
|
|||
* @return
|
||||
*/
|
||||
public static String actionManage(String stepsaction,String testresult){
|
||||
luckyclient.publicclass.LogUtil.APP.info("测试结果是:" + testresult);
|
||||
luckyclient.publicclass.LogUtil.APP.info("现在进入到Action(动作)处理......ACTION值:"+stepsaction);
|
||||
LogUtil.APP.info("测试结果是:" + testresult);
|
||||
LogUtil.APP.info("现在进入到Action(动作)处理......ACTION值:"+stepsaction);
|
||||
if(null==stepsaction||"".equals(stepsaction.trim())){
|
||||
luckyclient.publicclass.LogUtil.APP.info("Action(动作)无需处理......");
|
||||
LogUtil.APP.info("Action(动作)无需处理......");
|
||||
return testresult;
|
||||
}
|
||||
stepsaction=stepsaction.toLowerCase().trim();
|
||||
|
@ -52,7 +53,7 @@ public class ActionManageForSteps {
|
|||
// 获取步骤间等待时间
|
||||
int time=Integer.parseInt(actionorder.substring(0, actionorder.lastIndexOf("#wait")));
|
||||
if (time > 0) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("Action(Wait):线程等待"+time+"秒...");
|
||||
LogUtil.APP.info("Action(Wait):线程等待"+time+"秒...");
|
||||
Thread.sleep(time * 1000);
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
|
@ -60,7 +61,7 @@ public class ActionManageForSteps {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.error("使用等待关键字的参数不是整数,直接跳过此动作,请检查!");
|
||||
LogUtil.APP.warn("使用等待关键字的参数不是整数,直接跳过此动作,请检查!");
|
||||
}
|
||||
}else if(actionorder.endsWith("#getjv")){
|
||||
String actionparams=actionorder.substring(0, actionorder.lastIndexOf("#getjv"));
|
||||
|
@ -74,7 +75,7 @@ public class ActionManageForSteps {
|
|||
key=actionparams;
|
||||
testresult=SubString.getJsonValue(testresult, key, index);
|
||||
}
|
||||
luckyclient.publicclass.LogUtil.APP.info("Action(getJV):获取JSON字符串指定Key的值是:"+testresult);
|
||||
LogUtil.APP.info("Action(getJV):获取JSON字符串指定Key的值是:"+testresult);
|
||||
}else if(actionorder.endsWith("#subcentrestr")){
|
||||
String actionparams=actionorder.substring(0, actionorder.lastIndexOf("#subcentrestr"));
|
||||
String startstr="";
|
||||
|
@ -83,10 +84,10 @@ public class ActionManageForSteps {
|
|||
startstr=actionparams.substring(actionparams.indexOf("[")+1, actionparams.indexOf("]"));
|
||||
endstr=actionparams.substring(actionparams.lastIndexOf("[")+1, actionparams.lastIndexOf("]"));
|
||||
testresult=SubString.subCentreStr(testresult, startstr, endstr);
|
||||
luckyclient.publicclass.LogUtil.APP.info("Action(subCentreStr):截取测试结果指定开始及结束位置字符串:"+testresult);
|
||||
LogUtil.APP.info("Action(subCentreStr):截取测试结果指定开始及结束位置字符串:"+testresult);
|
||||
}else{
|
||||
testresult="步骤动作:subCentreStr 必须是[\"开始字符\"][\"结束字符\"]#subCentreStr 格式,请检查您的步骤动作关键字:"+actionorder;
|
||||
luckyclient.publicclass.LogUtil.APP.error("步骤动作:subCentreStr 必须是[\"开始字符\"][\"结束字符\"]#subCentreStr 格式,请检查您的步骤动作关键字:"+actionorder);
|
||||
LogUtil.APP.warn("步骤动作:subCentreStr 必须是[\"开始字符\"][\"结束字符\"]#subCentreStr 格式,请检查您的步骤动作关键字:"+actionorder);
|
||||
}
|
||||
}else if(actionorder.endsWith("#subcentrenum")){
|
||||
String actionparams=actionorder.substring(0, actionorder.lastIndexOf("#subcentrenum"));
|
||||
|
@ -96,10 +97,10 @@ public class ActionManageForSteps {
|
|||
startnum=actionparams.substring(actionparams.indexOf("[")+1, actionparams.indexOf("]"));
|
||||
endnum=actionparams.substring(actionparams.lastIndexOf("[")+1, actionparams.lastIndexOf("]"));
|
||||
testresult=SubString.subCentreNum(testresult, startnum, endnum);
|
||||
luckyclient.publicclass.LogUtil.APP.info("Action(subCentreNum):截取测试结果指定开始及结束位置字符串:"+testresult);
|
||||
LogUtil.APP.info("Action(subCentreNum):截取测试结果指定开始及结束位置字符串:"+testresult);
|
||||
}else{
|
||||
testresult="步骤动作:subCentreNum 必须是[\"开始字符\"][\"结束字符\"]#subCentreNum 格式,请检查您的步骤动作关键字:"+actionorder;
|
||||
luckyclient.publicclass.LogUtil.APP.error("步骤动作:subCentreNum 必须是[\"开始位置(整数)\"][\"结束位置(整数)\"]#subCentreNum 格式,请检查您的步骤动作关键字:"+actionorder);
|
||||
LogUtil.APP.warn("步骤动作:subCentreNum 必须是[\"开始位置(整数)\"][\"结束位置(整数)\"]#subCentreNum 格式,请检查您的步骤动作关键字:"+actionorder);
|
||||
}
|
||||
}else if(actionorder.endsWith("#substrrgex")){
|
||||
String actionparams=actionorder.substring(0, actionorder.lastIndexOf("#substrrgex"));
|
||||
|
@ -113,15 +114,15 @@ public class ActionManageForSteps {
|
|||
key=actionparams;
|
||||
testresult=SubString.subStrRgex(testresult, key, index);
|
||||
}
|
||||
luckyclient.publicclass.LogUtil.APP.info("Action(subStrRgex):获取JSON字符串指定Key的值是:"+testresult);
|
||||
LogUtil.APP.info("Action(subStrRgex):获取JSON字符串指定Key的值是:"+testresult);
|
||||
}else{
|
||||
testresult="未检索到对应动作关键字,直接跳过此动作,请检查关键字:"+actionorder;
|
||||
luckyclient.publicclass.LogUtil.APP.error("未检索到对应动作关键字,直接跳过此动作,请检查关键字:"+actionorder);
|
||||
LogUtil.APP.warn("未检索到对应动作关键字,直接跳过此动作,请检查关键字:"+actionorder);
|
||||
}
|
||||
return testresult;
|
||||
}catch(Exception e){
|
||||
testresult="处理步骤动作事件过程中出现异常,直接返回测试结果:"+actionorder;
|
||||
luckyclient.publicclass.LogUtil.APP.error("处理步骤动作事件过程中出现异常,直接返回测试结果:"+actionorder);
|
||||
LogUtil.APP.error("处理步骤动作事件过程中出现异常,直接返回测试结果:"+actionorder);
|
||||
return testresult;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ import com.alibaba.fastjson.JSONException;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
|
||||
/**
|
||||
* 对参数替换进行处理
|
||||
* =================================================================
|
||||
|
@ -49,7 +51,7 @@ public class ChangString {
|
|||
|
||||
// 如果存在传参,进行处理
|
||||
if (varcount > 0) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("在" + changname + "【" + str + "】中找到" + varcount + "个可替换参数");
|
||||
LogUtil.APP.info("在" + changname + "【" + str + "】中找到" + varcount + "个可替换参数");
|
||||
int changcount = 0;
|
||||
|
||||
// 准备将HASHMAP换成LINKMAP,对KEY进行排序,解决要先替换最长KEY的问题
|
||||
|
@ -80,7 +82,7 @@ public class ChangString {
|
|||
// "\\\\'"));
|
||||
int viewcount = counter(str, "@" + entry.getKey());
|
||||
str = str.replace("@" + entry.getKey(), entry.getValue());
|
||||
luckyclient.publicclass.LogUtil.APP
|
||||
LogUtil.APP
|
||||
.info("将" + changname + "引用变量【@" + entry.getKey() + "】替换成值【" + entry.getValue() + "】");
|
||||
str = str.replace("////CHANG////", "@@" + entry.getKey());
|
||||
changcount = changcount + viewcount;
|
||||
|
@ -88,7 +90,7 @@ public class ChangString {
|
|||
}
|
||||
|
||||
if (varcount != changcount) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(changname + "有引用变量未在参数列中找到,请检查!处理结果【" + str + "】");
|
||||
LogUtil.APP.warn(changname + "有引用变量未在参数列中找到,请检查!处理结果【" + str + "】");
|
||||
}
|
||||
}
|
||||
str = str.replace("@@", "@");
|
||||
|
@ -218,10 +220,10 @@ public class ChangString {
|
|||
if(entry.getValue() instanceof List){
|
||||
if(key.equals(entry.getKey())){
|
||||
if(keyindex==COUNTER){
|
||||
luckyclient.publicclass.LogUtil.APP.info("对象原始String值:【"+entry.getValue()+"】");
|
||||
LogUtil.APP.info("对象原始String值:【"+entry.getValue()+"】");
|
||||
JSONArray jsonarr = JSONArray.parseArray(value);
|
||||
entry.setValue(jsonarr);
|
||||
luckyclient.publicclass.LogUtil.APP.info("对象替换后String值:【"+entry.getValue()+"】");
|
||||
LogUtil.APP.info("对象替换后String值:【"+entry.getValue()+"】");
|
||||
BCHANG=true;
|
||||
}
|
||||
COUNTER++;
|
||||
|
@ -236,10 +238,10 @@ public class ChangString {
|
|||
}catch(JSONException jsone){
|
||||
if(key.equals(entry.getKey())){
|
||||
if(keyindex==COUNTER){
|
||||
luckyclient.publicclass.LogUtil.APP.info("对象原始List值:【"+entry.getValue()+"】");
|
||||
LogUtil.APP.info("对象原始List值:【"+entry.getValue()+"】");
|
||||
JSONArray jsonarr = JSONArray.parseArray(value);
|
||||
entry.setValue(jsonarr);
|
||||
luckyclient.publicclass.LogUtil.APP.info("对象替换后List值:【"+entry.getValue()+"】");
|
||||
LogUtil.APP.info("对象替换后List值:【"+entry.getValue()+"】");
|
||||
BCHANG=true;
|
||||
}
|
||||
COUNTER++;
|
||||
|
@ -253,9 +255,9 @@ public class ChangString {
|
|||
if(entry.getValue() instanceof String){
|
||||
if(key.equals(entry.getKey())){
|
||||
if(keyindex==COUNTER){
|
||||
luckyclient.publicclass.LogUtil.APP.info("对象原始String值:【"+entry.getValue()+"】");
|
||||
LogUtil.APP.info("对象原始String值:【"+entry.getValue()+"】");
|
||||
entry.setValue(value);
|
||||
luckyclient.publicclass.LogUtil.APP.info("对象替换后String值:【"+entry.getValue()+"】");
|
||||
LogUtil.APP.info("对象替换后String值:【"+entry.getValue()+"】");
|
||||
BCHANG=true;
|
||||
}
|
||||
COUNTER++;
|
||||
|
@ -265,9 +267,9 @@ public class ChangString {
|
|||
if(entry.getValue() instanceof Integer){
|
||||
if(key.equals(entry.getKey())){
|
||||
if(keyindex==COUNTER){
|
||||
luckyclient.publicclass.LogUtil.APP.info("对象原始Integer值:【"+entry.getValue()+"】");
|
||||
LogUtil.APP.info("对象原始Integer值:【"+entry.getValue()+"】");
|
||||
entry.setValue(Integer.valueOf(value));
|
||||
luckyclient.publicclass.LogUtil.APP.info("对象替换后Integer值:【"+entry.getValue()+"】");
|
||||
LogUtil.APP.info("对象替换后Integer值:【"+entry.getValue()+"】");
|
||||
BCHANG=true;
|
||||
}
|
||||
COUNTER++;
|
||||
|
@ -277,9 +279,9 @@ public class ChangString {
|
|||
if(entry.getValue() instanceof Long){
|
||||
if(key.equals(entry.getKey())){
|
||||
if(keyindex==COUNTER){
|
||||
luckyclient.publicclass.LogUtil.APP.info("对象原始Long值:【"+entry.getValue()+"】");
|
||||
LogUtil.APP.info("对象原始Long值:【"+entry.getValue()+"】");
|
||||
entry.setValue(Long.valueOf(value));
|
||||
luckyclient.publicclass.LogUtil.APP.info("对象替换后Long值:【"+entry.getValue()+"】");
|
||||
LogUtil.APP.info("对象替换后Long值:【"+entry.getValue()+"】");
|
||||
BCHANG=true;
|
||||
}
|
||||
COUNTER++;
|
||||
|
@ -289,10 +291,10 @@ public class ChangString {
|
|||
if(entry.getValue() instanceof BigDecimal){
|
||||
if(key.equals(entry.getKey())){
|
||||
if(keyindex==COUNTER){
|
||||
luckyclient.publicclass.LogUtil.APP.info("对象原始BigDecimal值:【"+entry.getValue()+"】");
|
||||
LogUtil.APP.info("对象原始BigDecimal值:【"+entry.getValue()+"】");
|
||||
BigDecimal bd = new BigDecimal(value);
|
||||
entry.setValue(bd);
|
||||
luckyclient.publicclass.LogUtil.APP.info("对象替换后BigDecimal值:【"+entry.getValue()+"】");
|
||||
LogUtil.APP.info("对象替换后BigDecimal值:【"+entry.getValue()+"】");
|
||||
BCHANG=true;
|
||||
}
|
||||
COUNTER++;
|
||||
|
@ -302,9 +304,9 @@ public class ChangString {
|
|||
if(entry.getValue() instanceof Boolean){
|
||||
if(key.equals(entry.getKey())){
|
||||
if(keyindex==COUNTER){
|
||||
luckyclient.publicclass.LogUtil.APP.info("对象原始Boolean值:【"+entry.getValue()+"】");
|
||||
LogUtil.APP.info("对象原始Boolean值:【"+entry.getValue()+"】");
|
||||
entry.setValue(Boolean.valueOf(value));
|
||||
luckyclient.publicclass.LogUtil.APP.info("对象替换后Boolean值:【"+entry.getValue()+"】");
|
||||
LogUtil.APP.info("对象替换后Boolean值:【"+entry.getValue()+"】");
|
||||
BCHANG=true;
|
||||
}
|
||||
COUNTER++;
|
||||
|
@ -324,10 +326,10 @@ public class ChangString {
|
|||
*/
|
||||
public static Map<String, String> changjson(String json, String key, String value,int index) {
|
||||
json=json.trim();
|
||||
luckyclient.publicclass.LogUtil.APP.info("原始JSON:【"+json+"】");
|
||||
luckyclient.publicclass.LogUtil.APP.info("待替换JSON KEY:【"+key+"】");
|
||||
luckyclient.publicclass.LogUtil.APP.info("待替换JSON VALUE:【"+value+"】");
|
||||
luckyclient.publicclass.LogUtil.APP.info("待替换JSON KEY序号:【"+index+"】");
|
||||
LogUtil.APP.info("原始JSON:【"+json+"】");
|
||||
LogUtil.APP.info("待替换JSON KEY:【"+key+"】");
|
||||
LogUtil.APP.info("待替换JSON VALUE:【"+value+"】");
|
||||
LogUtil.APP.info("待替换JSON KEY序号:【"+index+"】");
|
||||
Map<String, String> map = new HashMap<String, String>(0);
|
||||
map.put("json", json);
|
||||
map.put("boolean", BCHANG.toString().toLowerCase());
|
||||
|
@ -337,12 +339,12 @@ public class ChangString {
|
|||
JSONObject jsonStr = JSONObject.parseObject(json);
|
||||
jsonStr=parseJsonString(json,key,value,index);
|
||||
if (BCHANG) {
|
||||
luckyclient.publicclass.LogUtil.APP
|
||||
LogUtil.APP
|
||||
.info("JSON字符串替换成功,新JSON:【" + jsonStr.toJSONString() + "】");
|
||||
}
|
||||
map.put("json", jsonStr.toJSONString());
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("格式化成JSON异常,请检查参数:" + json, e);
|
||||
LogUtil.APP.error("格式化成JSON异常,请检查参数:" + json, e);
|
||||
return map;
|
||||
}
|
||||
} else if (json.startsWith("[") && json.endsWith("]")) {
|
||||
|
@ -354,7 +356,7 @@ public class ChangString {
|
|||
jsonStr=parseJsonString(jsonStr.toJSONString(),key,value,index);
|
||||
if(BCHANG){
|
||||
jsonarr.set(i, jsonStr);
|
||||
luckyclient.publicclass.LogUtil.APP.info(
|
||||
LogUtil.APP.info(
|
||||
"JSONARRAY字符串替换成功,新JSONARRAY:【" + jsonarr.toJSONString() + "】");
|
||||
break;
|
||||
}
|
||||
|
@ -362,7 +364,7 @@ public class ChangString {
|
|||
map.put("json", jsonarr.toJSONString());
|
||||
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("格式化成JSONArray异常,请检查参数:" + json, e);
|
||||
LogUtil.APP.error("格式化成JSONArray异常,请检查参数:" + json, e);
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@ import java.util.Random;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
|
||||
/**
|
||||
* ¶ÔÄÚÖòÎÊý½øÐд¦Àí
|
||||
* =================================================================
|
||||
|
@ -53,15 +55,15 @@ public class ParamsManageForSteps {
|
|||
Random random = new Random();
|
||||
String replacement = String.valueOf(random.nextInt(endnum - startnum + 1) + startnum);
|
||||
params = m.replaceFirst(replacement);
|
||||
luckyclient.publicclass.LogUtil.APP.info("Params(" + matcherstr + "):替换成随机数后,字符串:" + params);
|
||||
LogUtil.APP.info("Params(" + matcherstr + "):替换成随机数后,字符串:" + params);
|
||||
m = pattern.matcher(params);
|
||||
}
|
||||
return params;
|
||||
} catch (IllegalArgumentException iae) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("处理随机数字参数过程中出现异常,请检查数字区间是否正常!");
|
||||
LogUtil.APP.error("处理随机数字参数过程中出现异常,请检查数字区间是否正常!");
|
||||
return params;
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("处理随机数字参数过程中出现异常,请检查你的格式是否正确!");
|
||||
LogUtil.APP.error("处理随机数字参数过程中出现异常,请检查你的格式是否正确!");
|
||||
return params;
|
||||
}
|
||||
}
|
||||
|
@ -90,18 +92,18 @@ public class ParamsManageForSteps {
|
|||
matcherstr=df.format(new Date());
|
||||
}
|
||||
} catch (IllegalArgumentException iae) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("处理随机数字参数过程中出现异常,请检查你的格式是否正确!");
|
||||
LogUtil.APP.error("处理随机数字参数过程中出现异常,请检查你的格式是否正确!");
|
||||
df = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss");
|
||||
matcherstr=df.format(new Date());
|
||||
} finally {
|
||||
params = m.replaceFirst(matcherstr);
|
||||
luckyclient.publicclass.LogUtil.APP.info("Params(" + matcherstr + "):替换成随机数后,字符串:" + params);
|
||||
LogUtil.APP.info("Params(" + matcherstr + "):替换成随机数后,字符串:" + params);
|
||||
m = pattern.matcher(params);
|
||||
}
|
||||
}
|
||||
return params;
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("处理随机数字参数过程中出现异常,请检查你的格式是否正确!");
|
||||
LogUtil.APP.error("处理随机数字参数过程中出现异常,请检查你的格式是否正确!");
|
||||
return params;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package luckyclient.dblog;
|
|||
import java.util.Properties;
|
||||
|
||||
import luckyclient.publicclass.DBOperation;
|
||||
import luckyclient.publicclass.SysConfig;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
@ -30,7 +31,7 @@ public class DbLink {
|
|||
*
|
||||
*/
|
||||
public static DBOperation dbLogLink(){
|
||||
Properties properties = luckyclient.publicclass.SysConfig.getConfiguration();
|
||||
Properties properties = SysConfig.getConfiguration();
|
||||
String urlBase = "jdbc:mysql://"+properties.getProperty("mysql.db.ip")+":"+properties.getProperty("mysql.db.port")
|
||||
+"/"+properties.getProperty("mysql.db.dbname")+"?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&useSSL=false";
|
||||
String userNameBase = properties.getProperty("mysql.db.username");
|
||||
|
|
|
@ -1,254 +1,127 @@
|
|||
package luckyclient.dblog;
|
||||
|
||||
import luckyclient.publicclass.DBOperation;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
import luckyclient.serverapi.api.GetServerAPI;
|
||||
import luckyclient.serverapi.api.PostServerAPI;
|
||||
import luckyclient.serverapi.entity.TaskExecute;
|
||||
import luckyclient.serverapi.entity.TaskScheduling;
|
||||
|
||||
/**
|
||||
*
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改 有任何疑问欢迎联系作者讨论。 QQ:1573584944 Seagull
|
||||
* =================================================================
|
||||
*
|
||||
* @ClassName: LogOperation
|
||||
* @Description: 日志写入数据库 @author: seagull
|
||||
* @date 2015年4月15日 上午9:29:40
|
||||
*
|
||||
* @author Seagull
|
||||
* @date 2019年4月23日
|
||||
*/
|
||||
public class LogOperation {
|
||||
public static DBOperation dbt = DbLink.dbLogLink();
|
||||
static int exetype = DbLink.exetype;
|
||||
|
||||
/**
|
||||
* 插入用例执行状态 casestatus pass:0 fail:1 lock:2 unexecute:4
|
||||
* 插入用例执行状态 0通过 1失败 2锁定 3执行中 4未执行
|
||||
*/
|
||||
public void addCaseDetail(String taskid, String caseno, String caseversion, String casename, Integer casestatus) {
|
||||
public void insertTaskCaseExecute(String taskIdStr, Integer projectId,Integer caseId, String caseSign,String caseName, Integer caseStatus) {
|
||||
if (0 == exetype) {
|
||||
int taskidtoint = Integer.parseInt(taskid);
|
||||
casename = casename.replace("'", "''");
|
||||
// 设置日期格式
|
||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String sql = "Insert into test_casedetail(TASKID,CASENO,CASEVERSION,CASETIME,"
|
||||
+ "CASENAME,CASESTATUS) Values (" + taskidtoint + ",'" + caseno + "','" + caseversion + "',"
|
||||
+ "str_to_date('" + df.format(new Date()) + "','%Y-%m-%d %T'),'" + casename + "','" + casestatus
|
||||
+ "')";
|
||||
try {
|
||||
dbt.executeSql(sql);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
luckyclient.publicclass.LogUtil.APP.error("执行插入用例执行记录SQL出现异常,请确认数据库链接是否正常!", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
Integer taskId=Integer.valueOf(taskIdStr);
|
||||
PostServerAPI.clientPostInsertTaskCaseExecute(taskId, projectId, caseId, caseSign, caseName, caseStatus);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用例执行状态 casestatus pass:0 fail:1 lock:2 unexecute:4
|
||||
* 更新用例执行状态 0通过 1失败 2锁定 3执行中 4未执行
|
||||
*/
|
||||
public void updateCaseDetail(String taskid, String caseno, Integer casestatus) {
|
||||
public void updateTaskCaseExecuteStatus(String taskIdStr, Integer caseId, Integer caseStatus) {
|
||||
if (0 == exetype) {
|
||||
int taskidtoint = Integer.parseInt(taskid);
|
||||
// 设置日期格式
|
||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String sql = "update test_casedetail set casestatus = '" + casestatus + "',CASETIME = str_to_date('"
|
||||
+ df.format(new Date()) + "','%Y-%m-%d %T')" + " where taskid = " + taskidtoint + " and caseno = '"
|
||||
+ caseno + "'";
|
||||
try {
|
||||
dbt.executeSql(sql);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
luckyclient.publicclass.LogUtil.APP.error("执行更新用例执行状态SQL出现异常,请确认数据库链接是否正常!", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
Integer taskId=Integer.valueOf(taskIdStr);
|
||||
PostServerAPI.clientUpdateTaskCaseExecuteStatus(taskId, caseId, caseStatus);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入用例执行日志
|
||||
*/
|
||||
public void caseLogDetail(String taskid, String caseno, String detail, String loggrade, String step,
|
||||
public void insertTaskCaseLog(String taskIdStr, Integer caseId, String logDetail, String logGrade, String logStep,
|
||||
String imgname) {
|
||||
if (0 == exetype) {
|
||||
if (detail.indexOf("'") > -1) {
|
||||
detail = detail.replaceAll("'", "''");
|
||||
if (logDetail.length()>5000) {
|
||||
LogUtil.APP.info("日志明细超过5000字符,无法进入数据库存储,进行日志明细打印...");
|
||||
LogUtil.APP.info("第"+logStep+"步,日志级别"+logGrade+",日志明细【"+logGrade+"】...");
|
||||
logDetail="日志明细超过5000字符无法存入数据库,已在LOG4J日志中打印,请前往查看...";
|
||||
}
|
||||
int taskidtoint = Integer.parseInt(taskid);
|
||||
String sqlresult = null;
|
||||
try {
|
||||
sqlresult = dbt.executeQuery("select id from test_casedetail where taskid = " + taskidtoint
|
||||
+ " and caseno = '" + caseno + "' order by id desc");
|
||||
} catch (Exception e1) {
|
||||
// TODO Auto-generated catch block
|
||||
luckyclient.publicclass.LogUtil.APP.error("执行查询用例执行ID SQL出现异常,请确认数据库链接是否正常!", e1);
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
if (!"".equals(sqlresult) && null != sqlresult) {
|
||||
// 取其中最近一条数据做为CASEID
|
||||
int caseid = Integer.parseInt(sqlresult.substring(0, sqlresult.indexOf("%")));
|
||||
// 设置日期格式
|
||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
if (detail.length()>5000) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("日志明细超过5000字符,无法进入数据库存储,进行日志明细打印...");
|
||||
luckyclient.publicclass.LogUtil.APP.info("用例【"+caseno+"】第"+step+"步,日志级别"+loggrade+",日志明细【"+detail+"】...");
|
||||
detail="日志明细超过5000字符无法存入数据库,已在LOG4J日志中打印,请前往查看...";
|
||||
}
|
||||
String sql = "Insert into test_logdetail(LOGTIME,TASKID,CASEID,DETAIL,LOGGRADE,STEP,IMGNAME) "
|
||||
+ "Values (str_to_date('" + df.format(new Date()) + "','%Y-%m-%d %T')," + taskidtoint + ","
|
||||
+ caseid + ",'" + detail + "','" + loggrade + "','" + step + "','" + imgname + "')";
|
||||
try {
|
||||
String re = dbt.executeSql(sql);
|
||||
if (re.indexOf("成功") < 0) {
|
||||
throw new Exception("更新用例:" + caseno + "步骤" + step + "日志到数据库中出现异常!!!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
luckyclient.publicclass.LogUtil.APP.error("执行插入用例执行日志SQL出现异常,请确认数据库链接是否正常!", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Integer taskId=Integer.valueOf(taskIdStr);
|
||||
PostServerAPI.clientPostInsertTaskCaseLog(taskId, caseId, logDetail, logGrade, logStep, imgname);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新本次任务的执行统计情况
|
||||
* 状态 0未执行 1执行中 2执行完成 3执行失败 4唤起客户端失败
|
||||
*/
|
||||
public static int[] updateTastdetail(String taskid, int casecount) {
|
||||
public static int[] updateTaskExecuteData(String taskIdStr, int caseCount) {
|
||||
int[] taskcount = null;
|
||||
if (0 == exetype) {
|
||||
try {
|
||||
int id = Integer.parseInt(taskid);
|
||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Integer taskId = Integer.parseInt(taskIdStr);
|
||||
String str = PostServerAPI.clientUpdateTaskExecuteData(taskId, caseCount,2);
|
||||
JSONObject jsonObject = JSONObject.parseObject(str);
|
||||
|
||||
String casesucsql = dbt.executeQuery(
|
||||
"select count(*) from test_casedetail where taskid = " + id + " and casestatus = 0");
|
||||
String casefailsql = dbt.executeQuery(
|
||||
"select count(*) from test_casedetail where taskid = " + id + " and casestatus = 1");
|
||||
String caselocksql = dbt.executeQuery(
|
||||
"select count(*) from test_casedetail where taskid = " + id + " and casestatus = 2");
|
||||
String casenoexesql = dbt.executeQuery(
|
||||
"select count(*) from test_casedetail where taskid = " + id + " and casestatus = 4");
|
||||
// 返回本次任务执行情况
|
||||
taskcount = new int[5];
|
||||
taskcount[0] = jsonObject.getInteger("caseCount");
|
||||
taskcount[1] = jsonObject.getInteger("caseSuc");
|
||||
taskcount[2] = jsonObject.getInteger("caseFail");
|
||||
taskcount[3] = jsonObject.getInteger("caseLock");
|
||||
taskcount[4] = jsonObject.getInteger("caseNoExec");
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新本次任务的执行状态
|
||||
* 状态 0未执行 1执行中 2执行完成 3执行失败 4唤起客户端失败
|
||||
*/
|
||||
public static void updateTastStatus(String taskid, int casecount) {
|
||||
public static void updateTaskExecuteStatus(String taskIdStr, int caseCount) {
|
||||
if (0 == exetype) {
|
||||
try {
|
||||
int id = Integer.parseInt(taskid);
|
||||
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();
|
||||
}
|
||||
Integer taskId = Integer.parseInt(taskIdStr);
|
||||
PostServerAPI.clientUpdateTaskExecuteData(taskId, caseCount,1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除单次任务指定的用例日志明细
|
||||
*/
|
||||
public static void deleteCaseLogDetail(String caseno, String taskid) {
|
||||
int inttaskid = Integer.parseInt(taskid);
|
||||
String casesidsql;
|
||||
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();
|
||||
}
|
||||
public static void deleteTaskCaseLog(Integer caseId, String taskIdStr) {
|
||||
Integer taskId = Integer.parseInt(taskIdStr);
|
||||
PostServerAPI.clientDeleteTaskCaseLog(taskId, caseId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除单次任务指定的用例明细
|
||||
* 取出指定任务ID中的不属于成功状态的用例ID
|
||||
*/
|
||||
public static void deleteCaseDetail(String caseno, String taskid) {
|
||||
int inttaskid = Integer.parseInt(taskid);
|
||||
try {
|
||||
// 删除原来的用例
|
||||
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();
|
||||
}
|
||||
public List<Integer> getCaseListForUnSucByTaskId(String taskIdStr) {
|
||||
int taskId = Integer.parseInt(taskIdStr);
|
||||
return GetServerAPI.clientGetCaseListForUnSucByTaskId(taskId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取出指定任务ID中的不属于成功状态的用例编写以及版本号
|
||||
*/
|
||||
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
|
||||
* 取出指定任务ID中所属的调度是否要发送邮件状态及收件人地址 发送邮件通知时的具体逻辑, -1-不通知 0-全部,1-成功,2-失败
|
||||
* 发送 eMailer varchar(100) ; --收件人
|
||||
*/
|
||||
|
||||
public static String[] getEmailAddress(String taskid) {
|
||||
int inttaskid = Integer.parseInt(taskid);
|
||||
String casesidsql = null;
|
||||
public static String[] getEmailAddress(String taskIdStr) {
|
||||
Integer taskId = Integer.parseInt(taskIdStr);
|
||||
String[] address = null;
|
||||
try {
|
||||
casesidsql = dbt.executeQuery(
|
||||
"select t.issendmail,t.emailer from test_jobs t where id in (select jobid from test_taskexcute t where t.id = "
|
||||
+ inttaskid + ")");
|
||||
String status = casesidsql.substring(0, casesidsql.indexOf("%"));
|
||||
if ("1".equals(status)) {
|
||||
String temp = casesidsql.substring(casesidsql.indexOf("%") + 1, casesidsql.length() - 1);
|
||||
TaskScheduling taskScheduling = GetServerAPI.cGetTaskSchedulingByTaskId(taskId);
|
||||
if (taskScheduling.getEmailSendCondition()!=-1) {
|
||||
String temp = taskScheduling.getEmailAddress();
|
||||
// 清除最后一个;
|
||||
if (temp.indexOf(";") > -1 && temp.substring(temp.length() - 1, temp.length()).indexOf(";") > -1) {
|
||||
temp = temp.substring(0, temp.length() - 1);
|
||||
|
@ -264,7 +137,6 @@ public class LogOperation {
|
|||
}
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
luckyclient.publicclass.LogUtil.APP.error("执行取出指定任务ID中所属的调度是否要发送邮件状态及收件人地址SQL出现异常,请确认数据库链接是否正常!", e);
|
||||
e.printStackTrace();
|
||||
return address;
|
||||
}
|
||||
|
@ -272,23 +144,17 @@ public class LogOperation {
|
|||
}
|
||||
|
||||
/**
|
||||
* 取出指定任务ID中所属的调度是否要自动构建以及构建的项目名称 isBuilding varchar(1) default(0); --0
|
||||
* 不自动构建 1 自动构建 BuildName varchar(100) ; --构建项目名称
|
||||
* 取出指定任务ID中所属的调度是否要自动构建以及构建的项目名称 为空时不构建
|
||||
*/
|
||||
public static String[] getBuildName(String taskid) {
|
||||
int inttaskid = Integer.parseInt(taskid);
|
||||
String casesidsql = null;
|
||||
public static String[] getBuildName(String taskIdStr) {
|
||||
Integer taskId = Integer.parseInt(taskIdStr);
|
||||
String[] buildname = null;
|
||||
try {
|
||||
casesidsql = dbt.executeQuery(
|
||||
"select t.isbuilding,t.buildname from test_jobs t where id in (select jobid from test_taskexcute t where t.id = "
|
||||
+ inttaskid + ")");
|
||||
if (null == casesidsql || "".equals(casesidsql)) {
|
||||
TaskScheduling taskScheduling = GetServerAPI.cGetTaskSchedulingByTaskId(taskId);
|
||||
if (null == taskScheduling.getBuildingLink() || "".equals(taskScheduling.getBuildingLink())) {
|
||||
return buildname;
|
||||
}
|
||||
String status = casesidsql.substring(0, casesidsql.indexOf("%"));
|
||||
if ("1".equals(status)) {
|
||||
String temp = casesidsql.substring(casesidsql.indexOf("%") + 1, casesidsql.length() - 1);
|
||||
}else{
|
||||
String temp = taskScheduling.getBuildingLink();
|
||||
// 清除最后一个;
|
||||
if (temp.indexOf(";") > -1 && temp.substring(temp.length() - 1, temp.length()).indexOf(";") > -1) {
|
||||
temp = temp.substring(0, temp.length() - 1);
|
||||
|
@ -304,7 +170,6 @@ public class LogOperation {
|
|||
}
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
luckyclient.publicclass.LogUtil.APP.error("执行取出指定任务ID中所属的调度是否要自动构建以及构建的项目名称SQL出现异常,请确认数据库链接是否正常!", e);
|
||||
e.printStackTrace();
|
||||
return buildname;
|
||||
}
|
||||
|
@ -312,26 +177,21 @@ public class LogOperation {
|
|||
}
|
||||
|
||||
/**
|
||||
* 取出指定任务ID中所属的调度是否要自动重启TOMCAT isrestart varchar(1) default(0); --0 不自动重启 1
|
||||
* 取出指定任务ID中所属的调度是否要自动重启TOMCAT
|
||||
* 自动重启 restartcomm varchar(200) ; -- 格式:服务器IP;服务器用户名;服务器密码;ssh端口;Shell命令;
|
||||
* 例:192.168.222.22;pospsettle;pospsettle;22;cd
|
||||
* /home/pospsettle/tomcat-7.0-7080/bin&&./restart.sh;
|
||||
*/
|
||||
|
||||
public static String[] getrestartcomm(String taskid) {
|
||||
int inttaskid = Integer.parseInt(taskid);
|
||||
String casesidsql = null;
|
||||
public static String[] getRestartComm(String taskIdStr) {
|
||||
Integer taskId = Integer.parseInt(taskIdStr);
|
||||
String[] command = null;
|
||||
try {
|
||||
casesidsql = dbt.executeQuery(
|
||||
"select t.isrestart,t.restartcomm from test_jobs t where id in (select jobid from test_taskexcute t where t.id = "
|
||||
+ inttaskid + ")");
|
||||
if (null == casesidsql || "".equals(casesidsql)) {
|
||||
TaskScheduling taskScheduling = GetServerAPI.cGetTaskSchedulingByTaskId(taskId);
|
||||
if (null == taskScheduling.getRemoteShell() || "".equals(taskScheduling.getRemoteShell())) {
|
||||
return command;
|
||||
}
|
||||
String status = casesidsql.substring(0, casesidsql.indexOf("%"));
|
||||
if ("1".equals(status)) {
|
||||
String temp = casesidsql.substring(casesidsql.indexOf("%") + 1, casesidsql.length() - 1);
|
||||
}else{
|
||||
String temp = taskScheduling.getRemoteShell();
|
||||
// 清除最后一个;
|
||||
if (temp.indexOf(";") > -1 && temp.substring(temp.length() - 1, temp.length()).indexOf(";") > -1) {
|
||||
temp = temp.substring(0, temp.length() - 1);
|
||||
|
@ -347,7 +207,6 @@ public class LogOperation {
|
|||
}
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
luckyclient.publicclass.LogUtil.APP.error("执行取出指定任务ID中所属的调度是否要自动重启TOMCAT SQL出现异常,请确认数据库链接是否正常!", e);
|
||||
e.printStackTrace();
|
||||
return command;
|
||||
}
|
||||
|
@ -355,42 +214,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) {
|
||||
int inttaskid = Integer.parseInt(taskid);
|
||||
public static String getTestTime(String taskIdStr) {
|
||||
Integer taskId = Integer.parseInt(taskIdStr);
|
||||
String desTime = "计算测试时长出错!";
|
||||
try {
|
||||
String sql = dbt.executeQuery(
|
||||
"select date_format(t.createtime,'%Y-%m-%d %T'),date_format(t.finishtime,'%Y-%m-%d %T') from test_taskexcute t where t.id= "
|
||||
+ inttaskid);
|
||||
String starttime = sql.substring(0, sql.indexOf("%"));
|
||||
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);
|
||||
TaskExecute taskExecute = GetServerAPI.cgetTaskbyid(taskId);
|
||||
Date start = taskExecute.getCreateTime();
|
||||
if (null!= taskExecute.getFinishTime()) {
|
||||
Date finish = taskExecute.getFinishTime();
|
||||
long l = finish.getTime() - start.getTime();
|
||||
long day = l / (24 * 60 * 60 * 1000);
|
||||
long hour = (l / (60 * 60 * 1000) - day * 24);
|
||||
|
@ -401,7 +235,6 @@ public class LogOperation {
|
|||
}
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
luckyclient.publicclass.LogUtil.APP.error("执行获取任务测试时长SQL出现异常,请确认数据库链接是否正常!", e);
|
||||
e.printStackTrace();
|
||||
return desTime;
|
||||
}
|
||||
|
@ -409,93 +242,25 @@ public class LogOperation {
|
|||
}
|
||||
|
||||
/**
|
||||
* 查询web执行,浏览器类型
|
||||
* 查询web执行,浏览器类型 UI自动化浏览器类型 0 IE 1 火狐 2 谷歌 3 Edge
|
||||
*/
|
||||
public static int querydrivertype(String taskid) {
|
||||
int taskidtoint = Integer.parseInt(taskid);
|
||||
int drivertype = 0;
|
||||
public static int querydrivertype(String taskIdStr) {
|
||||
Integer taskId = Integer.parseInt(taskIdStr);
|
||||
Integer driverType = 0;
|
||||
try {
|
||||
String sqlresult = dbt.executeQuery(
|
||||
"select browsertype from test_jobs where id = (select jobid from test_taskexcute where id = "
|
||||
+ taskidtoint + ")");
|
||||
drivertype = Integer.parseInt(sqlresult.substring(0, sqlresult.lastIndexOf("%")));
|
||||
TaskScheduling taskScheduling = GetServerAPI.cGetTaskSchedulingByTaskId(taskId);
|
||||
driverType = taskScheduling.getBrowserType();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
luckyclient.publicclass.LogUtil.APP.error("执行查询web执行浏览器类型SQL出现异常,请确认数据库链接是否正常!", e);
|
||||
e.printStackTrace();
|
||||
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;
|
||||
return driverType;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
deleteTaskCaseLog(7, "46");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package luckyclient.jenkinsapi;
|
||||
|
||||
import luckyclient.dblog.LogOperation;
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
@ -24,7 +25,7 @@ public class BuildingInitialization {
|
|||
String result = JenkinsBuilding.buildingResult(buildname[i]);
|
||||
if(result.indexOf("alt=\"Failed\"")>-1){
|
||||
buildresult = "项目"+buildname[i]+"构建失败,自动化测试退出!";
|
||||
luckyclient.publicclass.LogUtil.APP.error("项目"+buildname[i]+"构建失败,自动化测试退出!");
|
||||
LogUtil.APP.warn("项目"+buildname[i]+"构建失败,自动化测试退出!");
|
||||
break;
|
||||
}else if(result.indexOf("alt=\"Success\"")>-1){
|
||||
k++;
|
||||
|
@ -33,7 +34,7 @@ public class BuildingInitialization {
|
|||
if(buildresult.indexOf("Status:true")<=-1){
|
||||
break;
|
||||
}
|
||||
luckyclient.publicclass.LogUtil.APP.info("正在检查构建中的项目(每6秒检查一次)。。。需要构建项目"+buildname.length+"个,目前成功"+k+"个");
|
||||
LogUtil.APP.info("正在检查构建中的项目(每6秒检查一次)。。。需要构建项目"+buildname.length+"个,目前成功"+k+"个");
|
||||
if(k==buildname.length){
|
||||
break;
|
||||
}
|
||||
|
@ -48,7 +49,7 @@ public class BuildingInitialization {
|
|||
String[] buildurl = LogOperation.getBuildName(tastid);
|
||||
|
||||
if(buildurl!=null){
|
||||
luckyclient.publicclass.LogUtil.APP.info("准备将配置的测试项目进行构建!请稍等。。。。");
|
||||
LogUtil.APP.info("准备将配置的测试项目进行构建!请稍等。。。。");
|
||||
for(int i=0;i<buildurl.length;i++){
|
||||
JenkinsBuilding.sendBuilding(buildurl[i]);
|
||||
}
|
||||
|
@ -56,11 +57,10 @@ public class BuildingInitialization {
|
|||
Thread.sleep(10000);
|
||||
result = booleanBuildingOver(buildurl);
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.info("当前任务没有找到需要构建的项目!");
|
||||
LogUtil.APP.info("当前任务没有找到需要构建的项目!");
|
||||
}
|
||||
}catch(Exception e){
|
||||
luckyclient.publicclass.LogUtil.APP.error("项目构建过程中出现异常");
|
||||
luckyclient.publicclass.LogUtil.APP.error(e);
|
||||
LogUtil.APP.error("项目构建过程中出现异常",e);
|
||||
result = "项目构建过程中出现异常";
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@ import java.net.URLConnection;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
|
@ -46,7 +48,7 @@ public class JenkinsBuilding {
|
|||
Map<String, List<String>> map = connection.getHeaderFields();
|
||||
// 遍历所有的响应头字段
|
||||
for (String key : map.keySet()) {
|
||||
luckyclient.publicclass.LogUtil.APP.info(key + "--->" + map.get(key));
|
||||
LogUtil.APP.info(key + "--->" + map.get(key));
|
||||
}
|
||||
// 定义 BufferedReader输入流来读取URL的响应
|
||||
in = new BufferedReader(new InputStreamReader(
|
||||
|
@ -56,7 +58,7 @@ public class JenkinsBuilding {
|
|||
result += line;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("发送构建请求(GET)时出现异常!", e);
|
||||
LogUtil.APP.error("发送构建请求(GET)时出现异常!", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
// 使用finally块来关闭输入流
|
||||
|
@ -102,7 +104,7 @@ public class JenkinsBuilding {
|
|||
Map<String, List<String>> map = connection.getHeaderFields();
|
||||
// 遍历所有的响应头字段
|
||||
for (String key : map.keySet()) {
|
||||
luckyclient.publicclass.LogUtil.APP.info(key + "--->" + map.get(key));
|
||||
LogUtil.APP.info(key + "--->" + map.get(key));
|
||||
}
|
||||
// 定义 BufferedReader输入流来读取URL的响应
|
||||
in = new BufferedReader(new InputStreamReader(
|
||||
|
@ -112,7 +114,7 @@ public class JenkinsBuilding {
|
|||
result += line;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("发送构建请求(GET)时出现异常!", e);
|
||||
LogUtil.APP.error("发送构建请求(GET)时出现异常!", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
// 使用finally块来关闭输入流
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package luckyclient.jenkinsapi;
|
||||
|
||||
import luckyclient.dblog.LogOperation;
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
@ -15,28 +16,26 @@ import luckyclient.dblog.LogOperation;
|
|||
*/
|
||||
public class RestartServerInitialization {
|
||||
|
||||
@SuppressWarnings("finally")
|
||||
public static String restartServerRun(String tastid){
|
||||
String result = "Status:true"+" 重启命令执行成功!";
|
||||
try{
|
||||
String[] command = LogOperation.getrestartcomm(tastid);
|
||||
String[] command = LogOperation.getRestartComm(tastid);
|
||||
if(command!=null){
|
||||
luckyclient.publicclass.LogUtil.APP.info("准备重启指定的TOMCAT!请稍等。。。参数个数:"+command.length);
|
||||
LogUtil.APP.info("准备重启指定的TOMCAT!请稍等。。。参数个数:"+command.length);
|
||||
if(command.length==5){
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始调用重启TOMCAT方法。。。参数0:"+command[0]+" 参数1:"+command[1]
|
||||
LogUtil.APP.info("开始调用重启TOMCAT方法。。。参数0:"+command[0]+" 参数1:"+command[1]
|
||||
+" 参数2:"+command[2]+" 参数3:"+command[3]+" 参数4:"+command[4]);
|
||||
result = RmtShellExecutor.sshShell(command[0], command[1], command[2], Integer.valueOf(command[3]), command[4]);
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.error("重启TOMCAT命令行参数出现异常,请检查配置信息!");
|
||||
LogUtil.APP.warn("重启TOMCAT命令行参数出现异常,请检查配置信息!");
|
||||
result = "重启TOMCAT命令行参数出现异常,请检查配置信息!";
|
||||
}
|
||||
}else{
|
||||
result = "Status:true"+" 当前任务没有找到需要重启的TOMCAT命令!";
|
||||
luckyclient.publicclass.LogUtil.APP.info("当前任务没有指定需要重启TOMCAT!");
|
||||
LogUtil.APP.info("当前任务没有指定需要重启TOMCAT!");
|
||||
}
|
||||
}catch(Throwable e){
|
||||
luckyclient.publicclass.LogUtil.APP.error("重启TOMCAT过程中出现异常");
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(),e);
|
||||
LogUtil.APP.error("重启TOMCAT过程中出现异常",e);
|
||||
result = "重启TOMCAT过程中出现异常";
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@ import com.jcraft.jsch.Channel;
|
|||
import com.jcraft.jsch.JSch;
|
||||
import com.jcraft.jsch.Session;
|
||||
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
|
||||
/**
|
||||
* 远程执行shell脚本类
|
||||
* @author l
|
||||
|
@ -31,7 +33,7 @@ public class RmtShellExecutor {
|
|||
String result = "Status:true"+" 重启命令执行成功!";
|
||||
try {
|
||||
JSch jsch = new JSch();
|
||||
luckyclient.publicclass.LogUtil.APP.info("进入到重启TOMCAT方法。。。");
|
||||
LogUtil.APP.info("进入到重启TOMCAT方法。。。");
|
||||
//设置密钥和密码
|
||||
if (privateKey != null && !"".equals(privateKey)) {
|
||||
if (passphrase != null && "".equals(passphrase)) {
|
||||
|
@ -45,18 +47,18 @@ public class RmtShellExecutor {
|
|||
|
||||
if(port <=0){
|
||||
//连接服务器,采用默认端口
|
||||
luckyclient.publicclass.LogUtil.APP.info("设置重启TOMCAT服务器IP及默认端口。。。");
|
||||
LogUtil.APP.info("设置重启TOMCAT服务器IP及默认端口。。。");
|
||||
session = jsch.getSession(user, ip);
|
||||
}else{
|
||||
//采用指定的端口连接服务器
|
||||
luckyclient.publicclass.LogUtil.APP.info("设置重启TOMCAT服务器IP及端口。。。");
|
||||
LogUtil.APP.info("设置重启TOMCAT服务器IP及端口。。。");
|
||||
session = jsch.getSession(user, ip ,port);
|
||||
luckyclient.publicclass.LogUtil.APP.info("设置重启TOMCAT服务器IP及端口完成!");
|
||||
LogUtil.APP.info("设置重启TOMCAT服务器IP及端口完成!");
|
||||
}
|
||||
|
||||
//如果服务器连接不上,则抛出异常
|
||||
if (session == null) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("重启TOMCAT过程中,链接服务器session is null");
|
||||
LogUtil.APP.warn("重启TOMCAT过程中,链接服务器session is null");
|
||||
result = "重启TOMCAT过程中,链接服务器session is null";
|
||||
throw new Exception("session is null");
|
||||
}
|
||||
|
@ -76,7 +78,7 @@ public class RmtShellExecutor {
|
|||
OutputStream outstream = channel.getOutputStream();
|
||||
|
||||
//发送需要执行的SHELL命令,需要用\n结尾,表示回车
|
||||
luckyclient.publicclass.LogUtil.APP.info("准备往重启TOMCAT服务器发送命令!");
|
||||
LogUtil.APP.info("准备往重启TOMCAT服务器发送命令!");
|
||||
String shellCommand = command+" \n";
|
||||
outstream.write(shellCommand.getBytes());
|
||||
outstream.flush();
|
||||
|
@ -87,20 +89,20 @@ public class RmtShellExecutor {
|
|||
byte[] data = new byte[instream.available()];
|
||||
int nLen = instream.read(data);
|
||||
if (nLen < 0) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("重启TOMCAT过程中,获取命令执行结果出现异常!");
|
||||
LogUtil.APP.warn("重启TOMCAT过程中,获取命令执行结果出现异常!");
|
||||
result = "重启TOMCAT过程中,获取命令执行结果出现异常!";
|
||||
throw new Exception("network error.");
|
||||
}
|
||||
|
||||
//转换输出结果并打印出来
|
||||
String temp = new String(data, 0, nLen,"iso8859-1");
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始打印重启TOMCAT命令执行结果"+temp);
|
||||
LogUtil.APP.info("开始打印重启TOMCAT命令执行结果"+temp);
|
||||
}
|
||||
outstream.close();
|
||||
instream.close();
|
||||
} catch (Exception e) {
|
||||
result = "重启TOMCAT过程中,出现异常!";
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
return result;
|
||||
} finally {
|
||||
if(null!=session){
|
||||
|
|
|
@ -8,6 +8,7 @@ import java.util.Properties;
|
|||
import freemarker.cache.ClassTemplateLoader;
|
||||
import freemarker.template.Configuration;
|
||||
import freemarker.template.Template;
|
||||
import luckyclient.publicclass.SysConfig;
|
||||
|
||||
/**
|
||||
* 基于Freemarker模板技术的邮件模板服务
|
||||
|
@ -15,7 +16,7 @@ import freemarker.template.Template;
|
|||
* @author Administrator
|
||||
*/
|
||||
public class FreemarkerEmailTemplate {
|
||||
Properties properties = luckyclient.publicclass.SysConfig.getConfiguration();
|
||||
Properties properties = SysConfig.getConfiguration();
|
||||
/**
|
||||
* 邮件模板的存放位置
|
||||
*/
|
||||
|
|
|
@ -4,8 +4,10 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import luckyclient.planapi.entity.ProjectProtocolTemplate;
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
import luckyclient.publicclass.SysConfig;
|
||||
import luckyclient.publicclass.remoterinterface.HttpClientHelper;
|
||||
import luckyclient.serverapi.entity.ProjectProtocolTemplate;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
@ -34,9 +36,9 @@ public class HtmlMail {
|
|||
parameters.put("jobname", jobname);
|
||||
try {
|
||||
Map<String, String> headmsg = new HashMap<>(0);
|
||||
Properties properties = luckyclient.publicclass.SysConfig.getConfiguration();
|
||||
Properties properties = SysConfig.getConfiguration();
|
||||
if ("true".equals(properties.getProperty("task.push.switch").toLowerCase())) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始向第三方平台推送任务执行情况....");
|
||||
LogUtil.APP.info("开始向第三方平台推送任务执行情况....");
|
||||
Map<String, Object> pushparameters = new HashMap<>(0);
|
||||
pushparameters.put("buildstatus", buildstatus);
|
||||
pushparameters.put("restartstatus", restartstatus);
|
||||
|
@ -51,12 +53,12 @@ public class HtmlMail {
|
|||
|
||||
String pushurl = properties.getProperty("task.push.url");
|
||||
ProjectProtocolTemplate ppt=new ProjectProtocolTemplate();
|
||||
ppt.setContentencoding("utf-8");
|
||||
ppt.setConnecttimeout(60);
|
||||
ppt.setEncoding("utf-8");
|
||||
ppt.setTimeout(60);
|
||||
HttpClientHelper.httpClientPostJson(pushurl, pushparameters, headmsg,ppt);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("向第三方平台推送任务执行情况出现异常,请检查!", e);
|
||||
LogUtil.APP.error("向第三方平台推送任务执行情况出现异常,请检查!", e);
|
||||
e.printStackTrace();
|
||||
return fet.getText("task-body", parameters);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package luckyclient.mail;
|
||||
|
||||
import luckyclient.dblog.LogOperation;
|
||||
import luckyclient.planapi.entity.TestJobs;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import luckyclient.dblog.LogOperation;
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
import luckyclient.publicclass.SysConfig;
|
||||
import luckyclient.serverapi.entity.TaskScheduling;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
|
@ -17,13 +19,13 @@ import java.util.Properties;
|
|||
*/
|
||||
public class MailSendInitialization {
|
||||
|
||||
public static void sendMailInitialization(String subject, String content, String taskid, TestJobs testJob, int[] taskCount) {
|
||||
public static void sendMailInitialization(String subject, String content, String taskid, TaskScheduling taskScheduling, int[] taskCount) {
|
||||
boolean isSend = false;
|
||||
if (null == taskCount) {
|
||||
isSend = true;
|
||||
} else {
|
||||
if (taskCount.length == 5 && null != testJob) {
|
||||
Integer sendCondition = testJob.getSendCondition();
|
||||
if (taskCount.length == 5 && null != taskScheduling) {
|
||||
Integer sendCondition = taskScheduling.getEmailSendCondition();
|
||||
// 用例全部成功了发送, casecount != casesuc
|
||||
if (null!=sendCondition&&1 == sendCondition) {
|
||||
if (taskCount[0] == taskCount[1]) {
|
||||
|
@ -43,13 +45,13 @@ public class MailSendInitialization {
|
|||
}
|
||||
}
|
||||
if (!isSend) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("当前任务不需要发送邮件通知!");
|
||||
LogUtil.APP.info("当前任务不需要发送邮件通知!");
|
||||
return;
|
||||
}
|
||||
String[] addresses = LogOperation.getEmailAddress(taskid);
|
||||
Properties properties = luckyclient.publicclass.SysConfig.getConfiguration();
|
||||
Properties properties = SysConfig.getConfiguration();
|
||||
if (addresses != null) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("准备将测试结果发送邮件通知!请稍等。。。。");
|
||||
LogUtil.APP.info("准备将测试结果发送邮件通知!请稍等。。。。");
|
||||
//这个类主要是设置邮件
|
||||
MailSenderInfo mailInfo = new MailSenderInfo();
|
||||
//这个类主要来发送邮件
|
||||
|
@ -75,12 +77,12 @@ public class MailSendInitialization {
|
|||
}
|
||||
String addressesmail = stringBuilder.toString();
|
||||
if (sms.sendHtmlMail(mailInfo)) {
|
||||
luckyclient.publicclass.LogUtil.APP.info("给" + addressesmail + "的测试结果通知邮件发送完成!");
|
||||
LogUtil.APP.info("给" + addressesmail + "的测试结果通知邮件发送完成!");
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("给" + addressesmail + "的测试结果通知邮件发送失败!");
|
||||
LogUtil.APP.warn("给" + addressesmail + "的测试结果通知邮件发送失败!");
|
||||
}
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.info("当前任务不需要发送邮件通知!");
|
||||
LogUtil.APP.info("当前任务不需要发送邮件通知!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package luckyclient.mail;
|
||||
|
||||
import com.sun.mail.util.MailSSLSocketFactory;
|
||||
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.util.Properties;
|
||||
|
||||
import com.sun.mail.util.MailSSLSocketFactory;
|
||||
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
|
@ -76,7 +78,7 @@ public class MailSenderInfo {
|
|||
p.put("mail.smtp.ssl.socketFactory", sf);
|
||||
}
|
||||
} catch (GeneralSecurityException e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("获得邮件会话属性失败或异常: " + e.getMessage());
|
||||
LogUtil.APP.error("获得邮件会话属性失败或异常: " + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
return p;
|
||||
|
|
|
@ -15,6 +15,8 @@ import javax.mail.internet.MimeBodyPart;
|
|||
import javax.mail.internet.MimeMessage;
|
||||
import javax.mail.internet.MimeMultipart;
|
||||
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
|
@ -119,7 +121,7 @@ public class SimpleMailSender {
|
|||
return true;
|
||||
} catch (MessagingException ex) {
|
||||
ex.printStackTrace();
|
||||
luckyclient.publicclass.LogUtil.APP.error(ex);
|
||||
LogUtil.APP.error("邮件发送异常", ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,145 +0,0 @@
|
|||
package luckyclient.planapi.api;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import luckyclient.planapi.entity.ProjectCase;
|
||||
import luckyclient.planapi.entity.ProjectCasesteps;
|
||||
import luckyclient.planapi.entity.PublicCaseParams;
|
||||
import luckyclient.planapi.entity.TestTaskexcute;
|
||||
import luckyclient.publicclass.remoterinterface.HttpRequest;
|
||||
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||
* =================================================================
|
||||
*
|
||||
* @author: seagull
|
||||
* @date 2017年12月1日 上午9:29:40
|
||||
*
|
||||
*/
|
||||
public class GetServerAPI {
|
||||
/**
|
||||
* 通过计划ID获取测试用例对象集
|
||||
* @param planid
|
||||
* @return
|
||||
*/
|
||||
public static List<ProjectCase> getCasesbyplanid(int planid) {
|
||||
String result = HttpRequest.loadJSON("/projectPlanCase/cgetcasebyplanid.do?planid=" + planid);
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
|
||||
List<ProjectCase> caseslist = new ArrayList<ProjectCase>();
|
||||
caseslist = JSONObject.parseArray(jsonObject.getString("cases"), ProjectCase.class);
|
||||
return caseslist;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过计划名称获取测试用例对象集
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public static List<ProjectCase> getCasesbyplanname(String name) {
|
||||
String result = HttpRequest.loadJSON("/projectPlanCase/cgetcasebyplanname.do?name=" + name);
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
|
||||
List<ProjectCase> caseslist = new ArrayList<ProjectCase>();
|
||||
caseslist = JSONObject.parseArray(jsonObject.getString("cases"), ProjectCase.class);
|
||||
return caseslist;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用例ID获取下面的步骤对象
|
||||
* @param caseid
|
||||
* @return
|
||||
*/
|
||||
public static List<ProjectCasesteps> getStepsbycaseid(int caseid) {
|
||||
String result = HttpRequest.loadJSON("/projectCasesteps/cgetStepsByCase.do?caseid=" + caseid);
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
|
||||
List<ProjectCasesteps> stepslist = new ArrayList<ProjectCasesteps>();
|
||||
stepslist = JSONObject.parseArray(jsonObject.getString("steps"), ProjectCasesteps.class);
|
||||
return stepslist;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过taskid获取对象
|
||||
* @param taskid
|
||||
* @return
|
||||
*/
|
||||
public static TestTaskexcute cgetTaskbyid(int taskid) {
|
||||
String result = HttpRequest.loadJSON("/tastExecute/cgettaskbyid.do?taskid=" + taskid);
|
||||
TestTaskexcute task = JSONObject.parseObject(result, TestTaskexcute.class);
|
||||
return task;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用例编号获取对象
|
||||
* @param sign
|
||||
* @return
|
||||
*/
|
||||
public static ProjectCase cgetCaseBysign(String sign) {
|
||||
String result = HttpRequest.loadJSON("/projectCase/cgetcasebysign.do?sign=" + sign);
|
||||
ProjectCase pc = JSONObject.parseObject(result, ProjectCase.class);
|
||||
return pc;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目下的所有公共参数
|
||||
* @param projectid
|
||||
* @return
|
||||
*/
|
||||
public static List<PublicCaseParams> cgetParamsByProjectid(String projectid) {
|
||||
String result = HttpRequest.loadJSON("/publicCaseParams/cgetParamsByProjectid.do?projectid="+projectid);
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
|
||||
List<PublicCaseParams> paramslist = new ArrayList<PublicCaseParams>();
|
||||
paramslist = JSONObject.parseArray(jsonObject.getString("params"), PublicCaseParams.class);
|
||||
return paramslist;
|
||||
}
|
||||
|
||||
/**
|
||||
* put web界面的数据到服务端
|
||||
* @param sign
|
||||
* @param executor
|
||||
* @param loglevel
|
||||
* @param detail
|
||||
*/
|
||||
public static void cPostDebugLog(String sign, String executor, String loglevel, String detail){
|
||||
sign = sign.replace("%","BBFFHH");
|
||||
sign = sign.replace("=","DHDHDH");
|
||||
sign = sign.replace("&","ANDAND");
|
||||
detail = detail.replace("%","BBFFHH");
|
||||
detail = detail.replace("=","DHDHDH");
|
||||
detail = detail.replace("&","ANDAND");
|
||||
String params = "";
|
||||
params = "sign=" + sign;
|
||||
params += "&executor=" + executor;
|
||||
params += "&executor=" + executor;
|
||||
params += "&loglevel=" + loglevel;
|
||||
params += "&detail=" + detail;
|
||||
|
||||
HttpRequest.sendPost("/projectCasesteps/cPostDebugLog.do", params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 供其他系统远程调用调度任务,启动执行
|
||||
* @param jobid
|
||||
* @return
|
||||
* @throws UnsupportedEncodingException
|
||||
*/
|
||||
public static String cRunJobForId(String jobid) throws UnsupportedEncodingException {
|
||||
String result = HttpRequest.loadJSON("/testJobs/runJobForInterface.do?jobid=" + jobid);
|
||||
return new String(result.getBytes("GBK"), "UTF-8");
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws UnsupportedEncodingException {
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,127 +0,0 @@
|
|||
package luckyclient.planapi.entity;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||
* =================================================================
|
||||
*
|
||||
* @author: seagull
|
||||
* @date 2017年12月1日 上午9:29:40
|
||||
*
|
||||
*/
|
||||
public class ProjectCase implements java.io.Serializable{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private int id;
|
||||
private String sign;
|
||||
private String name;
|
||||
private int projectid;
|
||||
private int moduleid;
|
||||
private String[] moduleidarr;
|
||||
private String modulename;
|
||||
private String projectname;
|
||||
private String remark;
|
||||
private int casetype;
|
||||
private String time;
|
||||
private String operationer;
|
||||
private int priority;
|
||||
private int checktype;
|
||||
// 失败了是否继续
|
||||
private Integer failcontinue;
|
||||
|
||||
public String getModulename() {
|
||||
return modulename;
|
||||
}
|
||||
public void setModulename(String modulename) {
|
||||
this.modulename = modulename;
|
||||
}
|
||||
public int getModuleid() {
|
||||
return moduleid;
|
||||
}
|
||||
public void setModuleid(int moduleid) {
|
||||
this.moduleid = moduleid;
|
||||
}
|
||||
public String[] getModuleidarr() {
|
||||
return moduleidarr;
|
||||
}
|
||||
public void setModuleidarr(String[] moduleidarr) {
|
||||
this.moduleidarr = moduleidarr;
|
||||
}
|
||||
public int getChecktype() {
|
||||
return checktype;
|
||||
}
|
||||
public void setChecktype(int checktype) {
|
||||
this.checktype = checktype;
|
||||
}
|
||||
public int getPriority() {
|
||||
return priority;
|
||||
}
|
||||
public void setPriority(int priority) {
|
||||
this.priority = priority;
|
||||
}
|
||||
public String getProjectname() {
|
||||
return projectname;
|
||||
}
|
||||
public void setProjectname(String projectname) {
|
||||
this.projectname = projectname;
|
||||
}
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
public String getSign() {
|
||||
return sign;
|
||||
}
|
||||
public void setSign(String sign) {
|
||||
this.sign = sign;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public int getProjectid() {
|
||||
return projectid;
|
||||
}
|
||||
public void setProjectid(int projectid) {
|
||||
this.projectid = projectid;
|
||||
}
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
public int getCasetype() {
|
||||
return casetype;
|
||||
}
|
||||
public void setCasetype(int casetype) {
|
||||
this.casetype = casetype;
|
||||
}
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
public void setTime(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
public String getOperationer() {
|
||||
return operationer;
|
||||
}
|
||||
public void setOperationer(String operationer) {
|
||||
this.operationer = operationer;
|
||||
}
|
||||
public Integer getFailcontinue() {
|
||||
return failcontinue;
|
||||
}
|
||||
public void setFailcontinue(Integer failcontinue) {
|
||||
this.failcontinue = failcontinue;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,113 +0,0 @@
|
|||
package luckyclient.planapi.entity;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||
* =================================================================
|
||||
*
|
||||
* @author: seagull
|
||||
* @date 2017年12月1日 上午9:29:40
|
||||
*
|
||||
*/
|
||||
public class ProjectCasesteps implements java.io.Serializable{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private int id;
|
||||
private String path;
|
||||
private String operation;
|
||||
private String parameters;
|
||||
private String action;
|
||||
private int caseid;
|
||||
private int stepnum;
|
||||
private String expectedresult;
|
||||
private int projectid;
|
||||
private int steptype;
|
||||
private String time;
|
||||
private String operationer;
|
||||
private String extend;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
public String getOperation() {
|
||||
return operation;
|
||||
}
|
||||
public void setOperation(String operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
public String getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
public void setParameters(String parameters) {
|
||||
this.parameters = parameters;
|
||||
}
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
public void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
public int getCaseid() {
|
||||
return caseid;
|
||||
}
|
||||
public void setCaseid(int caseid) {
|
||||
this.caseid = caseid;
|
||||
}
|
||||
public int getStepnum() {
|
||||
return stepnum;
|
||||
}
|
||||
public void setStepnum(int stepnum) {
|
||||
this.stepnum = stepnum;
|
||||
}
|
||||
public String getExpectedresult() {
|
||||
return expectedresult;
|
||||
}
|
||||
public void setExpectedresult(String expectedresult) {
|
||||
this.expectedresult = expectedresult;
|
||||
}
|
||||
public int getProjectid() {
|
||||
return projectid;
|
||||
}
|
||||
public void setProjectid(int projectid) {
|
||||
this.projectid = projectid;
|
||||
}
|
||||
public int getSteptype() {
|
||||
return steptype;
|
||||
}
|
||||
public void setSteptype(int steptype) {
|
||||
this.steptype = steptype;
|
||||
}
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
public void setTime(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
public String getOperationer() {
|
||||
return operationer;
|
||||
}
|
||||
public void setOperationer(String operationer) {
|
||||
this.operationer = operationer;
|
||||
}
|
||||
public String getExtend() {
|
||||
return extend;
|
||||
}
|
||||
public void setExtend(String extend) {
|
||||
this.extend = extend;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
package luckyclient.planapi.entity;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||
* =================================================================
|
||||
*
|
||||
* @author: seagull
|
||||
* @date 2017年12月1日 上午9:29:40
|
||||
*
|
||||
*/
|
||||
public class ProjectPlan implements java.io.Serializable{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private int id;
|
||||
private int projectid;
|
||||
private String name;
|
||||
private int casecount;
|
||||
private String remark;
|
||||
private String time;
|
||||
private String operationer;
|
||||
private String projectname;
|
||||
|
||||
public String getProjectname() {
|
||||
return projectname;
|
||||
}
|
||||
public void setProjectname(String projectname) {
|
||||
this.projectname = projectname;
|
||||
}
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
public int getProjectid() {
|
||||
return projectid;
|
||||
}
|
||||
public void setProjectid(int projectid) {
|
||||
this.projectid = projectid;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public int getCasecount() {
|
||||
return casecount;
|
||||
}
|
||||
public void setCasecount(int casecount) {
|
||||
this.casecount = casecount;
|
||||
}
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
public void setTime(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
public String getOperationer() {
|
||||
return operationer;
|
||||
}
|
||||
public void setOperationer(String operationer) {
|
||||
this.operationer = operationer;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
package luckyclient.planapi.entity;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||
* =================================================================
|
||||
*
|
||||
* @author: seagull
|
||||
* @date 2017年12月1日 上午9:29:40
|
||||
*
|
||||
*/
|
||||
public class ProjectPlanCase implements java.io.Serializable{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private int id;
|
||||
private int caseid;
|
||||
private int planid;
|
||||
private int priority;
|
||||
|
||||
public int getPriority() {
|
||||
return priority;
|
||||
}
|
||||
public void setPriority(int priority) {
|
||||
this.priority = priority;
|
||||
}
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
public int getCaseid() {
|
||||
return caseid;
|
||||
}
|
||||
public void setCaseid(int caseid) {
|
||||
this.caseid = caseid;
|
||||
}
|
||||
public int getPlanid() {
|
||||
return planid;
|
||||
}
|
||||
public void setPlanid(int planid) {
|
||||
this.planid = planid;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,121 +0,0 @@
|
|||
package luckyclient.planapi.entity;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||
* =================================================================
|
||||
*
|
||||
* @author: seagull
|
||||
* @date 2017年12月1日 上午9:29:40
|
||||
*
|
||||
*/
|
||||
public class ProjectProtocolTemplate{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private int id;
|
||||
private int projectid;
|
||||
private String name;
|
||||
private String protocoltype;
|
||||
private String cerpath;
|
||||
private String contentencoding;
|
||||
private int connecttimeout;
|
||||
private int responsehead;
|
||||
private int responsecode;
|
||||
private String time;
|
||||
private String operationer;
|
||||
private String remark;
|
||||
private String projectname;
|
||||
private String headmsg;
|
||||
|
||||
|
||||
public String getCerpath() {
|
||||
return cerpath;
|
||||
}
|
||||
public void setCerpath(String cerpath) {
|
||||
this.cerpath = cerpath;
|
||||
}
|
||||
public String getHeadmsg() {
|
||||
return headmsg;
|
||||
}
|
||||
public void setHeadmsg(String headmsg) {
|
||||
this.headmsg = headmsg;
|
||||
}
|
||||
public String getProjectname() {
|
||||
return projectname;
|
||||
}
|
||||
public void setProjectname(String projectname) {
|
||||
this.projectname = projectname;
|
||||
}
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
public int getProjectid() {
|
||||
return projectid;
|
||||
}
|
||||
public void setProjectid(int projectid) {
|
||||
this.projectid = projectid;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getProtocoltype() {
|
||||
return protocoltype;
|
||||
}
|
||||
public void setProtocoltype(String protocoltype) {
|
||||
this.protocoltype = protocoltype;
|
||||
}
|
||||
public String getContentencoding() {
|
||||
return contentencoding;
|
||||
}
|
||||
public void setContentencoding(String contentencoding) {
|
||||
this.contentencoding = contentencoding;
|
||||
}
|
||||
public int getConnecttimeout() {
|
||||
return connecttimeout;
|
||||
}
|
||||
public void setConnecttimeout(int connecttimeout) {
|
||||
this.connecttimeout = connecttimeout;
|
||||
}
|
||||
public int getResponsehead() {
|
||||
return responsehead;
|
||||
}
|
||||
public void setResponsehead(int responsehead) {
|
||||
this.responsehead = responsehead;
|
||||
}
|
||||
public int getResponsecode() {
|
||||
return responsecode;
|
||||
}
|
||||
public void setResponsecode(int responsecode) {
|
||||
this.responsecode = responsecode;
|
||||
}
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
public void setTime(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
public String getOperationer() {
|
||||
return operationer;
|
||||
}
|
||||
public void setOperationer(String operationer) {
|
||||
this.operationer = operationer;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
package luckyclient.planapi.entity;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||
* =================================================================
|
||||
*
|
||||
* @author: seagull
|
||||
* @date 2017年12月1日 上午9:29:40
|
||||
*
|
||||
*/
|
||||
public class ProjectTemplateParams{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private int id;
|
||||
private int templateid;
|
||||
private String paramname;
|
||||
private String param;
|
||||
private int paramtype;
|
||||
|
||||
public int getParamtype() {
|
||||
return paramtype;
|
||||
}
|
||||
public void setParamtype(int paramtype) {
|
||||
this.paramtype = paramtype;
|
||||
}
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
public int getTemplateid() {
|
||||
return templateid;
|
||||
}
|
||||
public void setTemplateid(int templateid) {
|
||||
this.templateid = templateid;
|
||||
}
|
||||
public String getParamname() {
|
||||
return paramname;
|
||||
}
|
||||
public void setParamname(String paramname) {
|
||||
this.paramname = paramname;
|
||||
}
|
||||
public String getParam() {
|
||||
return param;
|
||||
}
|
||||
public void setParam(String param) {
|
||||
this.param = param;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
package luckyclient.planapi.entity;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||
* =================================================================
|
||||
*
|
||||
* @author: seagull
|
||||
* @date 2017年12月1日 上午9:29:40
|
||||
*
|
||||
*/
|
||||
public class PublicCaseParams implements java.io.Serializable{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private int id;
|
||||
private String paramsname;
|
||||
private String paramsvalue;
|
||||
private String remark;
|
||||
private int projectid;
|
||||
private String projectname;
|
||||
|
||||
public String getProjectname() {
|
||||
return projectname;
|
||||
}
|
||||
public void setProjectname(String projectname) {
|
||||
this.projectname = projectname;
|
||||
}
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
public String getParamsname() {
|
||||
return paramsname;
|
||||
}
|
||||
public void setParamsname(String paramsname) {
|
||||
this.paramsname = paramsname;
|
||||
}
|
||||
public String getParamsvalue() {
|
||||
return paramsvalue;
|
||||
}
|
||||
public void setParamsvalue(String paramsvalue) {
|
||||
this.paramsvalue = paramsvalue;
|
||||
}
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
public int getProjectid() {
|
||||
return projectid;
|
||||
}
|
||||
public void setProjectid(int projectid) {
|
||||
this.projectid = projectid;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,393 +0,0 @@
|
|||
package luckyclient.planapi.entity;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||
* =================================================================
|
||||
*
|
||||
* @author: seagull
|
||||
* @date 2017年12月1日 上午9:29:40
|
||||
*
|
||||
*/
|
||||
public class TestJobs implements java.io.Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private int id;
|
||||
private String taskName;
|
||||
private String startDate;
|
||||
private String startTime;
|
||||
private String endDate;
|
||||
private String endTime;
|
||||
private String runTime;
|
||||
private String remark;
|
||||
|
||||
private String planproj;
|
||||
private String state;
|
||||
private String state_str;
|
||||
/**
|
||||
* 线程数
|
||||
*/
|
||||
private int threadCount;
|
||||
/**
|
||||
* 自定义时间
|
||||
*/
|
||||
private int time;
|
||||
private String timeType;
|
||||
/**
|
||||
* 是否发送邮件
|
||||
*/
|
||||
private String isSendMail;
|
||||
/**
|
||||
* 收件人
|
||||
*/
|
||||
private String emailer;
|
||||
private String testlinkname;
|
||||
/**
|
||||
* 是否构建
|
||||
*/
|
||||
private String isbuilding;
|
||||
/**
|
||||
* 构建在JENKINS中的名称
|
||||
*/
|
||||
private String buildname;
|
||||
/**
|
||||
* 是否重启
|
||||
*/
|
||||
private String isrestart;
|
||||
/**
|
||||
* 构建在JENKINS中的名称
|
||||
*/
|
||||
private String restartcomm;
|
||||
/**
|
||||
* 0:接口自动化 1:WebDriver自动化
|
||||
*/
|
||||
private int extype;
|
||||
/**
|
||||
* 0:ie 1:火狐 2:谷歌 3:Edge
|
||||
*/
|
||||
private Integer browsertype;
|
||||
/**
|
||||
* 任务超时时间 单位:分钟
|
||||
*/
|
||||
private Integer timeout;
|
||||
/**
|
||||
* 客户端IP
|
||||
*/
|
||||
private String clientip;
|
||||
/**
|
||||
* 项目类型 0testlink 1系统内项目
|
||||
*/
|
||||
private Integer projecttype;
|
||||
/**
|
||||
* 系统内项目ID
|
||||
*/
|
||||
private Integer projectid;
|
||||
/**
|
||||
* 系统内项目关联计划ID
|
||||
*/
|
||||
private Integer planid;
|
||||
private String taskType;
|
||||
private String startTimestr;
|
||||
private String endTimestr;
|
||||
private String createTime;
|
||||
private String noEndDate;
|
||||
// 发送条件
|
||||
private Integer sendCondition;
|
||||
|
||||
public Integer getProjecttype() {
|
||||
return projecttype;
|
||||
}
|
||||
|
||||
public void setProjecttype(Integer projecttype) {
|
||||
this.projecttype = projecttype;
|
||||
}
|
||||
|
||||
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 String getClientip() {
|
||||
return clientip;
|
||||
}
|
||||
|
||||
public void setClientip(String clientip) {
|
||||
this.clientip = clientip;
|
||||
}
|
||||
|
||||
public Integer getTimeout() {
|
||||
return timeout;
|
||||
}
|
||||
|
||||
public void setTimeout(Integer timeout) {
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
public Integer getBrowsertype() {
|
||||
return browsertype;
|
||||
}
|
||||
|
||||
public void setBrowsertype(Integer browsertype) {
|
||||
this.browsertype = browsertype;
|
||||
}
|
||||
|
||||
public int getExtype() {
|
||||
return extype;
|
||||
}
|
||||
|
||||
public void setExtype(int extype) {
|
||||
this.extype = extype;
|
||||
}
|
||||
|
||||
public String getIsrestart() {
|
||||
return isrestart;
|
||||
}
|
||||
|
||||
public void setIsrestart(String isrestart) {
|
||||
this.isrestart = isrestart;
|
||||
}
|
||||
|
||||
public String getRestartcomm() {
|
||||
return restartcomm;
|
||||
}
|
||||
|
||||
public void setRestartcomm(String restartcomm) {
|
||||
this.restartcomm = restartcomm;
|
||||
}
|
||||
|
||||
public String getIsbuilding() {
|
||||
return isbuilding;
|
||||
}
|
||||
|
||||
public void setIsbuilding(String isbuilding) {
|
||||
this.isbuilding = isbuilding;
|
||||
}
|
||||
|
||||
public String getBuildname() {
|
||||
return buildname;
|
||||
}
|
||||
|
||||
public void setBuildname(String buildname) {
|
||||
this.buildname = buildname;
|
||||
}
|
||||
|
||||
public int getThreadCount() {
|
||||
return threadCount;
|
||||
}
|
||||
|
||||
public void setThreadCount(int threadCount) {
|
||||
this.threadCount = threadCount;
|
||||
}
|
||||
|
||||
public String getTestlinkname() {
|
||||
return testlinkname;
|
||||
}
|
||||
|
||||
public void setTestlinkname(String testlinkname) {
|
||||
this.testlinkname = testlinkname;
|
||||
}
|
||||
|
||||
public String getIsSendMail() {
|
||||
return isSendMail;
|
||||
}
|
||||
|
||||
public void setIsSendMail(String isSendMail) {
|
||||
this.isSendMail = isSendMail;
|
||||
}
|
||||
|
||||
public String getEmailer() {
|
||||
return emailer;
|
||||
}
|
||||
|
||||
public void setEmailer(String emailer) {
|
||||
this.emailer = emailer;
|
||||
}
|
||||
|
||||
public String getTimeType() {
|
||||
return timeType;
|
||||
}
|
||||
|
||||
public void setTimeType(String timeType) {
|
||||
this.timeType = timeType;
|
||||
}
|
||||
|
||||
public int getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(int time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getState_str() {
|
||||
return state_str;
|
||||
}
|
||||
|
||||
public void setState_str(String state_str) {
|
||||
this.state_str = state_str;
|
||||
}
|
||||
|
||||
private boolean showRun = true;
|
||||
|
||||
public TestJobs() {
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务名称不能为空
|
||||
*/
|
||||
public String getTaskName() {
|
||||
return taskName;
|
||||
}
|
||||
|
||||
public void setTaskName(String taskName) {
|
||||
this.taskName = taskName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始日期的时间格式应为:yyyy-MM-dd
|
||||
*/
|
||||
public String getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(String startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 开始时间的时间格式应为:HH:mm:ss
|
||||
*/
|
||||
public String getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(String startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public String getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(String endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
public String getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(String endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public String getRunTime() {
|
||||
return runTime;
|
||||
}
|
||||
|
||||
public void setRunTime(String runTime) {
|
||||
this.runTime = runTime;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public String getPlanproj() {
|
||||
return planproj;
|
||||
}
|
||||
|
||||
public void setPlanproj(String planproj) {
|
||||
this.planproj = planproj;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getTaskType() {
|
||||
return taskType;
|
||||
}
|
||||
|
||||
public void setTaskType(String taskType) {
|
||||
this.taskType = taskType;
|
||||
}
|
||||
|
||||
public String getStartTimestr() {
|
||||
return startTimestr;
|
||||
}
|
||||
|
||||
public void setStartTimestr(String startTimestr) {
|
||||
this.startTimestr = startTimestr;
|
||||
}
|
||||
|
||||
public String getEndTimestr() {
|
||||
return endTimestr;
|
||||
}
|
||||
|
||||
public void setEndTimestr(String endTimestr) {
|
||||
this.endTimestr = endTimestr;
|
||||
}
|
||||
|
||||
public String getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(String createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public String getNoEndDate() {
|
||||
return noEndDate;
|
||||
}
|
||||
|
||||
public void setNoEndDate(String noEndDate) {
|
||||
this.noEndDate = noEndDate;
|
||||
}
|
||||
|
||||
public boolean isShowRun() {
|
||||
return showRun;
|
||||
}
|
||||
|
||||
public void setShowRun(boolean showRun) {
|
||||
this.showRun = showRun;
|
||||
}
|
||||
|
||||
public Integer getSendCondition() {
|
||||
return sendCondition;
|
||||
}
|
||||
|
||||
public void setSendCondition(Integer sendCondition) {
|
||||
this.sendCondition = sendCondition;
|
||||
}
|
||||
}
|
|
@ -1,215 +0,0 @@
|
|||
package luckyclient.planapi.entity;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||
* =================================================================
|
||||
*
|
||||
* @author: seagull
|
||||
* @date 2017年12月1日 上午9:29:40
|
||||
*
|
||||
*/
|
||||
public class TestTaskexcute implements java.io.Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private int id;
|
||||
private String taskId;
|
||||
private int casetotalCount = 0;
|
||||
private int casesuccCount = 0;
|
||||
private int casefailCount = 0;
|
||||
private int caselockCount = 0;
|
||||
private int casenoexecCount = 0;
|
||||
private TestJobs testJob = new TestJobs();
|
||||
|
||||
private int jobid;
|
||||
private int projectid;
|
||||
private String caseIsExec;
|
||||
private String finishtime;
|
||||
private String taskStatus;
|
||||
|
||||
private String startDate;
|
||||
private String endDate;
|
||||
private String name;
|
||||
|
||||
private String taskName;
|
||||
|
||||
public int getProjectid() {
|
||||
return projectid;
|
||||
}
|
||||
|
||||
public void setProjectid(int projectid) {
|
||||
this.projectid = projectid;
|
||||
}
|
||||
|
||||
public String getTaskName() {
|
||||
return taskName;
|
||||
}
|
||||
|
||||
public void setTaskName(String taskName) {
|
||||
this.taskName = taskName;
|
||||
}
|
||||
|
||||
public int getCasenoexecCount() {
|
||||
return casenoexecCount;
|
||||
}
|
||||
|
||||
public void setCasenoexecCount(int casenoexecCount) {
|
||||
this.casenoexecCount = casenoexecCount;
|
||||
}
|
||||
|
||||
public String getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(String startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
public String getTaskId() {
|
||||
return taskId;
|
||||
}
|
||||
|
||||
public void setTaskId(String taskId) {
|
||||
this.taskId = taskId;
|
||||
}
|
||||
|
||||
public String getTaskStatus() {
|
||||
return taskStatus;
|
||||
}
|
||||
|
||||
public void setTaskStatus(String taskStatus) {
|
||||
this.taskStatus = taskStatus;
|
||||
}
|
||||
|
||||
private String taskStatus_str;
|
||||
|
||||
public String getTaskStatus_str() {
|
||||
return taskStatus_str;
|
||||
}
|
||||
|
||||
public void setTaskStatus_str(String taskStatus_str) {
|
||||
this.taskStatus_str = taskStatus_str;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getCaseIsExec() {
|
||||
return caseIsExec;
|
||||
}
|
||||
|
||||
public void setCaseIsExec(String caseIsExec) {
|
||||
this.caseIsExec = caseIsExec;
|
||||
}
|
||||
|
||||
public String getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(String endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
public String getFinishtime() {
|
||||
return finishtime;
|
||||
}
|
||||
|
||||
public void setFinishtime(String finishtime) {
|
||||
this.finishtime = finishtime;
|
||||
}
|
||||
|
||||
public int getJobid() {
|
||||
return jobid;
|
||||
}
|
||||
|
||||
public void setJobid(int jobid) {
|
||||
this.jobid = jobid;
|
||||
}
|
||||
|
||||
public TestTaskexcute() {
|
||||
|
||||
}
|
||||
|
||||
public TestTaskexcute(int id, String taskId, int casetotalCount,
|
||||
int casesuccCount, int casefailCount, int caselockCount,
|
||||
TestJobs testJob, String createTime) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.taskId = taskId;
|
||||
this.casetotalCount = casetotalCount;
|
||||
this.casesuccCount = casesuccCount;
|
||||
this.casefailCount = casefailCount;
|
||||
this.caselockCount = caselockCount;
|
||||
this.testJob = testJob;
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
private String createTime;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getCasetotalCount() {
|
||||
return casetotalCount;
|
||||
}
|
||||
|
||||
public void setCasetotalCount(int casetotalCount) {
|
||||
this.casetotalCount = casetotalCount;
|
||||
}
|
||||
|
||||
public int getCasesuccCount() {
|
||||
return casesuccCount;
|
||||
}
|
||||
|
||||
public void setCasesuccCount(int casesuccCount) {
|
||||
this.casesuccCount = casesuccCount;
|
||||
}
|
||||
|
||||
public int getCasefailCount() {
|
||||
return casefailCount;
|
||||
}
|
||||
|
||||
public void setCasefailCount(int casefailCount) {
|
||||
this.casefailCount = casefailCount;
|
||||
}
|
||||
|
||||
public int getCaselockCount() {
|
||||
return caselockCount;
|
||||
}
|
||||
|
||||
public void setCaselockCount(int caselockCount) {
|
||||
this.caselockCount = caselockCount;
|
||||
}
|
||||
|
||||
public TestJobs getTestJob() {
|
||||
return testJob;
|
||||
}
|
||||
|
||||
public void setTestJob(TestJobs testJob) {
|
||||
this.testJob = testJob;
|
||||
}
|
||||
|
||||
public String getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(String createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,163 @@
|
|||
package luckyclient.publicclass;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
|
||||
/**
|
||||
* 时间工具类
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改 有任何疑问欢迎联系作者讨论。 QQ:1573584944 Seagull
|
||||
* =================================================================
|
||||
* @author Seagull
|
||||
* @date 2019年5月5日
|
||||
*/
|
||||
public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
||||
{
|
||||
public static String YYYY = "yyyy";
|
||||
|
||||
public static String YYYY_MM = "yyyy-MM";
|
||||
|
||||
public static String YYYY_MM_DD = "yyyy-MM-dd";
|
||||
|
||||
public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
|
||||
|
||||
public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
private static String[] parsePatterns = {
|
||||
"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
|
||||
"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
|
||||
"yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};
|
||||
|
||||
/**
|
||||
* 获取当前Date型日期
|
||||
*
|
||||
* @return Date() 当前日期
|
||||
*/
|
||||
public static Date getNowDate()
|
||||
{
|
||||
return new Date();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前日期, 默认格式为yyyy-MM-dd
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public static String getDate()
|
||||
{
|
||||
return dateTimeNow(YYYY_MM_DD);
|
||||
}
|
||||
|
||||
public static final String getTime()
|
||||
{
|
||||
return dateTimeNow(YYYY_MM_DD_HH_MM_SS);
|
||||
}
|
||||
|
||||
public static final String dateTimeNow()
|
||||
{
|
||||
return dateTimeNow(YYYYMMDDHHMMSS);
|
||||
}
|
||||
|
||||
public static final String dateTimeNow(final String format)
|
||||
{
|
||||
return parseDateToStr(format, new Date());
|
||||
}
|
||||
|
||||
public static final String dateTime(final Date date)
|
||||
{
|
||||
return parseDateToStr(YYYY_MM_DD, date);
|
||||
}
|
||||
|
||||
public static final String parseDateToStr(final String format, final Date date)
|
||||
{
|
||||
return new SimpleDateFormat(format).format(date);
|
||||
}
|
||||
|
||||
public static final Date dateTime(final String format, final String ts)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new SimpleDateFormat(format).parse(ts);
|
||||
}
|
||||
catch (ParseException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期路径 即年/月/日 如2018/08/08
|
||||
*/
|
||||
public static final String datePath()
|
||||
{
|
||||
Date now = new Date();
|
||||
return DateFormatUtils.format(now, "yyyy/MM/dd");
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期路径 即年/月/日 如20180808
|
||||
*/
|
||||
public static final String dateTime()
|
||||
{
|
||||
Date now = new Date();
|
||||
return DateFormatUtils.format(now, "yyyyMMdd");
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期型字符串转化为日期 格式
|
||||
*/
|
||||
public static Date parseDate(Object str)
|
||||
{
|
||||
if (str == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
try
|
||||
{
|
||||
return parseDate(str.toString(), parsePatterns);
|
||||
}
|
||||
catch (ParseException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务器启动时间
|
||||
*/
|
||||
public static Date getServerStartDate()
|
||||
{
|
||||
long time = ManagementFactory.getRuntimeMXBean().getStartTime();
|
||||
return new Date(time);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算两个时间差
|
||||
*/
|
||||
public static String getDatePoor(Date endDate, Date nowDate)
|
||||
{
|
||||
if(null==nowDate){
|
||||
return 0 + "天" + 0 + "小时" + 0 + "分钟";
|
||||
}
|
||||
|
||||
long nd = 1000 * 24 * 60 * 60;
|
||||
long nh = 1000 * 60 * 60;
|
||||
long nm = 1000 * 60;
|
||||
// long ns = 1000;
|
||||
// 获得两个时间的毫秒时间差异
|
||||
long diff = endDate.getTime() - nowDate.getTime();
|
||||
// 计算差多少天
|
||||
long day = diff / nd;
|
||||
// 计算差多少小时
|
||||
long hour = diff % nd / nh;
|
||||
// 计算差多少分钟
|
||||
long min = diff % nd % nh / nm;
|
||||
// 计算差多少秒//输出结果
|
||||
// long sec = diff % nd % nh % nm / ns;
|
||||
return day + "天" + hour + "小时" + min + "分钟";
|
||||
}
|
||||
}
|
|
@ -4,7 +4,6 @@ import java.io.ByteArrayOutputStream;
|
|||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -14,10 +13,10 @@ import com.alibaba.fastjson.JSONObject;
|
|||
|
||||
import luckyclient.caserun.publicdispose.ChangString;
|
||||
import luckyclient.caserun.publicdispose.ParamsManageForSteps;
|
||||
import luckyclient.planapi.entity.ProjectProtocolTemplate;
|
||||
import luckyclient.planapi.entity.ProjectTemplateParams;
|
||||
import luckyclient.publicclass.remoterinterface.HttpClientHelper;
|
||||
import luckyclient.publicclass.remoterinterface.HttpRequest;
|
||||
import luckyclient.serverapi.api.GetServerAPI;
|
||||
import luckyclient.serverapi.entity.ProjectProtocolTemplate;
|
||||
import luckyclient.serverapi.entity.ProjectTemplateParams;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
@ -45,15 +44,15 @@ public class InvokeMethod {
|
|||
public static String callCase(String packagename, String functionname, Object[] getParameterValues, int steptype, String extend) {
|
||||
String result = "调用异常,请查看错误日志!";
|
||||
try {
|
||||
if (steptype == 0) {
|
||||
if (steptype == 2) {
|
||||
if(functionname.toLowerCase().endsWith(".py")){
|
||||
//调用Python脚本
|
||||
luckyclient.publicclass.LogUtil.APP.info("准备开始调用Python脚本......");
|
||||
LogUtil.APP.info("准备开始调用Python脚本......");
|
||||
result = callPy(packagename, functionname, getParameterValues);
|
||||
}else{
|
||||
//调用JAVA
|
||||
// 调用非静态方法用到
|
||||
luckyclient.publicclass.LogUtil.APP.info("准备开始调用JAVA驱动桩程序......");
|
||||
LogUtil.APP.info("准备开始调用JAVA驱动桩程序......");
|
||||
Object server = Class.forName(packagename).newInstance();
|
||||
@SuppressWarnings("rawtypes")
|
||||
Class[] getParameterTypes = null;
|
||||
|
@ -76,32 +75,28 @@ public class InvokeMethod {
|
|||
result = str.toString();
|
||||
}
|
||||
}
|
||||
} else if (steptype == 2) {
|
||||
} else if (steptype == 0) {
|
||||
if(null==extend||"".equals(extend)||!extend.contains("】")){
|
||||
result = "您当前步骤是HTTP请求,请确认是否没有配置对应的HTTP协议模板...";
|
||||
luckyclient.publicclass.LogUtil.APP.error("您当前步骤是HTTP请求,请确认是否没有配置对应的HTTP协议模板...");
|
||||
LogUtil.APP.warn("您当前步骤是HTTP请求,请确认是否没有配置对应的HTTP协议模板...");
|
||||
return result;
|
||||
}
|
||||
String templateidstr = extend.substring(1, extend.indexOf("】"));
|
||||
String templatenamestr = extend.substring(extend.indexOf("】") + 1);
|
||||
luckyclient.publicclass.LogUtil.APP.info("即将使用模板【" + templatenamestr + "】,ID:【" + templateidstr + "】发送HTTP请求!");
|
||||
LogUtil.APP.info("即将使用模板【" + templatenamestr + "】,ID:【" + templateidstr + "】发送HTTP请求!");
|
||||
|
||||
String httpppt = HttpRequest.loadJSON("/projectprotocolTemplate/cgetPTemplateById.do?templateid=" + templateidstr);
|
||||
ProjectProtocolTemplate ppt = JSONObject.parseObject(httpppt,ProjectProtocolTemplate.class);
|
||||
ProjectProtocolTemplate ppt = GetServerAPI.clientGetProjectProtocolTemplateByTemplateId(Integer.valueOf(templateidstr));
|
||||
if (null == ppt) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("协议模板为空,请检查用例使用的协议模板是否已经删除!");
|
||||
LogUtil.APP.warn("协议模板为空,请检查用例使用的协议模板是否已经删除!");
|
||||
return "协议模板为空,请确认用例使用的模板是否已经删除!";
|
||||
}
|
||||
|
||||
String httpptp = HttpRequest.loadJSON("/projectTemplateParams/cgetParamsByTemplate.do?templateid=" + templateidstr);
|
||||
JSONObject jsonptpObject = JSONObject.parseObject(httpptp);
|
||||
List<ProjectTemplateParams> paramslist = new ArrayList<ProjectTemplateParams>();
|
||||
paramslist = JSONObject.parseArray(jsonptpObject.getString("params"), ProjectTemplateParams.class);
|
||||
List<ProjectTemplateParams> paramslist = GetServerAPI.clientGetProjectTemplateParamsListByTemplateId(Integer.valueOf(templateidstr));
|
||||
|
||||
//处理头域
|
||||
Map<String, String> headmsg = new HashMap<String, String>(0);
|
||||
if (null != ppt.getHeadmsg() && !ppt.getHeadmsg().equals("") && ppt.getHeadmsg().indexOf("=") > 0) {
|
||||
String headmsgtemp = ppt.getHeadmsg().replace("\\;", "!!!fhzh");
|
||||
if (null != ppt.getHeadMsg() && !ppt.getHeadMsg().equals("") && ppt.getHeadMsg().indexOf("=") > 0) {
|
||||
String headmsgtemp = ppt.getHeadMsg().replace("\\;", "!!!fhzh");
|
||||
String[] temp = headmsgtemp.split(";", -1);
|
||||
for (int i = 0; i < temp.length; i++) {
|
||||
if (null != temp[i] && !temp[i].equals("") && temp[i].indexOf("=") > 0) {
|
||||
|
@ -132,52 +127,52 @@ public class InvokeMethod {
|
|||
int replaceflag=0;
|
||||
for (int i = 0; i < paramslist.size(); i++) {
|
||||
ProjectTemplateParams ptp = paramslist.get(i);
|
||||
ptp.setParam(ParamsManageForSteps.paramsManage(ptp.getParam()));
|
||||
if("_forTextJson".equals(ptp.getParamname())){
|
||||
ptp.setParamValue(ParamsManageForSteps.paramsManage(ptp.getParamValue()));
|
||||
if("_forTextJson".equals(ptp.getParamName())){
|
||||
//分析参数替换序号
|
||||
int index = 1;
|
||||
if (key.contains("[") && key.endsWith("]")) {
|
||||
index = Integer.valueOf(key.substring(key.lastIndexOf("[") + 1, key.lastIndexOf("]")));
|
||||
key = key.substring(0, key.lastIndexOf("["));
|
||||
luckyclient.publicclass.LogUtil.APP.info("准备替换JSON对象中的参数值,替换指定第" + index + "个参数...");
|
||||
LogUtil.APP.info("准备替换JSON对象中的参数值,替换指定第" + index + "个参数...");
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.info("准备替换JSON对象中的参数值,未检测到指定参数名序号,默认替换第1个参数...");
|
||||
LogUtil.APP.info("准备替换JSON对象中的参数值,未检测到指定参数名序号,默认替换第1个参数...");
|
||||
}
|
||||
|
||||
if(ptp.getParam().contains("\""+key+"\":")){
|
||||
Map<String,String> map=ChangString.changjson(ptp.getParam(), key, value,index);
|
||||
if(ptp.getParamValue().contains("\""+key+"\":")){
|
||||
Map<String,String> map=ChangString.changjson(ptp.getParamValue(), key, value,index);
|
||||
if("true".equals(map.get("boolean"))){
|
||||
ptp.setParam(map.get("json"));
|
||||
ptp.setParamValue(map.get("json"));
|
||||
paramslist.set(i, ptp);
|
||||
replaceflag=1;
|
||||
luckyclient.publicclass.LogUtil.APP.info("替换参数"+key+"完成...");
|
||||
LogUtil.APP.info("替换参数"+key+"完成...");
|
||||
break;
|
||||
}
|
||||
}else if(ptp.getParam().contains(key)){
|
||||
ptp.setParam(ptp.getParam().replace(key, value));
|
||||
}else if(ptp.getParamValue().contains(key)){
|
||||
ptp.setParamValue(ptp.getParamValue().replace(key, value));
|
||||
paramslist.set(i, ptp);
|
||||
replaceflag=1;
|
||||
luckyclient.publicclass.LogUtil.APP.info("检查当前文本不属于JSON,在字符串【"+ptp.getParam()+"】中直接把【"+key+"】替换成【"+value+"】...");
|
||||
LogUtil.APP.info("检查当前文本不属于JSON,在字符串【"+ptp.getParamValue()+"】中直接把【"+key+"】替换成【"+value+"】...");
|
||||
break;
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.error("请检查您的纯文本模板是否是正常的JSON格式或是文本中是否存在需替换的关键字。");
|
||||
LogUtil.APP.warn("请检查您的纯文本模板是否是正常的JSON格式或是文本中是否存在需替换的关键字。");
|
||||
}
|
||||
}else{
|
||||
if (ptp.getParamname().equals(key)) {
|
||||
ptp.setParam(value);
|
||||
if (ptp.getParamName().equals(key)) {
|
||||
ptp.setParamValue(value);
|
||||
paramslist.set(i, ptp);
|
||||
replaceflag=1;
|
||||
luckyclient.publicclass.LogUtil.APP.info("把模板中参数【"+key+"】的值设置成【"+value+"】");
|
||||
LogUtil.APP.info("把模板中参数【"+key+"】的值设置成【"+value+"】");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(replaceflag==0){
|
||||
luckyclient.publicclass.LogUtil.APP.error("步骤参数【"+key+"】没有在模板中找到可替换的参数对应默认值,"
|
||||
LogUtil.APP.warn("步骤参数【"+key+"】没有在模板中找到可替换的参数对应默认值,"
|
||||
+ "设置请求参数失败,请检查协议模板中此参数是否存在。");
|
||||
}
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.error("替换模板或是头域参数失败,原因是因为没有检测到#,"
|
||||
LogUtil.APP.warn("替换模板或是头域参数失败,原因是因为没有检测到#,"
|
||||
+ "注意HTTP请求替换参数格式是【headmsg(头域名#头域值)|参数名#参数值|参数名2#参数值2】");
|
||||
}
|
||||
|
||||
|
@ -186,35 +181,36 @@ public class InvokeMethod {
|
|||
//处理参数
|
||||
Map<String, Object> params = new HashMap<String, Object>(0);
|
||||
for (ProjectTemplateParams ptp : paramslist) {
|
||||
String tempparam = "";
|
||||
if(null!=ptp.getParamValue()){
|
||||
tempparam = ptp.getParamValue().replace(""", "\"");
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
//处理参数对象
|
||||
if (ptp.getParamtype() == 1) {
|
||||
String tempparam = ptp.getParam().replace(""", "\"");
|
||||
if (ptp.getParamType() == 1) {
|
||||
JSONObject json = JSONObject.parseObject(tempparam);
|
||||
params.put(ptp.getParamname().replace(""", "\""), json);
|
||||
luckyclient.publicclass.LogUtil.APP.info("模板参数【" + ptp.getParamname() + "】 JSONObject类型参数值:【" + json.toString() + "】");
|
||||
} else if (ptp.getParamtype() == 2) {
|
||||
String tempparam = ptp.getParam().replace(""", "\"");
|
||||
params.put(ptp.getParamName().replace(""", "\""), json);
|
||||
LogUtil.APP.info("模板参数【" + ptp.getParamName() + "】 JSONObject类型参数值:【" + json.toString() + "】");
|
||||
} else if (ptp.getParamType() == 2) {
|
||||
JSONArray jarr = JSONArray.parseArray(tempparam);
|
||||
params.put(ptp.getParamname().replace(""", "\""), jarr);
|
||||
luckyclient.publicclass.LogUtil.APP.info("模板参数【" + ptp.getParamname() + "】 JSONArray类型参数值:【" + jarr.toString() + "】");
|
||||
} else if (ptp.getParamtype() == 3) {
|
||||
String tempparam = ptp.getParam().replace(""", "\"");
|
||||
params.put(ptp.getParamName().replace(""", "\""), jarr);
|
||||
LogUtil.APP.info("模板参数【" + ptp.getParamName() + "】 JSONArray类型参数值:【" + jarr.toString() + "】");
|
||||
} else if (ptp.getParamType() == 3) {
|
||||
File file = new File(tempparam);
|
||||
params.put(ptp.getParamname().replace(""", "\""), file);
|
||||
luckyclient.publicclass.LogUtil.APP.info("模板参数【" + ptp.getParamname() + "】 File类型参数值:【" + file.getAbsolutePath() + "】");
|
||||
} else if (ptp.getParamtype() == 4) {
|
||||
String tempparam = ptp.getParam().replace(""", "\"");
|
||||
params.put(ptp.getParamName().replace(""", "\""), file);
|
||||
LogUtil.APP.info("模板参数【" + ptp.getParamName() + "】 File类型参数值:【" + file.getAbsolutePath() + "】");
|
||||
} else if (ptp.getParamType() == 4) {
|
||||
Double dp = Double.valueOf(tempparam);
|
||||
params.put(ptp.getParamname().replace(""", "\""), dp);
|
||||
luckyclient.publicclass.LogUtil.APP.info("模板参数【" + ptp.getParamname() + "】 数字类型参数值:【" + tempparam + "】");
|
||||
} else if (ptp.getParamtype() == 5) {
|
||||
String tempparam = ptp.getParam().replace(""", "\"");
|
||||
params.put(ptp.getParamName().replace(""", "\""), dp);
|
||||
LogUtil.APP.info("模板参数【" + ptp.getParamName() + "】 数字类型参数值:【" + tempparam + "】");
|
||||
} else if (ptp.getParamType() == 5) {
|
||||
Boolean bn = Boolean.valueOf(tempparam);
|
||||
params.put(ptp.getParamname().replace(""", "\""), bn);
|
||||
luckyclient.publicclass.LogUtil.APP.info("模板参数【" + ptp.getParamname() + "】 Boolean类型参数值:【" + bn + "】");
|
||||
params.put(ptp.getParamName().replace(""", "\""), bn);
|
||||
LogUtil.APP.info("模板参数【" + ptp.getParamName() + "】 Boolean类型参数值:【" + bn + "】");
|
||||
} else {
|
||||
params.put(ptp.getParamname().replace(""", "\""), ptp.getParam().replace(""", "\""));
|
||||
luckyclient.publicclass.LogUtil.APP.info("模板参数【" + ptp.getParamname() + "】 String类型参数值:【" + ptp.getParam().replace(""", "\"") + "】");
|
||||
params.put(ptp.getParamName().replace(""", "\""), ptp.getParamValue().replace(""", "\""));
|
||||
LogUtil.APP.info("模板参数【" + ptp.getParamName() + "】 String类型参数值:【" + ptp.getParamValue().replace(""", "\"") + "】");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -244,30 +240,26 @@ public class InvokeMethod {
|
|||
} else if (functionname.toLowerCase().equals("httpclientget")) {
|
||||
result = HttpClientHelper.httpClientGet(packagename, params, headmsg, ppt);
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("您的HTTP操作方法异常,检测到的操作方法是:" + functionname);
|
||||
LogUtil.APP.warn("您的HTTP操作方法异常,检测到的操作方法是:" + functionname);
|
||||
result = "调用异常,请查看错误日志!";
|
||||
}
|
||||
} else if (steptype == 3) {
|
||||
} else if (steptype == 4) {
|
||||
String templateidstr = extend.substring(1, extend.indexOf("】"));
|
||||
String templatenamestr = extend.substring(extend.indexOf("】") + 1);
|
||||
luckyclient.publicclass.LogUtil.APP.info("即将使用模板【" + templatenamestr + "】,ID:【" + templateidstr + "】 发送SOCKET请求!");
|
||||
LogUtil.APP.info("即将使用模板【" + templatenamestr + "】,ID:【" + templateidstr + "】 发送SOCKET请求!");
|
||||
|
||||
String httpppt = HttpRequest.loadJSON("/projectprotocolTemplate/cgetPTemplateById.do?templateid=" + templateidstr);
|
||||
ProjectProtocolTemplate ppt = JSONObject.parseObject(httpppt,ProjectProtocolTemplate.class);
|
||||
ProjectProtocolTemplate ppt = GetServerAPI.clientGetProjectProtocolTemplateByTemplateId(Integer.valueOf(templateidstr));
|
||||
if (null == ppt) {
|
||||
luckyclient.publicclass.LogUtil.APP.error("协议模板为空,请检查用例使用的协议模板是否已经删除!");
|
||||
LogUtil.APP.warn("协议模板为空,请检查用例使用的协议模板是否已经删除!");
|
||||
return "协议模板为空,请确认用例使用的模板是否已经删除!";
|
||||
}
|
||||
|
||||
String httpptp = HttpRequest.loadJSON("/projectTemplateParams/cgetParamsByTemplate.do?templateid=" + templateidstr);
|
||||
JSONObject jsonptpObject = JSONObject.parseObject(httpptp);
|
||||
List<ProjectTemplateParams> paramslist = new ArrayList<ProjectTemplateParams>();
|
||||
paramslist = JSONObject.parseArray(jsonptpObject.getString("params"), ProjectTemplateParams.class);
|
||||
List<ProjectTemplateParams> paramslist = GetServerAPI.clientGetProjectTemplateParamsListByTemplateId(Integer.valueOf(templateidstr));
|
||||
|
||||
//处理头域
|
||||
Map<String, String> headmsg = new HashMap<String, String>(0);
|
||||
if (null != ppt.getHeadmsg() && !ppt.getHeadmsg().equals("") && ppt.getHeadmsg().indexOf("=") > 0) {
|
||||
String headmsgtemp = ppt.getHeadmsg().replace("\\;", "!!!fhzh");
|
||||
if (null != ppt.getHeadMsg() && !ppt.getHeadMsg().equals("") && ppt.getHeadMsg().indexOf("=") > 0) {
|
||||
String headmsgtemp = ppt.getHeadMsg().replace("\\;", "!!!fhzh");
|
||||
String[] temp = headmsgtemp.split(";", -1);
|
||||
for (int i = 0; i < temp.length; i++) {
|
||||
if (null != temp[i] && !temp[i].equals("") && temp[i].indexOf("=") > 0) {
|
||||
|
@ -296,51 +288,51 @@ public class InvokeMethod {
|
|||
int replaceflag=0;
|
||||
for (int i = 0; i < paramslist.size(); i++) {
|
||||
ProjectTemplateParams ptp = paramslist.get(i);
|
||||
if("_forTextJson".equals(ptp.getParamname())){
|
||||
if(ptp.getParam().indexOf("\""+key+"\":")>=0){
|
||||
if("_forTextJson".equals(ptp.getParamName())){
|
||||
if(ptp.getParamValue().indexOf("\""+key+"\":")>=0){
|
||||
//分析参数替换序号
|
||||
int index = 1;
|
||||
if (key.indexOf("[") >= 0 && key.endsWith("]")) {
|
||||
index = Integer.valueOf(key.substring(key.lastIndexOf("[") + 1, key.lastIndexOf("]")));
|
||||
key = key.substring(0, key.lastIndexOf("["));
|
||||
luckyclient.publicclass.LogUtil.APP.info("准备替换JSON对象中的参数值,未检测到指定参数名序号,默认替换第1个参数...");
|
||||
LogUtil.APP.info("准备替换JSON对象中的参数值,未检测到指定参数名序号,默认替换第1个参数...");
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.info("准备替换JSON对象中的参数值,替换指定第" + index + "个参数...");
|
||||
LogUtil.APP.info("准备替换JSON对象中的参数值,替换指定第" + index + "个参数...");
|
||||
}
|
||||
|
||||
Map<String,String> map=ChangString.changjson(ptp.getParam(), key, value,index);
|
||||
Map<String,String> map=ChangString.changjson(ptp.getParamValue(), key, value,index);
|
||||
if("true".equals(map.get("boolean"))){
|
||||
ptp.setParam(map.get("json"));
|
||||
ptp.setParamValue(map.get("json"));
|
||||
paramslist.set(i, ptp);
|
||||
replaceflag=1;
|
||||
luckyclient.publicclass.LogUtil.APP.info("替换参数"+key+"完成...");
|
||||
LogUtil.APP.info("替换参数"+key+"完成...");
|
||||
break;
|
||||
}
|
||||
}else if(ptp.getParam().indexOf(key)>=0){
|
||||
ptp.setParam(ptp.getParam().replace(key, value));
|
||||
}else if(ptp.getParamValue().indexOf(key)>=0){
|
||||
ptp.setParamValue(ptp.getParamValue().replace(key, value));
|
||||
paramslist.set(i, ptp);
|
||||
replaceflag=1;
|
||||
luckyclient.publicclass.LogUtil.APP.info("检查当前文本不属于JSON,在字符串【"+ptp.getParam()+"】中直接把【"+key+"】替换成【"+value+"】...");
|
||||
LogUtil.APP.info("检查当前文本不属于JSON,在字符串【"+ptp.getParamValue()+"】中直接把【"+key+"】替换成【"+value+"】...");
|
||||
break;
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.error("请检查您的纯文本模板是否是正常的JSON格式或是文本中是否存在需替换的关键字。");
|
||||
LogUtil.APP.warn("请检查您的纯文本模板是否是正常的JSON格式或是文本中是否存在需替换的关键字。");
|
||||
}
|
||||
}else{
|
||||
if (ptp.getParamname().equals(key)) {
|
||||
ptp.setParam(value);
|
||||
if (ptp.getParamName().equals(key)) {
|
||||
ptp.setParamValue(value);
|
||||
paramslist.set(i, ptp);
|
||||
replaceflag=1;
|
||||
luckyclient.publicclass.LogUtil.APP.info("把模板中参数【"+key+"】的值设置成【"+value+"】");
|
||||
LogUtil.APP.info("把模板中参数【"+key+"】的值设置成【"+value+"】");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(replaceflag==0){
|
||||
luckyclient.publicclass.LogUtil.APP.error("步骤参数【"+key+"】没有在模板中找到可替换的参数对应默认值,"
|
||||
LogUtil.APP.warn("步骤参数【"+key+"】没有在模板中找到可替换的参数对应默认值,"
|
||||
+ "设置请求参数失败,请检查协议模板中此参数是否存在。");
|
||||
}
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.error("替换模板或是头域参数失败,原因是因为没有检测到#,"
|
||||
LogUtil.APP.warn("替换模板或是头域参数失败,原因是因为没有检测到#,"
|
||||
+ "注意HTTP请求替换参数格式是【headmsg(头域名#头域值)|参数名#参数值|参数名2#参数值2】");
|
||||
}
|
||||
|
||||
|
@ -349,50 +341,49 @@ public class InvokeMethod {
|
|||
//处理参数
|
||||
Map<String, Object> params = new HashMap<String, Object>(0);
|
||||
for (ProjectTemplateParams ptp : paramslist) {
|
||||
String tempparam = "";
|
||||
if(null!=ptp.getParamValue()){
|
||||
tempparam = ptp.getParamValue().replace(""", "\"");
|
||||
}
|
||||
//处理参数对象
|
||||
if (ptp.getParamtype() == 1) {
|
||||
String tempparam = ptp.getParam().replace(""", "\"");
|
||||
if (ptp.getParamType() == 1) {
|
||||
JSONObject json = JSONObject.parseObject(tempparam);
|
||||
params.put(ptp.getParamname().replace(""", "\""), json);
|
||||
luckyclient.publicclass.LogUtil.APP.info("模板参数【" + ptp.getParamname() + "】 JSONObject类型参数值:【" + json.toString() + "】");
|
||||
} else if (ptp.getParamtype() == 2) {
|
||||
String tempparam = ptp.getParam().replace(""", "\"");
|
||||
params.put(ptp.getParamName().replace(""", "\""), json);
|
||||
LogUtil.APP.info("模板参数【" + ptp.getParamName() + "】 JSONObject类型参数值:【" + json.toString() + "】");
|
||||
} else if (ptp.getParamType() == 2) {
|
||||
JSONArray jarr = JSONArray.parseArray(tempparam);
|
||||
params.put(ptp.getParamname().replace(""", "\""), jarr);
|
||||
luckyclient.publicclass.LogUtil.APP.info("模板参数【" + ptp.getParamname() + "】 JSONArray类型参数值:【" + jarr.toString() + "】");
|
||||
} else if (ptp.getParamtype() == 3) {
|
||||
String tempparam = ptp.getParam().replace(""", "\"");
|
||||
params.put(ptp.getParamName().replace(""", "\""), jarr);
|
||||
LogUtil.APP.info("模板参数【" + ptp.getParamName() + "】 JSONArray类型参数值:【" + jarr.toString() + "】");
|
||||
} else if (ptp.getParamType() == 3) {
|
||||
File file = new File(tempparam);
|
||||
params.put(ptp.getParamname().replace(""", "\""), file);
|
||||
luckyclient.publicclass.LogUtil.APP.info("模板参数【" + ptp.getParamname() + "】 File类型参数值:【" + file.getAbsolutePath() + "】");
|
||||
} else if (ptp.getParamtype() == 4) {
|
||||
String tempparam = ptp.getParam().replace(""", "\"");
|
||||
params.put(ptp.getParamName().replace(""", "\""), file);
|
||||
LogUtil.APP.info("模板参数【" + ptp.getParamName() + "】 File类型参数值:【" + file.getAbsolutePath() + "】");
|
||||
} else if (ptp.getParamType() == 4) {
|
||||
Double dp = Double.valueOf(tempparam);
|
||||
params.put(ptp.getParamname().replace(""", "\""), dp);
|
||||
luckyclient.publicclass.LogUtil.APP.info("模板参数【" + ptp.getParamname() + "】 数字类型参数值:【" + tempparam + "】");
|
||||
} else if (ptp.getParamtype() == 5) {
|
||||
String tempparam = ptp.getParam().replace(""", "\"");
|
||||
params.put(ptp.getParamName().replace(""", "\""), dp);
|
||||
LogUtil.APP.info("模板参数【" + ptp.getParamName() + "】 数字类型参数值:【" + tempparam + "】");
|
||||
} else if (ptp.getParamType() == 5) {
|
||||
Boolean bn = Boolean.valueOf(tempparam);
|
||||
params.put(ptp.getParamname().replace(""", "\""), bn);
|
||||
luckyclient.publicclass.LogUtil.APP.info("模板参数【" + ptp.getParamname() + "】 Boolean类型参数值:【" + bn + "】");
|
||||
params.put(ptp.getParamName().replace(""", "\""), bn);
|
||||
LogUtil.APP.info("模板参数【" + ptp.getParamName() + "】 Boolean类型参数值:【" + bn + "】");
|
||||
} else {
|
||||
params.put(ptp.getParamname().replace(""", "\""), ptp.getParam().replace(""", "\""));
|
||||
luckyclient.publicclass.LogUtil.APP.info("模板参数【" + ptp.getParamname() + "】 String类型参数值:【" + ptp.getParam().replace(""", "\"") + "】");
|
||||
params.put(ptp.getParamName().replace(""", "\""), ptp.getParamValue().replace(""", "\""));
|
||||
LogUtil.APP.info("模板参数【" + ptp.getParamName() + "】 String类型参数值:【" + ptp.getParamValue().replace(""", "\"") + "】");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (functionname.toLowerCase().equals("socketpost")) {
|
||||
result = HttpClientHelper.sendSocketPost(packagename, params, ppt.getContentencoding().toLowerCase(), headmsg);
|
||||
result = HttpClientHelper.sendSocketPost(packagename, params, ppt.getEncoding().toLowerCase(), headmsg);
|
||||
} else if (functionname.toLowerCase().equals("socketget")) {
|
||||
result = HttpClientHelper.sendSocketGet(packagename, params, ppt.getContentencoding().toLowerCase(), headmsg);
|
||||
result = HttpClientHelper.sendSocketGet(packagename, params, ppt.getEncoding().toLowerCase(), headmsg);
|
||||
} else {
|
||||
luckyclient.publicclass.LogUtil.APP.error("您的SOCKET操作方法异常,检测到的操作方法是:" + functionname);
|
||||
LogUtil.APP.warn("您的SOCKET操作方法异常,检测到的操作方法是:" + functionname);
|
||||
result = "调用异常,请查看错误日志!";
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
return "调用异常,请查看错误日志!";
|
||||
}
|
||||
return result;
|
||||
|
@ -466,7 +457,7 @@ public class InvokeMethod {
|
|||
args[1]=packagename+File.separator+functionname;
|
||||
//args[1]="E:\\PycharmProjects\\untitled\\venv\\testaaa.py";
|
||||
}
|
||||
luckyclient.publicclass.LogUtil.APP.info("调用Python脚本路径:"+args[1]);
|
||||
LogUtil.APP.info("调用Python脚本路径:"+args[1]);
|
||||
for(int i=0;i < params;i++){
|
||||
args[2+i]=getParameterValues[i].toString();
|
||||
}
|
||||
|
@ -488,16 +479,16 @@ public class InvokeMethod {
|
|||
// 打印流信息
|
||||
if(outerrStream.toString().equals("")){
|
||||
result = outStream.toString().trim();
|
||||
luckyclient.publicclass.LogUtil.APP.info("成功调用Python脚本,返回结果:"+result);
|
||||
LogUtil.APP.info("成功调用Python脚本,返回结果:"+result);
|
||||
}else{
|
||||
result = outerrStream.toString().trim();
|
||||
if(result.indexOf("ModuleNotFoundError")>-1){
|
||||
luckyclient.publicclass.LogUtil.APP.error("调用Python脚本出现异常,有相关Python模块未引用到,请在Python脚本中注意设置系统环境路径(例: sys.path.append(\"E:\\PycharmProjects\\untitled\\venv\\Lib\\site-packages\")),"
|
||||
LogUtil.APP.warn("调用Python脚本出现异常,有相关Python模块未引用到,请在Python脚本中注意设置系统环境路径(例: sys.path.append(\"E:\\PycharmProjects\\untitled\\venv\\Lib\\site-packages\")),"
|
||||
+ "详细错误信息:"+result);
|
||||
}else if(result.indexOf("No such file or directory")>-1){
|
||||
luckyclient.publicclass.LogUtil.APP.error("调用Python脚本出现异常,在指定路径下未找到Python脚本,原因有可能是Python脚本路径错误或是传入Python指定参数个数不一致,详细错误信息:"+result);
|
||||
LogUtil.APP.warn("调用Python脚本出现异常,在指定路径下未找到Python脚本,原因有可能是Python脚本路径错误或是传入Python指定参数个数不一致,详细错误信息:"+result);
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.error("调用Python脚本出现异常,错误信息:"+result);
|
||||
LogUtil.APP.warn("调用Python脚本出现异常,错误信息:"+result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ package luckyclient.publicclass;
|
|||
|
||||
import java.io.File;
|
||||
import java.util.Enumeration;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
@ -42,8 +44,8 @@ public class JarClassFind {
|
|||
} else {
|
||||
if (filelist[i].endsWith("jar")) {
|
||||
try {
|
||||
java.util.jar.JarFile jarfile = new java.util.jar.JarFile(path + filelist[i]);
|
||||
for (Enumeration e = jarfile.entries(); e.hasMoreElements();) {
|
||||
JarFile jarfile = new java.util.jar.JarFile(path + filelist[i]);
|
||||
for (Enumeration<JarEntry> e = jarfile.entries(); e.hasMoreElements();) {
|
||||
String name = e.nextElement().toString();
|
||||
if (name.equals(classname) || name.indexOf(classname) > -1) {
|
||||
count++;
|
||||
|
@ -51,7 +53,9 @@ public class JarClassFind {
|
|||
System.out.println("【"+path + filelist[i]+"】查找到第"+count+"个JAR包存在指定类!");
|
||||
}
|
||||
}
|
||||
} catch (Exception eee) {
|
||||
jarfile.close();
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@ package luckyclient.publicclass;
|
|||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* 系统日志记录
|
||||
|
@ -14,20 +14,12 @@ import org.apache.commons.logging.LogFactory;
|
|||
public class LogUtil {
|
||||
|
||||
/**
|
||||
* 记录系统运行日志,监控系统运行情况
|
||||
* 主要使用三种日志级别,info,warn,error
|
||||
* info 记录客户端系统日志,监控客户端运行情况
|
||||
* warn 记录客户端业务上的告警日志
|
||||
* error 记录客户端在执行过程中抛出的异常以及严重错误
|
||||
*/
|
||||
public static final Log APP = LogFactory.getLog("app");
|
||||
|
||||
/**
|
||||
* 记录业务日志,监控业务执行情况
|
||||
*/
|
||||
public static final Log MSG = LogFactory.getLog("msg");
|
||||
|
||||
/**
|
||||
* 记录系统错误,监控程序是否出错
|
||||
*/
|
||||
public static final Log ERROR = LogFactory.getLog("error");
|
||||
|
||||
public static final Logger APP = LoggerFactory.getLogger("info");
|
||||
|
||||
public static StringBuffer getFieldValue(Object bean){
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
@ -58,7 +50,7 @@ public class LogUtil {
|
|||
}
|
||||
}
|
||||
catch(Exception ex){
|
||||
LogUtil.ERROR.error(ex,ex);
|
||||
LogUtil.APP.error("日志异常",ex);
|
||||
}
|
||||
return sb;
|
||||
}
|
||||
|
|
|
@ -56,7 +56,8 @@ import org.apache.http.ssl.SSLContexts;
|
|||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import luckyclient.planapi.entity.ProjectProtocolTemplate;
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
import luckyclient.serverapi.entity.ProjectProtocolTemplate;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
|
@ -80,18 +81,18 @@ public class HttpClientHelper {
|
|||
* @return
|
||||
*/
|
||||
public static String sendHttpURLPost(String urlParam, Map<String, Object> params, Map<String, String> headmsg,ProjectProtocolTemplate ppt) {
|
||||
String charset=ppt.getContentencoding().toLowerCase();
|
||||
int timeout=ppt.getConnecttimeout();
|
||||
int responsehead=ppt.getResponsehead();
|
||||
int responsecode=ppt.getResponsecode();
|
||||
String charset=ppt.getEncoding().toLowerCase();
|
||||
int timeout=ppt.getTimeout();
|
||||
int responsehead=ppt.getIsResponseHead();
|
||||
int responsecode=ppt.getIsResponseCode();
|
||||
|
||||
StringBuffer resultBuffer = null;
|
||||
luckyclient.publicclass.LogUtil.APP.info("设置HTTP请求地址:【"+urlParam+"】");
|
||||
LogUtil.APP.info("设置HTTP请求地址:【"+urlParam+"】");
|
||||
// 构建请求参数
|
||||
StringBuffer sbParams = new StringBuffer();
|
||||
if (params != null && params.size() > 0) {
|
||||
if(1==params.size()&¶ms.containsKey("_forTextJson")){
|
||||
luckyclient.publicclass.LogUtil.APP.error("协议模板是纯文本模式(仅限httpClientPostJson以及httpClientPutJson请求),无法使用sendHttpURLPost请求(必须为key-value)...");
|
||||
LogUtil.APP.warn("协议模板是纯文本模式(仅限httpClientPostJson以及httpClientPutJson请求),无法使用sendHttpURLPost请求(必须为key-value)...");
|
||||
return "协议模板是纯文本,无法使用sendHttpURLPost请求(必须为key-value)...";
|
||||
}else{
|
||||
for (Entry<String, Object> e : params.entrySet()) {
|
||||
|
@ -99,7 +100,7 @@ public class HttpClientHelper {
|
|||
sbParams.append("=");
|
||||
sbParams.append(e.getValue());
|
||||
sbParams.append("&");
|
||||
luckyclient.publicclass.LogUtil.APP.info("设置HTTPURLPost参数信息...key:【"+e.getKey()+"】 value:【"+e.getValue()+"】");
|
||||
LogUtil.APP.info("设置HTTPURLPost参数信息...key:【"+e.getKey()+"】 value:【"+e.getValue()+"】");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -120,11 +121,11 @@ public class HttpClientHelper {
|
|||
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
||||
String key=m.getKey();
|
||||
String value=m.getValue();
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始设置|替换HTTPURLPost头域信息...key:【"+key+"】 value:【"+value+"】");
|
||||
LogUtil.APP.info("开始设置|替换HTTPURLPost头域信息...key:【"+key+"】 value:【"+value+"】");
|
||||
if(null!=value&&value.indexOf("Base64(")==0){
|
||||
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
||||
value="Basic " + DatatypeConverter.printBase64Binary((valuesub).getBytes());
|
||||
luckyclient.publicclass.LogUtil.APP.info("将头域【"+key+"】的值【"+value+"】FORMAT成BASE64格式...");
|
||||
LogUtil.APP.info("将头域【"+key+"】的值【"+value+"】FORMAT成BASE64格式...");
|
||||
con.setRequestProperty(key, value);
|
||||
}else{
|
||||
con.setRequestProperty(key, value);
|
||||
|
@ -160,14 +161,14 @@ public class HttpClientHelper {
|
|||
resultBuffer.append("Content-Length=0");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
if (osw != null) {
|
||||
try {
|
||||
osw.close();
|
||||
} catch (IOException e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
osw = null;
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
|
@ -181,7 +182,7 @@ public class HttpClientHelper {
|
|||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
br = null;
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
|
@ -205,19 +206,19 @@ public class HttpClientHelper {
|
|||
* @param headmsg
|
||||
* @return
|
||||
*/
|
||||
public static String sendURLPost(String urlParam, Map<String, Object> params, Map<String, String> headmsg,ProjectProtocolTemplate ppt) {
|
||||
String charset=ppt.getContentencoding().toLowerCase();
|
||||
int timeout=ppt.getConnecttimeout();
|
||||
int responsehead=ppt.getResponsehead();
|
||||
int responsecode=ppt.getResponsecode();
|
||||
public static String sendURLPost(String urlParam, Map<String, Object> params, Map<String, String> headmsg,ProjectProtocolTemplate ppt) {
|
||||
String charset=ppt.getEncoding().toLowerCase();
|
||||
int timeout=ppt.getTimeout();
|
||||
int responsehead=ppt.getIsResponseHead();
|
||||
int responsecode=ppt.getIsResponseCode();
|
||||
|
||||
StringBuffer resultBuffer = null;
|
||||
// 构建请求参数
|
||||
luckyclient.publicclass.LogUtil.APP.info("设置HTTP请求地址:【"+urlParam+"】");
|
||||
LogUtil.APP.info("设置HTTP请求地址:【"+urlParam+"】");
|
||||
StringBuffer sbParams = new StringBuffer();
|
||||
if (params != null && params.size() > 0) {
|
||||
if(1==params.size()&¶ms.containsKey("_forTextJson")){
|
||||
luckyclient.publicclass.LogUtil.APP.error("协议模板是纯文本模式(仅限httpClientPostJson以及httpClientPutJson请求),无法使用sendURLPost请求(必须为key-value)...");
|
||||
LogUtil.APP.warn("协议模板是纯文本模式(仅限httpClientPostJson以及httpClientPutJson请求),无法使用sendURLPost请求(必须为key-value)...");
|
||||
return "协议模板是纯文本,无法使用sendURLPost请求(必须为key-value)...";
|
||||
}else{
|
||||
for (Entry<String, Object> e : params.entrySet()) {
|
||||
|
@ -225,7 +226,7 @@ public class HttpClientHelper {
|
|||
sbParams.append("=");
|
||||
sbParams.append(e.getValue());
|
||||
sbParams.append("&");
|
||||
luckyclient.publicclass.LogUtil.APP.info("设置URLPost参数信息...key:【"+e.getKey()+"】 value:【"+e.getValue()+"】");
|
||||
LogUtil.APP.info("设置URLPost参数信息...key:【"+e.getKey()+"】 value:【"+e.getValue()+"】");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -245,11 +246,11 @@ public class HttpClientHelper {
|
|||
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
||||
String key=m.getKey();
|
||||
String value=m.getValue();
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始设置|替换URLPost头域信息...key:【"+key+"】 value:【"+value+"】");
|
||||
LogUtil.APP.info("开始设置|替换URLPost头域信息...key:【"+key+"】 value:【"+value+"】");
|
||||
if(null!=value&&value.indexOf("Base64(")==0){
|
||||
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
||||
value="Basic " + DatatypeConverter.printBase64Binary((valuesub).getBytes());
|
||||
luckyclient.publicclass.LogUtil.APP.info("将头域【"+key+"】的值【"+value+"】FORMAT成BASE64格式...");
|
||||
LogUtil.APP.info("将头域【"+key+"】的值【"+value+"】FORMAT成BASE64格式...");
|
||||
con.setRequestProperty(key, value);
|
||||
}else{
|
||||
con.setRequestProperty(key, value);
|
||||
|
@ -292,14 +293,14 @@ public class HttpClientHelper {
|
|||
resultBuffer.append("Content-Length=0");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
if (osw != null) {
|
||||
try {
|
||||
osw.close();
|
||||
} catch (IOException e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
osw = null;
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -308,7 +309,7 @@ public class HttpClientHelper {
|
|||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
br = null;
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -327,22 +328,22 @@ public class HttpClientHelper {
|
|||
*/
|
||||
public static String sendGetAndSaveFile(String urlParam, Map<String, Object> params, String fileSavePath, Map<String, String> headmsg,ProjectProtocolTemplate ppt) {
|
||||
// 构建请求参数
|
||||
luckyclient.publicclass.LogUtil.APP.info("设置HTTP请求地址:【"+urlParam+"】");
|
||||
int timeout=ppt.getConnecttimeout();
|
||||
int responsehead=ppt.getResponsehead();
|
||||
int responsecode=ppt.getResponsecode();
|
||||
LogUtil.APP.info("设置HTTP请求地址:【"+urlParam+"】");
|
||||
int timeout=ppt.getTimeout();
|
||||
int responsehead=ppt.getIsResponseHead();
|
||||
int responsecode=ppt.getIsResponseCode();
|
||||
|
||||
StringBuffer sbParams = new StringBuffer();
|
||||
if (params != null && params.size() > 0) {
|
||||
if(1==params.size()&¶ms.containsKey("_forTextJson")){
|
||||
luckyclient.publicclass.LogUtil.APP.error("协议模板是纯文本模式(仅限httpClientPostJson以及httpClientPutJson请求),无法使用sendGetAndSaveFile请求(必须为key-value)...");
|
||||
LogUtil.APP.warn("协议模板是纯文本模式(仅限httpClientPostJson以及httpClientPutJson请求),无法使用sendGetAndSaveFile请求(必须为key-value)...");
|
||||
}else{
|
||||
for (Entry<String, Object> entry : params.entrySet()) {
|
||||
sbParams.append(entry.getKey());
|
||||
sbParams.append("=");
|
||||
sbParams.append(entry.getValue());
|
||||
sbParams.append("&");
|
||||
luckyclient.publicclass.LogUtil.APP.info("设置HTTPSaveFile参数信息...key:【"+entry.getKey()+"】 value:【"+entry.getValue()+"】");
|
||||
LogUtil.APP.info("设置HTTPSaveFile参数信息...key:【"+entry.getKey()+"】 value:【"+entry.getValue()+"】");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -362,11 +363,11 @@ public class HttpClientHelper {
|
|||
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
||||
String key=m.getKey();
|
||||
String value=m.getValue();
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始设置|替换HTTPSaveFile头域信息...key:【"+key+"】 value:【"+value+"】");
|
||||
LogUtil.APP.info("开始设置|替换HTTPSaveFile头域信息...key:【"+key+"】 value:【"+value+"】");
|
||||
if(null!=value&&value.indexOf("Base64(")==0){
|
||||
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
||||
value="Basic " + DatatypeConverter.printBase64Binary((valuesub).getBytes());
|
||||
luckyclient.publicclass.LogUtil.APP.info("将头域【"+key+"】的值【"+value+"】FORMAT成BASE64格式...");
|
||||
LogUtil.APP.info("将头域【"+key+"】的值【"+value+"】FORMAT成BASE64格式...");
|
||||
con.setRequestProperty(key, value);
|
||||
}else{
|
||||
con.setRequestProperty(key, value);
|
||||
|
@ -394,14 +395,14 @@ public class HttpClientHelper {
|
|||
os.flush();
|
||||
return resultBuffer.toString()+"下载文件成功,请前往客户端路径:" + fileSavePath + " 查看附件。";
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
if (os != null) {
|
||||
try {
|
||||
os.close();
|
||||
} catch (IOException e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
os = null;
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
|
@ -415,7 +416,7 @@ public class HttpClientHelper {
|
|||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
br = null;
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
|
@ -438,18 +439,18 @@ public class HttpClientHelper {
|
|||
* @return
|
||||
*/
|
||||
public static String sendHttpURLGet(String urlParam, Map<String, Object> params, Map<String, String> headmsg,ProjectProtocolTemplate ppt) {
|
||||
String charset=ppt.getContentencoding().toLowerCase();
|
||||
int timeout=ppt.getConnecttimeout();
|
||||
int responsehead=ppt.getResponsehead();
|
||||
int responsecode=ppt.getResponsecode();
|
||||
String charset=ppt.getEncoding().toLowerCase();
|
||||
int timeout=ppt.getTimeout();
|
||||
int responsehead=ppt.getIsResponseHead();
|
||||
int responsecode=ppt.getIsResponseCode();
|
||||
|
||||
StringBuffer resultBuffer = null;
|
||||
// 构建请求参数
|
||||
luckyclient.publicclass.LogUtil.APP.info("设置HTTP请求地址:【"+urlParam+"】");
|
||||
LogUtil.APP.info("设置HTTP请求地址:【"+urlParam+"】");
|
||||
StringBuffer sbParams = new StringBuffer();
|
||||
if (params != null && params.size() > 0) {
|
||||
if(1==params.size()&¶ms.containsKey("_forTextJson")){
|
||||
luckyclient.publicclass.LogUtil.APP.error("协议模板是纯文本模式(仅限httpClientPostJson以及httpClientPutJson请求),无法使用sendHttpURLGet请求(必须为key-value)...");
|
||||
LogUtil.APP.warn("协议模板是纯文本模式(仅限httpClientPostJson以及httpClientPutJson请求),无法使用sendHttpURLGet请求(必须为key-value)...");
|
||||
return "协议模板是纯文本模式(仅限httpClientPostJson以及httpClientPutJson请求),无法使用sendHttpURLGet请求(必须为key-value)...";
|
||||
}else{
|
||||
for (Entry<String, Object> entry : params.entrySet()) {
|
||||
|
@ -457,7 +458,7 @@ public class HttpClientHelper {
|
|||
sbParams.append("=");
|
||||
sbParams.append(entry.getValue());
|
||||
sbParams.append("&");
|
||||
luckyclient.publicclass.LogUtil.APP.info("设置HTTPURLGet参数信息...key:【"+entry.getKey()+"】 value:【"+entry.getValue()+"】");
|
||||
LogUtil.APP.info("设置HTTPURLGet参数信息...key:【"+entry.getKey()+"】 value:【"+entry.getValue()+"】");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -476,11 +477,11 @@ public class HttpClientHelper {
|
|||
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
||||
String key=m.getKey();
|
||||
String value=m.getValue();
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始设置|替换HTTPURLGet头域信息...key:【"+key+"】 value:【"+value+"】");
|
||||
LogUtil.APP.info("开始设置|替换HTTPURLGet头域信息...key:【"+key+"】 value:【"+value+"】");
|
||||
if(null!=value&&value.indexOf("Base64(")==0){
|
||||
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
||||
value="Basic " + DatatypeConverter.printBase64Binary((valuesub).getBytes());
|
||||
luckyclient.publicclass.LogUtil.APP.info("将头域【"+key+"】的值【"+value+"】FORMAT成BASE64格式...");
|
||||
LogUtil.APP.info("将头域【"+key+"】的值【"+value+"】FORMAT成BASE64格式...");
|
||||
con.setRequestProperty(key, value);
|
||||
}else{
|
||||
con.setRequestProperty(key, value);
|
||||
|
@ -506,14 +507,14 @@ public class HttpClientHelper {
|
|||
resultBuffer.append("读取服务器响应数据异常!响应码:"+con.getResponseCode());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
br = null;
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
|
@ -537,18 +538,18 @@ public class HttpClientHelper {
|
|||
* @return
|
||||
*/
|
||||
public static String sendURLGet(String urlParam, Map<String, Object> params, Map<String, String> headmsg,ProjectProtocolTemplate ppt) {
|
||||
String charset=ppt.getContentencoding().toLowerCase();
|
||||
int timeout=ppt.getConnecttimeout();
|
||||
int responsehead=ppt.getResponsehead();
|
||||
int responsecode=ppt.getResponsecode();
|
||||
String charset=ppt.getEncoding().toLowerCase();
|
||||
int timeout=ppt.getTimeout();
|
||||
int responsehead=ppt.getIsResponseHead();
|
||||
int responsecode=ppt.getIsResponseCode();
|
||||
|
||||
StringBuffer resultBuffer = null;
|
||||
// 构建请求参数
|
||||
luckyclient.publicclass.LogUtil.APP.info("设置HTTP请求地址:【"+urlParam+"】");
|
||||
LogUtil.APP.info("设置HTTP请求地址:【"+urlParam+"】");
|
||||
StringBuffer sbParams = new StringBuffer();
|
||||
if (params != null && params.size() > 0) {
|
||||
if(1==params.size()&¶ms.containsKey("_forTextJson")){
|
||||
luckyclient.publicclass.LogUtil.APP.error("协议模板是纯文本模式(仅限httpClientPostJson以及httpClientPutJson请求),无法使用sendURLGet请求(必须为key-value)...");
|
||||
LogUtil.APP.warn("协议模板是纯文本模式(仅限httpClientPostJson以及httpClientPutJson请求),无法使用sendURLGet请求(必须为key-value)...");
|
||||
return "协议模板是纯文本模式(仅限httpClientPostJson以及httpClientPutJson请求),无法使用sendURLGet请求(必须为key-value)...";
|
||||
}else{
|
||||
for (Entry<String, Object> entry : params.entrySet()) {
|
||||
|
@ -556,7 +557,7 @@ public class HttpClientHelper {
|
|||
sbParams.append("=");
|
||||
sbParams.append(entry.getValue());
|
||||
sbParams.append("&");
|
||||
luckyclient.publicclass.LogUtil.APP.info("设置URLGet参数信息...key:【"+entry.getKey()+"】 value:【"+entry.getValue()+"】");
|
||||
LogUtil.APP.info("设置URLGet参数信息...key:【"+entry.getKey()+"】 value:【"+entry.getValue()+"】");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -579,11 +580,11 @@ public class HttpClientHelper {
|
|||
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
||||
String key=m.getKey();
|
||||
String value=m.getValue();
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始设置|替换URLGet头域信息...key:【"+key+"】 value:【"+value+"】");
|
||||
LogUtil.APP.info("开始设置|替换URLGet头域信息...key:【"+key+"】 value:【"+value+"】");
|
||||
if(null!=value&&value.indexOf("Base64(")==0){
|
||||
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
||||
value="Basic " + DatatypeConverter.printBase64Binary((valuesub).getBytes());
|
||||
luckyclient.publicclass.LogUtil.APP.info("将头域【"+key+"】的值【"+value+"】FORMAT成BASE64格式...");
|
||||
LogUtil.APP.info("将头域【"+key+"】的值【"+value+"】FORMAT成BASE64格式...");
|
||||
con.setRequestProperty(key, value);
|
||||
}else{
|
||||
con.setRequestProperty(key, value);
|
||||
|
@ -610,14 +611,14 @@ public class HttpClientHelper {
|
|||
resultBuffer.append("读取服务器响应数据异常!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
br = null;
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -638,14 +639,14 @@ public class HttpClientHelper {
|
|||
* @throws KeyManagementException
|
||||
*/
|
||||
public static String httpClientPostJson(String urlParam, Map<String, Object> params, Map<String, String> headmsg,ProjectProtocolTemplate ppt) throws NoSuchAlgorithmException, KeyManagementException {
|
||||
String charset=ppt.getContentencoding().toLowerCase();
|
||||
String cerpath=ppt.getCerpath();
|
||||
int timeout=ppt.getConnecttimeout()*1000;
|
||||
int responsehead=ppt.getResponsehead();
|
||||
int responsecode=ppt.getResponsecode();
|
||||
String cerpath=ppt.getCerificatePath();
|
||||
String charset=ppt.getEncoding().toLowerCase();
|
||||
int timeout=ppt.getTimeout()*1000;
|
||||
int responsehead=ppt.getIsResponseHead();
|
||||
int responsecode=ppt.getIsResponseCode();
|
||||
|
||||
StringBuffer resultBuffer = null;
|
||||
luckyclient.publicclass.LogUtil.APP.info("设置HTTP请求地址:【"+urlParam+"】");
|
||||
LogUtil.APP.info("设置HTTP请求地址:【"+urlParam+"】");
|
||||
CloseableHttpClient httpclient=iniHttpClient(urlParam,cerpath);
|
||||
HttpPost httpPost = new HttpPost(urlParam);
|
||||
httpPost.setHeader("Content-Type", "application/json");
|
||||
|
@ -658,11 +659,11 @@ public class HttpClientHelper {
|
|||
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
||||
String key=m.getKey();
|
||||
String value=m.getValue();
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始设置|替换HTTPPostJson头域信息...key:【"+key+"】 value:【"+value+"】");
|
||||
LogUtil.APP.info("开始设置|替换HTTPPostJson头域信息...key:【"+key+"】 value:【"+value+"】");
|
||||
if(null!=value&&value.indexOf("Base64(")==0){
|
||||
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
||||
value="Basic " + DatatypeConverter.printBase64Binary((valuesub).getBytes());
|
||||
luckyclient.publicclass.LogUtil.APP.info("将头域【"+key+"】的值【"+value+"】FORMAT成BASE64格式...");
|
||||
LogUtil.APP.info("将头域【"+key+"】的值【"+value+"】FORMAT成BASE64格式...");
|
||||
httpPost.setHeader(key, value);
|
||||
}else{
|
||||
httpPost.setHeader(key, value);
|
||||
|
@ -673,12 +674,12 @@ public class HttpClientHelper {
|
|||
try {
|
||||
if(params.size()>0){
|
||||
if(1==params.size()&¶ms.containsKey("_forTextJson")){
|
||||
luckyclient.publicclass.LogUtil.APP.info("参数类型:TEXT,设置HTTPPostJson参数信息...【"+params.get("_forTextJson").toString()+"】");
|
||||
LogUtil.APP.info("参数类型:TEXT,设置HTTPPostJson参数信息...【"+params.get("_forTextJson").toString()+"】");
|
||||
StringEntity entity = new StringEntity(params.get("_forTextJson").toString(),charset);
|
||||
httpPost.setEntity(entity);
|
||||
}else{
|
||||
String jsonString = JSON.toJSONString(params);
|
||||
luckyclient.publicclass.LogUtil.APP.info("参数类型:FORM,设置HTTPPostJson参数信息...【"+jsonString+"】");
|
||||
LogUtil.APP.info("参数类型:FORM,设置HTTPPostJson参数信息...【"+jsonString+"】");
|
||||
StringEntity entity = new StringEntity(jsonString,charset);
|
||||
httpPost.setEntity(entity);
|
||||
}
|
||||
|
@ -707,14 +708,14 @@ public class HttpClientHelper {
|
|||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
br = null;
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -735,15 +736,15 @@ public class HttpClientHelper {
|
|||
* @throws KeyManagementException
|
||||
*/
|
||||
public static String httpClientPost(String urlParam, Map<String, Object> params, Map<String, String> headmsg,ProjectProtocolTemplate ppt) throws NoSuchAlgorithmException, KeyManagementException {
|
||||
String charset=ppt.getContentencoding().toLowerCase();
|
||||
String cerpath=ppt.getCerpath();
|
||||
int timeout=ppt.getConnecttimeout()*1000;
|
||||
int responsehead=ppt.getResponsehead();
|
||||
int responsecode=ppt.getResponsecode();
|
||||
String cerpath=ppt.getCerificatePath();
|
||||
String charset=ppt.getEncoding().toLowerCase();
|
||||
int timeout=ppt.getTimeout()*1000;
|
||||
int responsehead=ppt.getIsResponseHead();
|
||||
int responsecode=ppt.getIsResponseCode();
|
||||
|
||||
StringBuffer resultBuffer = null;
|
||||
CloseableHttpClient httpclient=iniHttpClient(urlParam,cerpath);
|
||||
luckyclient.publicclass.LogUtil.APP.info("设置HTTP请求地址:【"+urlParam+"】");
|
||||
LogUtil.APP.info("设置HTTP请求地址:【"+urlParam+"】");
|
||||
HttpPost httpPost = new HttpPost(urlParam);
|
||||
RequestConfig requestConfig = RequestConfig.custom()
|
||||
.setConnectTimeout(timeout)
|
||||
|
@ -754,11 +755,11 @@ public class HttpClientHelper {
|
|||
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
||||
String key=m.getKey();
|
||||
String value=m.getValue();
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始设置|替换HTTPClientPost头域信息...key:【"+key+"】 value:【"+value+"】");
|
||||
LogUtil.APP.info("开始设置|替换HTTPClientPost头域信息...key:【"+key+"】 value:【"+value+"】");
|
||||
if(null!=value&&value.indexOf("Base64(")==0){
|
||||
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
||||
value="Basic " + DatatypeConverter.printBase64Binary((valuesub).getBytes());
|
||||
luckyclient.publicclass.LogUtil.APP.info("将头域【"+key+"】的值【"+value+"】FORMAT成BASE64格式...");
|
||||
LogUtil.APP.info("将头域【"+key+"】的值【"+value+"】FORMAT成BASE64格式...");
|
||||
httpPost.setHeader(key, value);
|
||||
}else{
|
||||
httpPost.setHeader(key, value);
|
||||
|
@ -769,14 +770,14 @@ public class HttpClientHelper {
|
|||
try {
|
||||
if(params.size()>0){
|
||||
if(1==params.size()&¶ms.containsKey("_forTextJson")){
|
||||
luckyclient.publicclass.LogUtil.APP.error("协议模板是纯文本模式(仅限httpClientPostJson以及httpClientPutJson请求),无法使用httpClientPost请求(必须为key-value)...");
|
||||
LogUtil.APP.warn("协议模板是纯文本模式(仅限httpClientPostJson以及httpClientPutJson请求),无法使用httpClientPost请求(必须为key-value)...");
|
||||
return "协议模板是纯文本模式(仅限httpClientPostJson以及httpClientPutJson请求),无法使用httpClientPost请求(必须为key-value)...";
|
||||
}else{
|
||||
//拼接参数
|
||||
List <NameValuePair> nvps = new ArrayList <NameValuePair>();
|
||||
for (Map.Entry<String, Object> m :params.entrySet()) {
|
||||
nvps.add(new BasicNameValuePair(m.getKey(), m.getValue().toString()));
|
||||
luckyclient.publicclass.LogUtil.APP.info("设置HTTPClientPost参数信息...key:【"+m.getKey()+"】 value:【"+m.getValue()+"】");
|
||||
LogUtil.APP.info("设置HTTPClientPost参数信息...key:【"+m.getKey()+"】 value:【"+m.getValue()+"】");
|
||||
}
|
||||
httpPost.setEntity(new UrlEncodedFormEntity(nvps,charset));
|
||||
}
|
||||
|
@ -805,14 +806,14 @@ public class HttpClientHelper {
|
|||
resultBuffer.append("读取服务器响应数据异常,响应码:"+response.getStatusLine().getStatusCode());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
br = null;
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -834,14 +835,14 @@ public class HttpClientHelper {
|
|||
* @throws KeyManagementException
|
||||
*/
|
||||
public static String httpClientUploadFile(String urlParam, Map<String, Object> params, Map<String, String> headmsg,ProjectProtocolTemplate ppt) throws NoSuchAlgorithmException, KeyManagementException {
|
||||
String charset=ppt.getContentencoding().toLowerCase();
|
||||
String cerpath=ppt.getCerpath();
|
||||
int timeout=ppt.getConnecttimeout()*1000;
|
||||
int responsehead=ppt.getResponsehead();
|
||||
int responsecode=ppt.getResponsecode();
|
||||
String cerpath=ppt.getCerificatePath();
|
||||
String charset=ppt.getEncoding().toLowerCase();
|
||||
int timeout=ppt.getTimeout()*1000;
|
||||
int responsehead=ppt.getIsResponseHead();
|
||||
int responsecode=ppt.getIsResponseCode();
|
||||
|
||||
StringBuffer resultBuffer = null;
|
||||
luckyclient.publicclass.LogUtil.APP.info("设置HTTP请求地址:【"+urlParam+"】");
|
||||
LogUtil.APP.info("设置HTTP请求地址:【"+urlParam+"】");
|
||||
CloseableHttpClient httpclient=iniHttpClient(urlParam,cerpath);
|
||||
HttpPost httpPost = new HttpPost(urlParam);
|
||||
RequestConfig requestConfig = RequestConfig.custom()
|
||||
|
@ -853,11 +854,11 @@ public class HttpClientHelper {
|
|||
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
||||
String key=m.getKey();
|
||||
String value=m.getValue();
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始设置|替换httpClientUploadFile头域信息...key:【"+key+"】 value:【"+value+"】");
|
||||
LogUtil.APP.info("开始设置|替换httpClientUploadFile头域信息...key:【"+key+"】 value:【"+value+"】");
|
||||
if(null!=value&&value.indexOf("Base64(")==0){
|
||||
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
||||
value="Basic " + DatatypeConverter.printBase64Binary((valuesub).getBytes());
|
||||
luckyclient.publicclass.LogUtil.APP.info("将头域【"+key+"】的值【"+value+"】FORMAT成BASE64格式...");
|
||||
LogUtil.APP.info("将头域【"+key+"】的值【"+value+"】FORMAT成BASE64格式...");
|
||||
httpPost.setHeader(key, value);
|
||||
}else{
|
||||
httpPost.setHeader(key, value);
|
||||
|
@ -868,7 +869,7 @@ public class HttpClientHelper {
|
|||
try {
|
||||
if(params.size()>0){
|
||||
if(1==params.size()&¶ms.containsKey("_forTextJson")){
|
||||
luckyclient.publicclass.LogUtil.APP.error("协议模板是纯文本模式(仅限httpClientPostJson以及httpClientPutJson请求),无法使用httpClientUploadFile请求(必须为key-value)...");
|
||||
LogUtil.APP.warn("协议模板是纯文本模式(仅限httpClientPostJson以及httpClientPutJson请求),无法使用httpClientUploadFile请求(必须为key-value)...");
|
||||
return "协议模板是纯文本模式(仅限httpClientPostJson以及httpClientPutJson请求),无法使用httpClientUploadFile请求(必须为key-value)...";
|
||||
}else{
|
||||
//拼接参数
|
||||
|
@ -879,10 +880,10 @@ public class HttpClientHelper {
|
|||
for (Map.Entry<String, Object> m :params.entrySet()) {
|
||||
if (m.getValue() instanceof File) {
|
||||
entityBuilder.addBinaryBody(m.getKey(), (File)m.getValue());
|
||||
luckyclient.publicclass.LogUtil.APP.info("设置httpClientUploadFile 上传文件参数信息...key:【"+m.getKey()+"】 value:【"+m.getValue()+"】");
|
||||
LogUtil.APP.info("设置httpClientUploadFile 上传文件参数信息...key:【"+m.getKey()+"】 value:【"+m.getValue()+"】");
|
||||
}else{
|
||||
entityBuilder.addTextBody(m.getKey(), m.getValue().toString());
|
||||
luckyclient.publicclass.LogUtil.APP.info("设置httpClientUploadFile参数信息...key:【"+m.getKey()+"】 value:【"+m.getValue()+"】");
|
||||
LogUtil.APP.info("设置httpClientUploadFile参数信息...key:【"+m.getKey()+"】 value:【"+m.getValue()+"】");
|
||||
}
|
||||
}
|
||||
HttpEntity reqEntity =entityBuilder.build();
|
||||
|
@ -913,14 +914,14 @@ public class HttpClientHelper {
|
|||
resultBuffer.append("读取服务器响应数据异常,响应码:"+response.getStatusLine().getStatusCode());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
br = null;
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -941,21 +942,21 @@ public class HttpClientHelper {
|
|||
* @throws KeyManagementException
|
||||
*/
|
||||
public static String httpClientGet(String urlParam, Map<String, Object> params, Map<String, String> headmsg,ProjectProtocolTemplate ppt) throws NoSuchAlgorithmException, KeyManagementException {
|
||||
String charset=ppt.getContentencoding().toLowerCase();
|
||||
String cerpath=ppt.getCerpath();
|
||||
int timeout=ppt.getConnecttimeout()*1000;
|
||||
int responsehead=ppt.getResponsehead();
|
||||
int responsecode=ppt.getResponsecode();
|
||||
String cerpath=ppt.getCerificatePath();
|
||||
String charset=ppt.getEncoding().toLowerCase();
|
||||
int timeout=ppt.getTimeout()*1000;
|
||||
int responsehead=ppt.getIsResponseHead();
|
||||
int responsecode=ppt.getIsResponseCode();
|
||||
|
||||
StringBuffer resultBuffer = null;
|
||||
luckyclient.publicclass.LogUtil.APP.info("设置HTTP请求地址:【"+urlParam+"】");
|
||||
LogUtil.APP.info("设置HTTP请求地址:【"+urlParam+"】");
|
||||
CloseableHttpClient httpclient=iniHttpClient(urlParam,cerpath);
|
||||
BufferedReader br = null;
|
||||
// 构建请求参数
|
||||
StringBuffer sbParams = new StringBuffer();
|
||||
if (params != null && params.size() > 0) {
|
||||
if(1==params.size()&¶ms.containsKey("_forTextJson")){
|
||||
luckyclient.publicclass.LogUtil.APP.error("协议模板是纯文本模式(仅限httpClientPostJson以及httpClientPutJson请求),无法使用httpClientGet请求(必须为key-value)...");
|
||||
LogUtil.APP.warn("协议模板是纯文本模式(仅限httpClientPostJson以及httpClientPutJson请求),无法使用httpClientGet请求(必须为key-value)...");
|
||||
return "协议模板是纯文本模式(仅限httpClientPostJson以及httpClientPutJson请求),无法使用httpClientGet请求(必须为key-value)...";
|
||||
}else{
|
||||
for (Entry<String, Object> entry : params.entrySet()) {
|
||||
|
@ -964,11 +965,11 @@ public class HttpClientHelper {
|
|||
try {
|
||||
sbParams.append(URLEncoder.encode(String.valueOf(entry.getValue()), charset));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
sbParams.append("&");
|
||||
luckyclient.publicclass.LogUtil.APP.info("设置HTTPClientGet参数信息...key:【"+entry.getKey()+"】 value:【"+entry.getValue()+"】");
|
||||
LogUtil.APP.info("设置HTTPClientGet参数信息...key:【"+entry.getKey()+"】 value:【"+entry.getValue()+"】");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -986,11 +987,11 @@ public class HttpClientHelper {
|
|||
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
||||
String key=m.getKey();
|
||||
String value=m.getValue();
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始设置|替换HTTPClientGet头域信息...key:【"+key+"】 value:【"+value+"】");
|
||||
LogUtil.APP.info("开始设置|替换HTTPClientGet头域信息...key:【"+key+"】 value:【"+value+"】");
|
||||
if(null!=value&&value.indexOf("Base64(")==0){
|
||||
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
||||
value="Basic " + DatatypeConverter.printBase64Binary((valuesub).getBytes());
|
||||
luckyclient.publicclass.LogUtil.APP.info("将头域【"+key+"】的值【"+value+"】FORMAT成BASE64格式...");
|
||||
LogUtil.APP.info("将头域【"+key+"】的值【"+value+"】FORMAT成BASE64格式...");
|
||||
httpGet.setHeader(key, value);
|
||||
}else{
|
||||
httpGet.setHeader(key, value);
|
||||
|
@ -1018,14 +1019,14 @@ public class HttpClientHelper {
|
|||
resultBuffer.append(temp);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
br = null;
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -1045,12 +1046,12 @@ public class HttpClientHelper {
|
|||
public static String sendSocketPost(String urlParam, Map<String, Object> params, String charset,
|
||||
Map<String, String> headmsg) {
|
||||
String result = "";
|
||||
luckyclient.publicclass.LogUtil.APP.info("设置Socket请求地址:【"+urlParam+"】");
|
||||
LogUtil.APP.info("设置Socket请求地址:【"+urlParam+"】");
|
||||
// 构建请求参数
|
||||
StringBuffer sbParams = new StringBuffer();
|
||||
if (params != null && params.size() > 0) {
|
||||
if(1==params.size()&¶ms.containsKey("_forTextJson")){
|
||||
luckyclient.publicclass.LogUtil.APP.error("协议模板是纯文本模式(仅限httpClientPostJson以及httpClientPutJson请求),无法使用sendSocketPost请求(必须为key-value)...");
|
||||
LogUtil.APP.warn("协议模板是纯文本模式(仅限httpClientPostJson以及httpClientPutJson请求),无法使用sendSocketPost请求(必须为key-value)...");
|
||||
return "协议模板是纯文本模式(仅限httpClientPostJson以及httpClientPutJson请求),无法使用sendSocketPost请求(必须为key-value)...";
|
||||
}else{
|
||||
for (Entry<String, Object> entry : params.entrySet()) {
|
||||
|
@ -1058,7 +1059,7 @@ public class HttpClientHelper {
|
|||
sbParams.append("=");
|
||||
sbParams.append(entry.getValue());
|
||||
sbParams.append("&");
|
||||
luckyclient.publicclass.LogUtil.APP.info("设置SocketPost参数信息...key:【"+entry.getKey()+"】 value:【"+entry.getValue()+"】");
|
||||
LogUtil.APP.info("设置SocketPost参数信息...key:【"+entry.getKey()+"】 value:【"+entry.getValue()+"】");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1083,11 +1084,11 @@ public class HttpClientHelper {
|
|||
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
||||
String key=m.getKey();
|
||||
String value=m.getValue();
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始设置|替换Socket头域信息...key:【"+key+"】 value:【"+value+"】");
|
||||
LogUtil.APP.info("开始设置|替换Socket头域信息...key:【"+key+"】 value:【"+value+"】");
|
||||
if(null!=value&&value.indexOf("Base64(")==0){
|
||||
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
||||
value="Basic " + DatatypeConverter.printBase64Binary((valuesub).getBytes());
|
||||
luckyclient.publicclass.LogUtil.APP.info("将头域【"+key+"】的值【"+value+"】FORMAT成BASE64格式...");
|
||||
LogUtil.APP.info("将头域【"+key+"】的值【"+value+"】FORMAT成BASE64格式...");
|
||||
sb.append(key+": "+value+" \r\n");
|
||||
}else{
|
||||
sb.append(key+": "+value+" \r\n");
|
||||
|
@ -1118,14 +1119,14 @@ public class HttpClientHelper {
|
|||
// 读取出响应体数据(就是你要的数据)
|
||||
result = readLine(is, contentLength, charset);
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
if (osw != null) {
|
||||
try {
|
||||
osw.close();
|
||||
} catch (IOException e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
osw = null;
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
|
@ -1133,7 +1134,7 @@ public class HttpClientHelper {
|
|||
try {
|
||||
socket.close();
|
||||
} catch (IOException e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
socket = null;
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -1144,7 +1145,7 @@ public class HttpClientHelper {
|
|||
try {
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
is = null;
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
|
@ -1153,7 +1154,7 @@ public class HttpClientHelper {
|
|||
socket.close();
|
||||
} catch (IOException e) {
|
||||
socket = null;
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
@ -1173,12 +1174,12 @@ public class HttpClientHelper {
|
|||
*/
|
||||
public static String sendSocketGet(String urlParam, Map<String, Object> params, String charset,Map<String, String> headmsg) {
|
||||
String result = "";
|
||||
luckyclient.publicclass.LogUtil.APP.info("设置Socket请求地址:【"+urlParam+"】");
|
||||
LogUtil.APP.info("设置Socket请求地址:【"+urlParam+"】");
|
||||
// 构建请求参数
|
||||
StringBuffer sbParams = new StringBuffer();
|
||||
if (params != null && params.size() > 0) {
|
||||
if(1==params.size()&¶ms.containsKey("_forTextJson")){
|
||||
luckyclient.publicclass.LogUtil.APP.error("协议模板是纯文本模式(仅限httpClientPostJson以及httpClientPutJson请求),无法使用sendSocketGet请求(必须为key-value)...");
|
||||
LogUtil.APP.warn("协议模板是纯文本模式(仅限httpClientPostJson以及httpClientPutJson请求),无法使用sendSocketGet请求(必须为key-value)...");
|
||||
return "协议模板是纯文本模式(仅限httpClientPostJson以及httpClientPutJson请求),无法使用sendSocketGet请求(必须为key-value)...";
|
||||
}else{
|
||||
for (Entry<String, Object> entry : params.entrySet()) {
|
||||
|
@ -1186,7 +1187,7 @@ public class HttpClientHelper {
|
|||
sbParams.append("=");
|
||||
sbParams.append(entry.getValue());
|
||||
sbParams.append("&");
|
||||
luckyclient.publicclass.LogUtil.APP.info("设置SocketPost参数信息...key:【"+entry.getKey()+"】 value:【"+entry.getValue()+"】");
|
||||
LogUtil.APP.info("设置SocketPost参数信息...key:【"+entry.getKey()+"】 value:【"+entry.getValue()+"】");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1212,11 +1213,11 @@ public class HttpClientHelper {
|
|||
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
||||
String key=m.getKey();
|
||||
String value=m.getValue();
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始设置|替换Socket头域信息...key:【"+key+"】 value:【"+value+"】");
|
||||
LogUtil.APP.info("开始设置|替换Socket头域信息...key:【"+key+"】 value:【"+value+"】");
|
||||
if(null!=value&&value.indexOf("Base64(")==0){
|
||||
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
||||
value="Basic " + DatatypeConverter.printBase64Binary((valuesub).getBytes());
|
||||
luckyclient.publicclass.LogUtil.APP.info("将头域【"+key+"】的值【"+value+"】FORMAT成BASE64格式...");
|
||||
LogUtil.APP.info("将头域【"+key+"】的值【"+value+"】FORMAT成BASE64格式...");
|
||||
sb.append(key+": "+value+" \r\n");
|
||||
}else{
|
||||
sb.append(key+": "+value+" \r\n");
|
||||
|
@ -1247,14 +1248,14 @@ public class HttpClientHelper {
|
|||
// 读取出响应体数据(就是你要的数据)
|
||||
result = readLine(is, contentLength, charset);
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
if (osw != null) {
|
||||
try {
|
||||
osw.close();
|
||||
} catch (IOException e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
osw = null;
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
|
@ -1262,7 +1263,7 @@ public class HttpClientHelper {
|
|||
try {
|
||||
socket.close();
|
||||
} catch (IOException e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
socket = null;
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -1273,7 +1274,7 @@ public class HttpClientHelper {
|
|||
try {
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
is = null;
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
|
@ -1281,7 +1282,7 @@ public class HttpClientHelper {
|
|||
try {
|
||||
socket.close();
|
||||
} catch (IOException e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
socket = null;
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -1336,18 +1337,18 @@ public class HttpClientHelper {
|
|||
* @return
|
||||
*/
|
||||
public static String sendHttpURLDel(String urlParam, Map<String, Object> params, Map<String, String> headmsg,ProjectProtocolTemplate ppt) {
|
||||
String charset=ppt.getContentencoding().toLowerCase();
|
||||
int timeout=ppt.getConnecttimeout();
|
||||
int responsehead=ppt.getResponsehead();
|
||||
int responsecode=ppt.getResponsecode();
|
||||
String charset=ppt.getEncoding().toLowerCase();
|
||||
int timeout=ppt.getTimeout();
|
||||
int responsehead=ppt.getIsResponseHead();
|
||||
int responsecode=ppt.getIsResponseCode();
|
||||
|
||||
StringBuffer resultBuffer = null;
|
||||
// 构建请求参数
|
||||
luckyclient.publicclass.LogUtil.APP.info("设置HTTP请求地址:【"+urlParam+"】");
|
||||
LogUtil.APP.info("设置HTTP请求地址:【"+urlParam+"】");
|
||||
StringBuffer sbParams = new StringBuffer();
|
||||
if (params != null && params.size() > 0) {
|
||||
if(1==params.size()&¶ms.containsKey("_forTextJson")){
|
||||
luckyclient.publicclass.LogUtil.APP.error("协议模板是纯文本模式(仅限httpClientPostJson以及httpClientPutJson请求),无法使用sendHttpURLDel请求(必须为key-value)...");
|
||||
LogUtil.APP.warn("协议模板是纯文本模式(仅限httpClientPostJson以及httpClientPutJson请求),无法使用sendHttpURLDel请求(必须为key-value)...");
|
||||
return "协议模板是纯文本模式(仅限httpClientPostJson以及httpClientPutJson请求),无法使用sendHttpURLDel请求(必须为key-value)...";
|
||||
}else{
|
||||
for (Entry<String, Object> e : params.entrySet()) {
|
||||
|
@ -1355,7 +1356,7 @@ public class HttpClientHelper {
|
|||
sbParams.append("=");
|
||||
sbParams.append(e.getValue());
|
||||
sbParams.append("&");
|
||||
luckyclient.publicclass.LogUtil.APP.info("设置HttpURLDel参数信息...key:【"+e.getKey()+"】 value:【"+e.getValue()+"】");
|
||||
LogUtil.APP.info("设置HttpURLDel参数信息...key:【"+e.getKey()+"】 value:【"+e.getValue()+"】");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1375,11 +1376,11 @@ public class HttpClientHelper {
|
|||
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
||||
String key=m.getKey();
|
||||
String value=m.getValue();
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始设置|替换HTTP头域信息...key:【"+key+"】 value:【"+value+"】");
|
||||
LogUtil.APP.info("开始设置|替换HTTP头域信息...key:【"+key+"】 value:【"+value+"】");
|
||||
if(null!=value&&value.indexOf("Base64(")==0){
|
||||
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
||||
value="Basic " + DatatypeConverter.printBase64Binary((valuesub).getBytes());
|
||||
luckyclient.publicclass.LogUtil.APP.info("将头域【"+key+"】的值【"+value+"】FORMAT成BASE64格式...");
|
||||
LogUtil.APP.info("将头域【"+key+"】的值【"+value+"】FORMAT成BASE64格式...");
|
||||
con.setRequestProperty(key,value);
|
||||
}else{
|
||||
con.setRequestProperty(key,value);
|
||||
|
@ -1412,14 +1413,14 @@ public class HttpClientHelper {
|
|||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
if (osw != null) {
|
||||
try {
|
||||
osw.close();
|
||||
} catch (IOException e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
osw = null;
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
|
@ -1433,7 +1434,7 @@ public class HttpClientHelper {
|
|||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
br = null;
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
|
@ -1461,14 +1462,14 @@ public class HttpClientHelper {
|
|||
* @throws NoSuchAlgorithmException
|
||||
*/
|
||||
public static String httpClientPutJson(String urlParam, Map<String, Object> params, Map<String, String> headmsg,ProjectProtocolTemplate ppt) throws KeyManagementException, NoSuchAlgorithmException {
|
||||
String charset=ppt.getContentencoding().toLowerCase();
|
||||
String cerpath=ppt.getCerpath();
|
||||
int timeout=ppt.getConnecttimeout()*1000;
|
||||
int responsehead=ppt.getResponsehead();
|
||||
int responsecode=ppt.getResponsecode();
|
||||
String cerpath=ppt.getCerificatePath();
|
||||
String charset=ppt.getEncoding().toLowerCase();
|
||||
int timeout=ppt.getTimeout()*1000;
|
||||
int responsehead=ppt.getIsResponseHead();
|
||||
int responsecode=ppt.getIsResponseCode();
|
||||
|
||||
StringBuffer resultBuffer = null;
|
||||
luckyclient.publicclass.LogUtil.APP.info("设置HTTP请求地址:【"+urlParam+"】");
|
||||
LogUtil.APP.info("设置HTTP请求地址:【"+urlParam+"】");
|
||||
CloseableHttpClient httpclient=iniHttpClient(urlParam,cerpath);
|
||||
HttpPut httpput = new HttpPut(urlParam);
|
||||
httpput.setHeader("Content-Type", "application/json");
|
||||
|
@ -1481,11 +1482,11 @@ public class HttpClientHelper {
|
|||
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
||||
String key=m.getKey();
|
||||
String value=m.getValue();
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始设置|替换HTTP头域信息...key:【"+key+"】 value:【"+value+"】");
|
||||
LogUtil.APP.info("开始设置|替换HTTP头域信息...key:【"+key+"】 value:【"+value+"】");
|
||||
if(null!=value&&value.indexOf("Base64(")==0){
|
||||
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
||||
value="Basic " + DatatypeConverter.printBase64Binary((valuesub).getBytes());
|
||||
luckyclient.publicclass.LogUtil.APP.info("将头域【"+key+"】的值【"+value+"】FORMAT成BASE64格式...");
|
||||
LogUtil.APP.info("将头域【"+key+"】的值【"+value+"】FORMAT成BASE64格式...");
|
||||
httpput.setHeader(key,value);
|
||||
}else{
|
||||
httpput.setHeader(key,value);
|
||||
|
@ -1496,12 +1497,12 @@ public class HttpClientHelper {
|
|||
try {
|
||||
if(params.size()>0){
|
||||
if(1==params.size()&¶ms.containsKey("_forTextJson")){
|
||||
luckyclient.publicclass.LogUtil.APP.info("参数类型:TEXT,设置HTTPClientPutJson参数信息...【"+params.get("_forTextJson").toString()+"】");
|
||||
LogUtil.APP.info("参数类型:TEXT,设置HTTPClientPutJson参数信息...【"+params.get("_forTextJson").toString()+"】");
|
||||
StringEntity entity = new StringEntity(params.get("_forTextJson").toString(),charset);
|
||||
httpput.setEntity(entity);
|
||||
}else{
|
||||
String jsonString = JSON.toJSONString(params);
|
||||
luckyclient.publicclass.LogUtil.APP.info("参数类型:FORM,设置HTTPClientPutJson参数信息...【"+jsonString+"】");
|
||||
LogUtil.APP.info("参数类型:FORM,设置HTTPClientPutJson参数信息...【"+jsonString+"】");
|
||||
StringEntity entity = new StringEntity(jsonString,charset);
|
||||
httpput.setEntity(entity);
|
||||
}
|
||||
|
@ -1531,14 +1532,14 @@ public class HttpClientHelper {
|
|||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
br = null;
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -1559,14 +1560,14 @@ public class HttpClientHelper {
|
|||
* @throws NoSuchAlgorithmException
|
||||
*/
|
||||
public static String httpClientPut(String urlParam, Map<String, Object> params, Map<String, String> headmsg,ProjectProtocolTemplate ppt) throws KeyManagementException, NoSuchAlgorithmException {
|
||||
String charset=ppt.getContentencoding().toLowerCase();
|
||||
String cerpath=ppt.getCerpath();
|
||||
int timeout=ppt.getConnecttimeout()*1000;
|
||||
int responsehead=ppt.getResponsehead();
|
||||
int responsecode=ppt.getResponsecode();
|
||||
String cerpath=ppt.getCerificatePath();
|
||||
String charset=ppt.getEncoding().toLowerCase();
|
||||
int timeout=ppt.getTimeout()*1000;
|
||||
int responsehead=ppt.getIsResponseHead();
|
||||
int responsecode=ppt.getIsResponseCode();
|
||||
|
||||
StringBuffer resultBuffer = null;
|
||||
luckyclient.publicclass.LogUtil.APP.info("设置HTTP请求地址:【"+urlParam+"】");
|
||||
LogUtil.APP.info("设置HTTP请求地址:【"+urlParam+"】");
|
||||
CloseableHttpClient httpclient=iniHttpClient(urlParam,cerpath);
|
||||
HttpPut httpput = new HttpPut(urlParam);
|
||||
RequestConfig requestConfig = RequestConfig.custom()
|
||||
|
@ -1578,11 +1579,11 @@ public class HttpClientHelper {
|
|||
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
||||
String key=m.getKey();
|
||||
String value=m.getValue();
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始设置|替换HTTP头域信息...key:【"+key+"】 value:【"+value+"】");
|
||||
LogUtil.APP.info("开始设置|替换HTTP头域信息...key:【"+key+"】 value:【"+value+"】");
|
||||
if(null!=value&&value.indexOf("Base64(")==0){
|
||||
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
||||
value="Basic " + DatatypeConverter.printBase64Binary((valuesub).getBytes());
|
||||
luckyclient.publicclass.LogUtil.APP.info("将头域【"+key+"】的值【"+value+"】FORMAT成BASE64格式...");
|
||||
LogUtil.APP.info("将头域【"+key+"】的值【"+value+"】FORMAT成BASE64格式...");
|
||||
httpput.setHeader(key,value);
|
||||
}else{
|
||||
httpput.setHeader(key,value);
|
||||
|
@ -1593,14 +1594,14 @@ public class HttpClientHelper {
|
|||
try {
|
||||
if(params.size()>0){
|
||||
if(1==params.size()&¶ms.containsKey("_forTextJson")){
|
||||
luckyclient.publicclass.LogUtil.APP.error("协议模板是纯文本模式(仅限httpClientPostJson以及httpClientPutJson请求),无法使用httpClientPut请求(必须为key-value)...");
|
||||
LogUtil.APP.warn("协议模板是纯文本模式(仅限httpClientPostJson以及httpClientPutJson请求),无法使用httpClientPut请求(必须为key-value)...");
|
||||
return "协议模板是纯文本模式(仅限httpClientPostJson以及httpClientPutJson请求),无法使用httpClientPut请求(必须为key-value)...";
|
||||
}else{
|
||||
//拼接参数
|
||||
List <NameValuePair> nvps = new ArrayList <NameValuePair>();
|
||||
for (Map.Entry<String, Object> m :params.entrySet()) {
|
||||
nvps.add(new BasicNameValuePair(m.getKey(), m.getValue().toString()));
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始设置HTTPClientPut参数信息...key:【"+m.getKey()+"】 value:【"+m.getValue()+"】");
|
||||
LogUtil.APP.info("开始设置HTTPClientPut参数信息...key:【"+m.getKey()+"】 value:【"+m.getValue()+"】");
|
||||
}
|
||||
httpput.setEntity(new UrlEncodedFormEntity(nvps,charset));
|
||||
}
|
||||
|
@ -1630,14 +1631,14 @@ public class HttpClientHelper {
|
|||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
br = null;
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -1656,12 +1657,12 @@ public class HttpClientHelper {
|
|||
SSLContext sslContext = null;
|
||||
FileInputStream instream = null;
|
||||
KeyStore trustStore = null;
|
||||
luckyclient.publicclass.LogUtil.APP.info("证书路径:"+keyStorePath+" 密钥:"+keyStorepass);
|
||||
LogUtil.APP.info("证书路径:"+keyStorePath+" 密钥:"+keyStorepass);
|
||||
try {
|
||||
trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始读取证书文件流...");
|
||||
LogUtil.APP.info("开始读取证书文件流...");
|
||||
instream = new FileInputStream(new File(keyStorePath));
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始设置证书以及密钥...");
|
||||
LogUtil.APP.info("开始设置证书以及密钥...");
|
||||
trustStore.load(instream, keyStorepass.toCharArray());
|
||||
// 相信自己的CA和所有自签名的证书
|
||||
sslContext = SSLContexts.custom().loadTrustMaterial(trustStore, new TrustSelfSignedStrategy()).build();
|
||||
|
@ -1673,12 +1674,12 @@ public class HttpClientHelper {
|
|||
sslContext = SSLContext.getInstance("SSL", "SunJSSE");
|
||||
sslContext.init(null, tms, new java.security.SecureRandom());
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
} finally {
|
||||
try {
|
||||
instream.close();
|
||||
} catch (IOException e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return sslContext;
|
||||
|
@ -1701,12 +1702,12 @@ public class HttpClientHelper {
|
|||
//采用绕过验证的方式处理https请求
|
||||
SSLContext sslContext=null;
|
||||
if(null==cerpath||"".equals(cerpath.trim())){
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始构建HTTPS单向认证请求...");
|
||||
LogUtil.APP.info("开始构建HTTPS单向认证请求...");
|
||||
TrustManager[] trustManagers = {new MyX509TrustManager()};
|
||||
sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(null, trustManagers, new SecureRandom());
|
||||
}else{
|
||||
luckyclient.publicclass.LogUtil.APP.info("开始构建HTTPS双向认证请求...");
|
||||
LogUtil.APP.info("开始构建HTTPS双向认证请求...");
|
||||
String strcerpath[]=cerpath.split(";",-1);
|
||||
sslContext = sslContextKeyStore(strcerpath[0], strcerpath[1]);
|
||||
}
|
||||
|
|
|
@ -7,13 +7,22 @@ import java.io.OutputStreamWriter;
|
|||
import java.io.PrintWriter;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
|
||||
import luckyclient.publicclass.LogUtil;
|
||||
import luckyclient.publicclass.SysConfig;
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
|
@ -26,7 +35,7 @@ import org.apache.http.impl.client.HttpClients;
|
|||
*
|
||||
*/
|
||||
public class HttpRequest {
|
||||
final static Properties PROPERTIES = luckyclient.publicclass.SysConfig.getConfiguration();
|
||||
final static Properties PROPERTIES = SysConfig.getConfiguration();
|
||||
private final static String WEB_URL = "http://" + PROPERTIES.getProperty("server.web.ip") + ":"
|
||||
+ PROPERTIES.getProperty("server.web.port");
|
||||
|
||||
|
@ -53,14 +62,14 @@ public class HttpRequest {
|
|||
resultBuffer.append(temp);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
|
||||
LogUtil.APP.error(e.getMessage(), e);
|
||||
br = null;
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -127,6 +136,59 @@ public class HttpRequest {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用HttpClient以JSON格式发送post请求
|
||||
* @param urlParam
|
||||
* @param params
|
||||
* @param charset
|
||||
* @param headmsg
|
||||
* @param cerpath
|
||||
* @return
|
||||
* @throws NoSuchAlgorithmException
|
||||
* @throws KeyManagementException
|
||||
*/
|
||||
public static String httpClientPostJson(String urlParam, String params){
|
||||
StringBuffer resultBuffer = null;
|
||||
CloseableHttpClient httpclient=HttpClients.createDefault();
|
||||
HttpPost httpPost = new HttpPost(WEB_URL+urlParam);
|
||||
httpPost.setHeader("Content-Type", "application/json");
|
||||
RequestConfig requestConfig = RequestConfig.custom()
|
||||
.setConnectTimeout(60*1000)
|
||||
.setConnectionRequestTimeout(60*1000)
|
||||
.setSocketTimeout(60*1000).build(); //设置请求和传输超时时间
|
||||
httpPost.setConfig(requestConfig);
|
||||
// 构建请求参数
|
||||
BufferedReader br = null;
|
||||
try {
|
||||
StringEntity entity = new StringEntity(params,"utf-8");
|
||||
httpPost.setEntity(entity);
|
||||
|
||||
CloseableHttpResponse response = httpclient.execute(httpPost);
|
||||
|
||||
// 读取服务器响应数据
|
||||
resultBuffer = new StringBuffer();
|
||||
if(null!=response.getEntity()){
|
||||
br = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "utf-8"));
|
||||
String temp;
|
||||
while ((temp = br.readLine()) != null) {
|
||||
resultBuffer.append(temp);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
br = null;
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return resultBuffer.toString();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
|
|
@ -0,0 +1,161 @@
|
|||
package luckyclient.serverapi.api;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import luckyclient.publicclass.remoterinterface.HttpRequest;
|
||||
import luckyclient.serverapi.entity.ProjectCase;
|
||||
import luckyclient.serverapi.entity.ProjectCaseParams;
|
||||
import luckyclient.serverapi.entity.ProjectCaseSteps;
|
||||
import luckyclient.serverapi.entity.ProjectProtocolTemplate;
|
||||
import luckyclient.serverapi.entity.ProjectTemplateParams;
|
||||
import luckyclient.serverapi.entity.TaskExecute;
|
||||
import luckyclient.serverapi.entity.TaskScheduling;
|
||||
|
||||
|
||||
/**
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||
* =================================================================
|
||||
*
|
||||
* @author: seagull
|
||||
* @date 2017年12月1日 上午9:29:40
|
||||
*
|
||||
*/
|
||||
public class GetServerAPI {
|
||||
|
||||
private static final String prefix = "/openGetApi";
|
||||
/**
|
||||
* 通过计划ID获取测试用例对象集
|
||||
* @param planid
|
||||
* @return
|
||||
*/
|
||||
public static List<ProjectCase> getCasesbyplanId(int planId) {
|
||||
String result = HttpRequest.loadJSON(prefix+"/clientGetCaseListByPlanId.do?planId=" + planId);
|
||||
List<ProjectCase> caseList = JSONObject.parseArray(result, ProjectCase.class);
|
||||
return caseList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过计划名称获取测试用例对象集
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public static List<ProjectCase> getCasesbyplanname(String name) {
|
||||
String result = HttpRequest.loadJSON(prefix+"/clientGetCaseListByPlanName.do?planName=" + name);
|
||||
List<ProjectCase> caseList = JSONObject.parseArray(result, ProjectCase.class);
|
||||
return caseList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用例ID获取下面的步骤对象
|
||||
* @param caseid
|
||||
* @return
|
||||
*/
|
||||
public static List<ProjectCaseSteps> getStepsbycaseid(Integer caseid) {
|
||||
String result = HttpRequest.loadJSON(prefix+"/clientGetStepListByCaseId.do?caseId=" + caseid);
|
||||
List<ProjectCaseSteps> stepsList = JSONObject.parseArray(result, ProjectCaseSteps.class);
|
||||
return stepsList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过taskid获取对象
|
||||
* @param taskid
|
||||
* @return
|
||||
*/
|
||||
public static TaskExecute cgetTaskbyid(int taskid) {
|
||||
String result = HttpRequest.loadJSON(prefix+"/clientGetTaskByTaskId.do?taskId=" + taskid);
|
||||
TaskExecute task = JSONObject.parseObject(result, TaskExecute.class);
|
||||
return task;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过taskid获取调度对象
|
||||
* @param taskid
|
||||
* @return
|
||||
*/
|
||||
public static TaskScheduling cGetTaskSchedulingByTaskId(int taskid) {
|
||||
String result = HttpRequest.loadJSON(prefix+"/clientGetTaskSchedulingByTaskId.do?taskId=" + taskid);
|
||||
TaskScheduling taskScheduling = JSONObject.parseObject(result, TaskScheduling.class);
|
||||
return taskScheduling;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用例编号获取对象
|
||||
* @param sign
|
||||
* @return
|
||||
*/
|
||||
public static ProjectCase cgetCaseBysign(String sign) {
|
||||
String result = HttpRequest.loadJSON(prefix+"/clientGetCaseByCaseSign.do?caseSign=" + sign);
|
||||
ProjectCase projectCase = JSONObject.parseObject(result, ProjectCase.class);
|
||||
return projectCase;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用例ID获取对象
|
||||
* @param sign
|
||||
* @return
|
||||
*/
|
||||
public static ProjectCase cGetCaseByCaseId(Integer caseId) {
|
||||
String result = HttpRequest.loadJSON(prefix+"/clientGetCaseByCaseId.do?caseId=" + caseId);
|
||||
ProjectCase projectCase = JSONObject.parseObject(result, ProjectCase.class);
|
||||
return projectCase;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目下的所有公共参数
|
||||
* @param projectid
|
||||
* @return
|
||||
*/
|
||||
public static List<ProjectCaseParams> cgetParamsByProjectid(String projectid) {
|
||||
String result = HttpRequest.loadJSON(prefix+"/clientGetParamsByProjectId.do?projectId="+projectid);
|
||||
List<ProjectCaseParams> paramsList = JSONObject.parseArray(result, ProjectCaseParams.class);
|
||||
return paramsList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过计划ID获取测试用例对象集
|
||||
* @param planid
|
||||
* @return
|
||||
*/
|
||||
public static List<Integer> clientGetCaseListForUnSucByTaskId(Integer taskId) {
|
||||
String result = HttpRequest.loadJSON(prefix+"/clientGetCaseListForUnSucByTaskId.do?taskId=" + taskId);
|
||||
List<Integer> caseIdList = JSONObject.parseArray(result, Integer.class);
|
||||
return caseIdList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过templateId获取实体
|
||||
* @param templateId
|
||||
* @return
|
||||
* @author Seagull
|
||||
* @date 2019年4月24日
|
||||
*/
|
||||
public static ProjectProtocolTemplate clientGetProjectProtocolTemplateByTemplateId(Integer templateId) {
|
||||
String result = HttpRequest.loadJSON(prefix+"/clientGetProjectProtocolTemplateByTemplateId.do?templateId=" + templateId);
|
||||
ProjectProtocolTemplate projectProtocolTemplate = JSONObject.parseObject(result, ProjectProtocolTemplate.class);
|
||||
return projectProtocolTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过模板ID获取参数列表
|
||||
* @param templateId
|
||||
* @return
|
||||
* @author Seagull
|
||||
* @date 2019年4月24日
|
||||
*/
|
||||
public static List<ProjectTemplateParams> clientGetProjectTemplateParamsListByTemplateId(Integer templateId) {
|
||||
String result = HttpRequest.loadJSON(prefix+"/clientGetProjectTemplateParamsListByTemplateId.do?templateId=" + templateId);
|
||||
List<ProjectTemplateParams> projectTemplateParamsList = JSONObject.parseArray(result, ProjectTemplateParams.class);
|
||||
return projectTemplateParamsList;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws UnsupportedEncodingException {
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,145 @@
|
|||
package luckyclient.serverapi.api;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Date;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import luckyclient.publicclass.remoterinterface.HttpRequest;
|
||||
import luckyclient.serverapi.entity.ProjectCaseDebug;
|
||||
import luckyclient.serverapi.entity.TaskCaseExecute;
|
||||
import luckyclient.serverapi.entity.TaskCaseLog;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改 有任何疑问欢迎联系作者讨论。 QQ:1573584944 Seagull
|
||||
* =================================================================
|
||||
* @author Seagull
|
||||
* @date 2019年4月18日
|
||||
*/
|
||||
public class PostServerAPI {
|
||||
|
||||
private static final String prefix = "/openPostApi";
|
||||
|
||||
/**
|
||||
* put web界面的数据到服务端
|
||||
* @param sign
|
||||
* @param executor
|
||||
* @param loglevel
|
||||
* @param detail
|
||||
*/
|
||||
public static void cPostDebugLog(Integer userId, Integer caseId, String logLevel, String logDetail,Integer debugIsend){
|
||||
ProjectCaseDebug ProjectCaseDebug = new ProjectCaseDebug();
|
||||
ProjectCaseDebug.setCaseId(caseId);
|
||||
ProjectCaseDebug.setUserId(userId);
|
||||
ProjectCaseDebug.setLogLevel(logLevel);
|
||||
ProjectCaseDebug.setLogDetail(logDetail);
|
||||
ProjectCaseDebug.setDebugIsend(debugIsend);
|
||||
|
||||
HttpRequest.httpClientPostJson(prefix+"/clientPostCaseDebugLog", JSONObject.toJSONString(ProjectCaseDebug));
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入用例执行明细到数据库
|
||||
* @param taskId
|
||||
* @param projectId
|
||||
* @param caseId
|
||||
* @param caseSign
|
||||
* @param caseName
|
||||
* @param caseStatus
|
||||
* @author Seagull
|
||||
* @date 2019年4月22日
|
||||
*/
|
||||
public static void clientPostInsertTaskCaseExecute(Integer taskId, Integer projectId, Integer caseId, String caseSign, String caseName, Integer caseStatus){
|
||||
TaskCaseExecute taskCaseExecute = new TaskCaseExecute();
|
||||
taskCaseExecute.setTaskId(taskId);
|
||||
taskCaseExecute.setProjectId(projectId);
|
||||
taskCaseExecute.setCaseId(caseId);
|
||||
taskCaseExecute.setCaseSign(caseSign);
|
||||
taskCaseExecute.setCaseName(caseName);
|
||||
taskCaseExecute.setCaseStatus(caseStatus);
|
||||
taskCaseExecute.setCreateTime(new Date());
|
||||
taskCaseExecute.setUpdateTime(new Date());
|
||||
|
||||
HttpRequest.httpClientPostJson(prefix+"/clientPostTaskCaseExecute", JSONObject.toJSONString(taskCaseExecute));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用例执行状态
|
||||
* @param taskId
|
||||
* @param caseId
|
||||
* @param caseStatus
|
||||
* @author Seagull
|
||||
* @date 2019年4月22日
|
||||
*/
|
||||
public static void clientUpdateTaskCaseExecuteStatus(Integer taskId, Integer caseId, Integer caseStatus){
|
||||
TaskCaseExecute taskCaseExecute = new TaskCaseExecute();
|
||||
taskCaseExecute.setTaskId(taskId);
|
||||
taskCaseExecute.setCaseId(caseId);
|
||||
taskCaseExecute.setCaseStatus(caseStatus);
|
||||
taskCaseExecute.setUpdateTime(new Date());
|
||||
|
||||
HttpRequest.httpClientPostJson(prefix+"/clientUpdateTaskCaseExecuteStatus", JSONObject.toJSONString(taskCaseExecute));
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入用例执行明细到数据库
|
||||
* @param taskId
|
||||
* @param caseId
|
||||
* @param logDetail
|
||||
* @param logGrade
|
||||
* @param logStep
|
||||
* @param imgname
|
||||
* @author Seagull
|
||||
* @date 2019年4月22日
|
||||
*/
|
||||
public static void clientPostInsertTaskCaseLog(Integer taskId, Integer caseId, String logDetail, String logGrade, String logStep,
|
||||
String imgname){
|
||||
TaskCaseLog taskCaseLog = new TaskCaseLog();
|
||||
taskCaseLog.setTaskId(taskId);
|
||||
taskCaseLog.setCaseId(caseId);
|
||||
taskCaseLog.setLogDetail(logDetail);
|
||||
taskCaseLog.setLogGrade(logGrade);
|
||||
taskCaseLog.setLogStep(logStep);
|
||||
taskCaseLog.setImgname(imgname);
|
||||
taskCaseLog.setCreateTime(new Date());
|
||||
taskCaseLog.setUpdateTime(new Date());
|
||||
|
||||
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+"}";
|
||||
JSONObject jsonObject = JSON.parseObject(str);
|
||||
return HttpRequest.httpClientPostJson(prefix+"/clientUpdateTaskExecuteData", jsonObject.toJSONString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新任务执行数据
|
||||
* @param taskId
|
||||
* @param casecount
|
||||
* @author Seagull
|
||||
* @date 2019年4月22日
|
||||
*/
|
||||
public static String clientDeleteTaskCaseLog(Integer taskId, Integer caseId){
|
||||
String str = "{\"taskId\":"+taskId+",\"caseId\":"+caseId+"}";
|
||||
JSONObject jsonObject = JSON.parseObject(str);
|
||||
return HttpRequest.httpClientPostJson(prefix+"/clientDeleteTaskCaseLog", jsonObject.toJSONString());
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws UnsupportedEncodingException {
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
package luckyclient.serverapi.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
/**
|
||||
* Entity基类
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class BaseEntity implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 搜索值 */
|
||||
private String searchValue;
|
||||
|
||||
/** 创建者 */
|
||||
private String createBy;
|
||||
|
||||
/** 创建时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
/** 更新者 */
|
||||
private String updateBy;
|
||||
|
||||
/** 更新时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
/** 请求参数 */
|
||||
private Map<String, Object> params;
|
||||
|
||||
public String getSearchValue()
|
||||
{
|
||||
return searchValue;
|
||||
}
|
||||
|
||||
public void setSearchValue(String searchValue)
|
||||
{
|
||||
this.searchValue = searchValue;
|
||||
}
|
||||
|
||||
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 Map<String, Object> getParams()
|
||||
{
|
||||
if (params == null)
|
||||
{
|
||||
params = Maps.newHashMap();
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
public void setParams(Map<String, Object> params)
|
||||
{
|
||||
this.params = params;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package luckyclient.serverapi.entity;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* 项目实体
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改 有任何疑问欢迎联系作者讨论。 QQ:1573584944 Seagull
|
||||
* =================================================================
|
||||
* @author Seagull
|
||||
* @date 2019年4月13日
|
||||
*/
|
||||
public class Project extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 项目ID */
|
||||
private Integer projectId;
|
||||
/** 项目名称 */
|
||||
private String projectName;
|
||||
/** 归属部门 */
|
||||
private Integer deptId;
|
||||
/** 项目标识 */
|
||||
private String projectSign;
|
||||
/** 项目标记 */
|
||||
private boolean flag = false;
|
||||
|
||||
public boolean isFlag() {
|
||||
return flag;
|
||||
}
|
||||
|
||||
public void setFlag(boolean flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
public void setProjectId(Integer projectId)
|
||||
{
|
||||
this.projectId = projectId;
|
||||
}
|
||||
|
||||
public Integer getProjectId()
|
||||
{
|
||||
return projectId;
|
||||
}
|
||||
public void setProjectName(String projectName)
|
||||
{
|
||||
this.projectName = projectName;
|
||||
}
|
||||
|
||||
public String getProjectName()
|
||||
{
|
||||
return projectName;
|
||||
}
|
||||
public void setDeptId(Integer deptId)
|
||||
{
|
||||
this.deptId = deptId;
|
||||
}
|
||||
|
||||
public Integer getDeptId()
|
||||
{
|
||||
return deptId;
|
||||
}
|
||||
public void setProjectSign(String projectSign)
|
||||
{
|
||||
this.projectSign = projectSign;
|
||||
}
|
||||
|
||||
public String getProjectSign()
|
||||
{
|
||||
return projectSign;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("projectId", getProjectId())
|
||||
.append("projectName", getProjectName())
|
||||
.append("deptId", getDeptId())
|
||||
.append("projectSign", getProjectSign())
|
||||
.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,189 @@
|
|||
package luckyclient.serverapi.entity;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.apache.tools.ant.Project;
|
||||
|
||||
/**
|
||||
* 测试用例实体
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改 有任何疑问欢迎联系作者讨论。 QQ:1573584944 Seagull
|
||||
* =================================================================
|
||||
* @author Seagull
|
||||
* @date 2019年4月13日
|
||||
*/
|
||||
public class ProjectCase extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 测试用例ID */
|
||||
private Integer caseId;
|
||||
/** 用例编号排序 */
|
||||
private Integer caseSerialNumber;
|
||||
/** 用例标识 */
|
||||
private String caseSign;
|
||||
/** 用例名称 */
|
||||
private String caseName;
|
||||
/** 关联项目ID */
|
||||
private Integer projectId;
|
||||
/** 关联项目模块ID */
|
||||
private Integer moduleId;
|
||||
/** 默认类型 0 API接口 1 Web UI 2 HTTP接口 3移动端 */
|
||||
private Integer caseType;
|
||||
/** 前置步骤失败,后续步骤是否继续,0:中断,1:继续 */
|
||||
private Integer failcontinue;
|
||||
/** 关联项目实体 */
|
||||
private Project project;
|
||||
/** 关联用例模块实体 */
|
||||
private ProjectCaseModule projectCaseModule;
|
||||
/** 用例选中标记 */
|
||||
private boolean flag = false;
|
||||
/** 用例优先级 */
|
||||
private int priority;
|
||||
/** 关联计划ID标识 */
|
||||
private Integer planId;
|
||||
/** 关联计划用例ID标识 */
|
||||
private Integer planCaseId;
|
||||
|
||||
public Integer getPlanCaseId() {
|
||||
return planCaseId;
|
||||
}
|
||||
|
||||
public void setPlanCaseId(Integer planCaseId) {
|
||||
this.planCaseId = planCaseId;
|
||||
}
|
||||
|
||||
public Integer getPlanId() {
|
||||
return planId;
|
||||
}
|
||||
|
||||
public void setPlanId(Integer planId) {
|
||||
this.planId = planId;
|
||||
}
|
||||
|
||||
public boolean isFlag() {
|
||||
return flag;
|
||||
}
|
||||
|
||||
public void setFlag(boolean flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
public int getPriority() {
|
||||
return priority;
|
||||
}
|
||||
|
||||
public void setPriority(int priority) {
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
public ProjectCaseModule getProjectCaseModule() {
|
||||
return projectCaseModule;
|
||||
}
|
||||
|
||||
public void setProjectCaseModule(ProjectCaseModule projectCaseModule) {
|
||||
this.projectCaseModule = projectCaseModule;
|
||||
}
|
||||
|
||||
public Project getProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
public void setProject(Project project) {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
public void setCaseId(Integer caseId)
|
||||
{
|
||||
this.caseId = caseId;
|
||||
}
|
||||
|
||||
public Integer getCaseId()
|
||||
{
|
||||
return caseId;
|
||||
}
|
||||
public void setCaseSerialNumber(Integer caseSerialNumber)
|
||||
{
|
||||
this.caseSerialNumber = caseSerialNumber;
|
||||
}
|
||||
|
||||
public Integer getCaseSerialNumber()
|
||||
{
|
||||
return caseSerialNumber;
|
||||
}
|
||||
public void setCaseSign(String caseSign)
|
||||
{
|
||||
this.caseSign = caseSign;
|
||||
}
|
||||
|
||||
public String getCaseSign()
|
||||
{
|
||||
return caseSign;
|
||||
}
|
||||
public void setCaseName(String caseName)
|
||||
{
|
||||
this.caseName = caseName;
|
||||
}
|
||||
|
||||
public String getCaseName()
|
||||
{
|
||||
return caseName;
|
||||
}
|
||||
public void setProjectId(Integer projectId)
|
||||
{
|
||||
this.projectId = projectId;
|
||||
}
|
||||
|
||||
public Integer getProjectId()
|
||||
{
|
||||
return projectId;
|
||||
}
|
||||
public void setModuleId(Integer moduleId)
|
||||
{
|
||||
this.moduleId = moduleId;
|
||||
}
|
||||
|
||||
public Integer getModuleId()
|
||||
{
|
||||
return moduleId;
|
||||
}
|
||||
public void setCaseType(Integer caseType)
|
||||
{
|
||||
this.caseType = caseType;
|
||||
}
|
||||
|
||||
public Integer getCaseType()
|
||||
{
|
||||
return caseType;
|
||||
}
|
||||
public void setFailcontinue(Integer failcontinue)
|
||||
{
|
||||
this.failcontinue = failcontinue;
|
||||
}
|
||||
|
||||
public Integer getFailcontinue()
|
||||
{
|
||||
return failcontinue;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("caseId", getCaseId())
|
||||
.append("caseSerialNumber", getCaseSerialNumber())
|
||||
.append("caseSign", getCaseSign())
|
||||
.append("caseName", getCaseName())
|
||||
.append("projectId", getProjectId())
|
||||
.append("moduleId", getModuleId())
|
||||
.append("caseType", getCaseType())
|
||||
.append("failcontinue", getFailcontinue())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.append("project", getProject())
|
||||
.append("projectCaseModule", getProjectCaseModule())
|
||||
.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
package luckyclient.serverapi.entity;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* 用例调试日志记录表 project_case_debug
|
||||
*
|
||||
* @author luckyframe
|
||||
* @date 2019-03-14
|
||||
*/
|
||||
public class ProjectCaseDebug extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 调试ID */
|
||||
private Integer debugId;
|
||||
/** 用例ID */
|
||||
private Integer caseId;
|
||||
/** 用户ID */
|
||||
private Integer userId;
|
||||
/** 调试结束标识 0 进行中 1结束 2异常 */
|
||||
private Integer debugIsend;
|
||||
/** 日志级别 info 记录 warning 警告 error 异常 */
|
||||
private String logLevel;
|
||||
/** 日志 */
|
||||
private String logDetail;
|
||||
/** 客户端ID */
|
||||
private Integer clientId;
|
||||
/** 客户端驱动路径 */
|
||||
private String driverPath;
|
||||
|
||||
public Integer getClientId() {
|
||||
return clientId;
|
||||
}
|
||||
|
||||
public void setClientId(Integer clientId) {
|
||||
this.clientId = clientId;
|
||||
}
|
||||
|
||||
public String getDriverPath() {
|
||||
return driverPath;
|
||||
}
|
||||
|
||||
public void setDriverPath(String driverPath) {
|
||||
this.driverPath = driverPath;
|
||||
}
|
||||
|
||||
public void setDebugId(Integer debugId)
|
||||
{
|
||||
this.debugId = debugId;
|
||||
}
|
||||
|
||||
public Integer getDebugId()
|
||||
{
|
||||
return debugId;
|
||||
}
|
||||
public void setCaseId(Integer caseId)
|
||||
{
|
||||
this.caseId = caseId;
|
||||
}
|
||||
|
||||
public Integer getCaseId()
|
||||
{
|
||||
return caseId;
|
||||
}
|
||||
public void setUserId(Integer userId)
|
||||
{
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Integer getUserId()
|
||||
{
|
||||
return userId;
|
||||
}
|
||||
public void setDebugIsend(Integer debugIsend)
|
||||
{
|
||||
this.debugIsend = debugIsend;
|
||||
}
|
||||
|
||||
public Integer getDebugIsend()
|
||||
{
|
||||
return debugIsend;
|
||||
}
|
||||
public void setLogLevel(String logLevel)
|
||||
{
|
||||
this.logLevel = logLevel;
|
||||
}
|
||||
|
||||
public String getLogLevel()
|
||||
{
|
||||
return logLevel;
|
||||
}
|
||||
public void setLogDetail(String logDetail)
|
||||
{
|
||||
this.logDetail = logDetail;
|
||||
}
|
||||
|
||||
public String getLogDetail()
|
||||
{
|
||||
return logDetail;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("debugId", getDebugId())
|
||||
.append("caseId", getCaseId())
|
||||
.append("userId", getUserId())
|
||||
.append("debugIsend", getDebugIsend())
|
||||
.append("logLevel", getLogLevel())
|
||||
.append("logDetail", getLogDetail())
|
||||
.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
package luckyclient.serverapi.entity;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* 用例模块实体
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改 有任何疑问欢迎联系作者讨论。 QQ:1573584944 Seagull
|
||||
* =================================================================
|
||||
* @author Seagull
|
||||
* @date 2019年4月13日
|
||||
*/
|
||||
public class ProjectCaseModule extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 模块ID */
|
||||
private Integer moduleId;
|
||||
/** 模块名字 */
|
||||
private String moduleName;
|
||||
/** 项目ID */
|
||||
private Integer projectId;
|
||||
/** 父模块id */
|
||||
private Integer parentId;
|
||||
/** 祖模块列表 */
|
||||
private String ancestors;
|
||||
/** 显示顺序 */
|
||||
private Integer orderNum;
|
||||
/** 所属项目名称 */
|
||||
private String projectName;
|
||||
|
||||
public void setModuleId(Integer moduleId)
|
||||
{
|
||||
this.moduleId = moduleId;
|
||||
}
|
||||
|
||||
public Integer getModuleId()
|
||||
{
|
||||
return moduleId;
|
||||
}
|
||||
public void setModuleName(String moduleName)
|
||||
{
|
||||
this.moduleName = moduleName;
|
||||
}
|
||||
|
||||
public String getModuleName()
|
||||
{
|
||||
return moduleName;
|
||||
}
|
||||
public void setProjectId(Integer projectId)
|
||||
{
|
||||
this.projectId = projectId;
|
||||
}
|
||||
|
||||
public Integer getProjectId()
|
||||
{
|
||||
return projectId;
|
||||
}
|
||||
public void setParentId(Integer parentId)
|
||||
{
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public Integer getParentId()
|
||||
{
|
||||
return parentId;
|
||||
}
|
||||
public void setAncestors(String ancestors)
|
||||
{
|
||||
this.ancestors = ancestors;
|
||||
}
|
||||
|
||||
public String getAncestors()
|
||||
{
|
||||
return ancestors;
|
||||
}
|
||||
public void setOrderNum(Integer orderNum)
|
||||
{
|
||||
this.orderNum = orderNum;
|
||||
}
|
||||
|
||||
public Integer getOrderNum()
|
||||
{
|
||||
return orderNum;
|
||||
}
|
||||
|
||||
public String getProjectName() {
|
||||
return projectName;
|
||||
}
|
||||
|
||||
public void setProjectName(String projectName) {
|
||||
this.projectName = projectName;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("moduleId", getModuleId())
|
||||
.append("moduleName", getModuleName())
|
||||
.append("projectId", getProjectId())
|
||||
.append("parentId", getParentId())
|
||||
.append("ancestors", getAncestors())
|
||||
.append("orderNum", getOrderNum())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.append("projectName", getProjectName())
|
||||
.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,145 @@
|
|||
package luckyclient.serverapi.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* 公共参数实体
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改 有任何疑问欢迎联系作者讨论。 QQ:1573584944 Seagull
|
||||
* =================================================================
|
||||
* @author Seagull
|
||||
* @date 2019年4月13日
|
||||
*/
|
||||
public class ProjectCaseParams extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 用例参数ID */
|
||||
private Integer paramsId;
|
||||
/** 参数名称 */
|
||||
private String paramsName;
|
||||
/** 参数值 */
|
||||
private String paramsValue;
|
||||
/** 项目ID */
|
||||
private Integer projectId;
|
||||
/** 创建者 */
|
||||
private String createBy;
|
||||
/** 创建时间 */
|
||||
private Date createTime;
|
||||
/** 更新者 */
|
||||
private String updateBy;
|
||||
/** 更新时间 */
|
||||
private Date updateTime;
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
/** 关联项目实体 */
|
||||
private Project project;
|
||||
|
||||
public Project getProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
public void setProject(Project project) {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
public void setParamsId(Integer paramsId)
|
||||
{
|
||||
this.paramsId = paramsId;
|
||||
}
|
||||
|
||||
public Integer getParamsId()
|
||||
{
|
||||
return paramsId;
|
||||
}
|
||||
public void setParamsName(String paramsName)
|
||||
{
|
||||
this.paramsName = paramsName;
|
||||
}
|
||||
|
||||
public String getParamsName()
|
||||
{
|
||||
return paramsName;
|
||||
}
|
||||
public void setParamsValue(String paramsValue)
|
||||
{
|
||||
this.paramsValue = paramsValue;
|
||||
}
|
||||
|
||||
public String getParamsValue()
|
||||
{
|
||||
return paramsValue;
|
||||
}
|
||||
public void setProjectId(Integer projectId)
|
||||
{
|
||||
this.projectId = projectId;
|
||||
}
|
||||
|
||||
public Integer getProjectId()
|
||||
{
|
||||
return projectId;
|
||||
}
|
||||
public void setCreateBy(String createBy)
|
||||
{
|
||||
this.createBy = createBy;
|
||||
}
|
||||
|
||||
public String getCreateBy()
|
||||
{
|
||||
return createBy;
|
||||
}
|
||||
public void setCreateTime(Date createTime)
|
||||
{
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Date getCreateTime()
|
||||
{
|
||||
return createTime;
|
||||
}
|
||||
public void setUpdateBy(String updateBy)
|
||||
{
|
||||
this.updateBy = updateBy;
|
||||
}
|
||||
|
||||
public String getUpdateBy()
|
||||
{
|
||||
return updateBy;
|
||||
}
|
||||
public void setUpdateTime(Date updateTime)
|
||||
{
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public Date getUpdateTime()
|
||||
{
|
||||
return updateTime;
|
||||
}
|
||||
public void setRemark(String remark)
|
||||
{
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public String getRemark()
|
||||
{
|
||||
return remark;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("paramsId", getParamsId())
|
||||
.append("paramsName", getParamsName())
|
||||
.append("paramsValue", getParamsValue())
|
||||
.append("projectId", getProjectId())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,161 @@
|
|||
package luckyclient.serverapi.entity;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* 测试用例步骤实体
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改 有任何疑问欢迎联系作者讨论。 QQ:1573584944 Seagull
|
||||
* =================================================================
|
||||
* @author Seagull
|
||||
* @date 2019年4月13日
|
||||
*/
|
||||
public class ProjectCaseSteps extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 步骤ID */
|
||||
private Integer stepId;
|
||||
/** 用例ID */
|
||||
private Integer caseId;
|
||||
/** 项目ID */
|
||||
private Integer projectId;
|
||||
/** 步骤序号 */
|
||||
private Integer stepSerialNumber;
|
||||
/** 包路径|定位路径 */
|
||||
private String stepPath;
|
||||
/** 方法名|操作 */
|
||||
private String stepOperation;
|
||||
/** 参数 */
|
||||
private String stepParameters;
|
||||
/** 步骤动作 */
|
||||
private String action;
|
||||
/** 预期结果 */
|
||||
private String expectedResult;
|
||||
/** 0 API接口 1 Web UI 2 HTTP接口 3移动端 */
|
||||
private Integer stepType;
|
||||
/** 扩展字段,可用于备注、存储HTTP模板等 */
|
||||
private String extend;
|
||||
|
||||
public void setStepId(Integer stepId)
|
||||
{
|
||||
this.stepId = stepId;
|
||||
}
|
||||
|
||||
public Integer getStepId()
|
||||
{
|
||||
return stepId;
|
||||
}
|
||||
public void setCaseId(Integer caseId)
|
||||
{
|
||||
this.caseId = caseId;
|
||||
}
|
||||
|
||||
public Integer getCaseId()
|
||||
{
|
||||
return caseId;
|
||||
}
|
||||
public void setProjectId(Integer projectId)
|
||||
{
|
||||
this.projectId = projectId;
|
||||
}
|
||||
|
||||
public Integer getProjectId()
|
||||
{
|
||||
return projectId;
|
||||
}
|
||||
public void setStepSerialNumber(Integer stepSerialNumber)
|
||||
{
|
||||
this.stepSerialNumber = stepSerialNumber;
|
||||
}
|
||||
|
||||
public Integer getStepSerialNumber()
|
||||
{
|
||||
return stepSerialNumber;
|
||||
}
|
||||
public void setStepPath(String stepPath)
|
||||
{
|
||||
this.stepPath = stepPath;
|
||||
}
|
||||
|
||||
public String getStepPath()
|
||||
{
|
||||
return stepPath;
|
||||
}
|
||||
public void setStepOperation(String stepOperation)
|
||||
{
|
||||
this.stepOperation = stepOperation;
|
||||
}
|
||||
|
||||
public String getStepOperation()
|
||||
{
|
||||
return stepOperation;
|
||||
}
|
||||
public void setStepParameters(String stepParameters)
|
||||
{
|
||||
this.stepParameters = stepParameters;
|
||||
}
|
||||
|
||||
public String getStepParameters()
|
||||
{
|
||||
return stepParameters;
|
||||
}
|
||||
public void setAction(String action)
|
||||
{
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public String getAction()
|
||||
{
|
||||
return action;
|
||||
}
|
||||
public void setExpectedResult(String expectedResult)
|
||||
{
|
||||
this.expectedResult = expectedResult;
|
||||
}
|
||||
|
||||
public String getExpectedResult()
|
||||
{
|
||||
return expectedResult;
|
||||
}
|
||||
public void setStepType(Integer stepType)
|
||||
{
|
||||
this.stepType = stepType;
|
||||
}
|
||||
|
||||
public Integer getStepType()
|
||||
{
|
||||
return stepType;
|
||||
}
|
||||
public void setExtend(String extend)
|
||||
{
|
||||
this.extend = extend;
|
||||
}
|
||||
|
||||
public String getExtend()
|
||||
{
|
||||
return extend;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("stepId", getStepId())
|
||||
.append("caseId", getCaseId())
|
||||
.append("projectId", getProjectId())
|
||||
.append("stepSerialNumber", getStepSerialNumber())
|
||||
.append("stepPath", getStepPath())
|
||||
.append("stepOperation", getStepOperation())
|
||||
.append("stepParameters", getStepParameters())
|
||||
.append("action", getAction())
|
||||
.append("expectedResult", getExpectedResult())
|
||||
.append("stepType", getStepType())
|
||||
.append("extend", getExtend())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,147 @@
|
|||
package luckyclient.serverapi.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.apache.tools.ant.Project;
|
||||
|
||||
/**
|
||||
* 测试计划实体
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改 有任何疑问欢迎联系作者讨论。 QQ:1573584944 Seagull
|
||||
* =================================================================
|
||||
* @author Seagull
|
||||
* @date 2019年4月13日
|
||||
*/
|
||||
public class ProjectPlan extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 测试计划ID */
|
||||
private Integer planId;
|
||||
/** 测试计划名称 */
|
||||
private String planName;
|
||||
/** 计划中用例总数 */
|
||||
private Integer planCaseCount;
|
||||
/** 项目ID */
|
||||
private Integer projectId;
|
||||
/** 创建者 */
|
||||
private String createBy;
|
||||
/** 创建时间 */
|
||||
private Date createTime;
|
||||
/** 更新者 */
|
||||
private String updateBy;
|
||||
/** 更新时间 */
|
||||
private Date updateTime;
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
/** 关联项目实体 */
|
||||
private Project project;
|
||||
|
||||
public Project getProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
public void setProject(Project project) {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
public void setPlanId(Integer planId)
|
||||
{
|
||||
this.planId = planId;
|
||||
}
|
||||
|
||||
public Integer getPlanId()
|
||||
{
|
||||
return planId;
|
||||
}
|
||||
public void setPlanName(String planName)
|
||||
{
|
||||
this.planName = planName;
|
||||
}
|
||||
|
||||
public String getPlanName()
|
||||
{
|
||||
return planName;
|
||||
}
|
||||
public void setPlanCaseCount(Integer planCaseCount)
|
||||
{
|
||||
this.planCaseCount = planCaseCount;
|
||||
}
|
||||
|
||||
public Integer getPlanCaseCount()
|
||||
{
|
||||
return planCaseCount;
|
||||
}
|
||||
public void setProjectId(Integer projectId)
|
||||
{
|
||||
this.projectId = projectId;
|
||||
}
|
||||
|
||||
public Integer getProjectId()
|
||||
{
|
||||
return projectId;
|
||||
}
|
||||
public void setCreateBy(String createBy)
|
||||
{
|
||||
this.createBy = createBy;
|
||||
}
|
||||
|
||||
public String getCreateBy()
|
||||
{
|
||||
return createBy;
|
||||
}
|
||||
public void setCreateTime(Date createTime)
|
||||
{
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Date getCreateTime()
|
||||
{
|
||||
return createTime;
|
||||
}
|
||||
public void setUpdateBy(String updateBy)
|
||||
{
|
||||
this.updateBy = updateBy;
|
||||
}
|
||||
|
||||
public String getUpdateBy()
|
||||
{
|
||||
return updateBy;
|
||||
}
|
||||
public void setUpdateTime(Date updateTime)
|
||||
{
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public Date getUpdateTime()
|
||||
{
|
||||
return updateTime;
|
||||
}
|
||||
public void setRemark(String remark)
|
||||
{
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public String getRemark()
|
||||
{
|
||||
return remark;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("planId", getPlanId())
|
||||
.append("planName", getPlanName())
|
||||
.append("planCaseCount", getPlanCaseCount())
|
||||
.append("projectId", getProjectId())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.append("project", getProject())
|
||||
.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package luckyclient.serverapi.entity;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* 测试计划用例实体
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改 有任何疑问欢迎联系作者讨论。 QQ:1573584944 Seagull
|
||||
* =================================================================
|
||||
* @author Seagull
|
||||
* @date 2019年4月13日
|
||||
*/
|
||||
public class ProjectPlanCase extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 计划用例ID */
|
||||
private Integer planCaseId;
|
||||
/** 用例ID */
|
||||
private Integer caseId;
|
||||
/** 测试计划ID */
|
||||
private Integer planId;
|
||||
/** 用例优先级 数字越小,优先级越高 */
|
||||
private Integer priority;
|
||||
|
||||
public void setPlanCaseId(Integer planCaseId)
|
||||
{
|
||||
this.planCaseId = planCaseId;
|
||||
}
|
||||
|
||||
public Integer getPlanCaseId()
|
||||
{
|
||||
return planCaseId;
|
||||
}
|
||||
public void setCaseId(Integer caseId)
|
||||
{
|
||||
this.caseId = caseId;
|
||||
}
|
||||
|
||||
public Integer getCaseId()
|
||||
{
|
||||
return caseId;
|
||||
}
|
||||
public void setPlanId(Integer planId)
|
||||
{
|
||||
this.planId = planId;
|
||||
}
|
||||
|
||||
public Integer getPlanId()
|
||||
{
|
||||
return planId;
|
||||
}
|
||||
public void setPriority(Integer priority)
|
||||
{
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
public Integer getPriority()
|
||||
{
|
||||
return priority;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("planCaseId", getPlanCaseId())
|
||||
.append("caseId", getCaseId())
|
||||
.append("planId", getPlanId())
|
||||
.append("priority", getPriority())
|
||||
.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,149 @@
|
|||
package luckyclient.serverapi.entity;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* 协议模板实体
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改 有任何疑问欢迎联系作者讨论。 QQ:1573584944 Seagull
|
||||
* =================================================================
|
||||
* @author Seagull
|
||||
* @date 2019年4月13日
|
||||
*/
|
||||
public class ProjectProtocolTemplate extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 模板ID */
|
||||
private Integer templateId;
|
||||
/** 模板名称 */
|
||||
private String templateName;
|
||||
/** 项目ID */
|
||||
private Integer projectId;
|
||||
/** 消息头 */
|
||||
private String headMsg;
|
||||
/** 客户端中的证书路径 */
|
||||
private String cerificatePath;
|
||||
/** 编码格式 */
|
||||
private String encoding;
|
||||
/** 超时时间 */
|
||||
private Integer timeout;
|
||||
/** 请求响应返回值是否带头域信息 0不带 1带 */
|
||||
private Integer isResponseHead;
|
||||
/** 请求响应返回值是否带状态码 0不带 1带 */
|
||||
private Integer isResponseCode;
|
||||
/** 关联项目实体 */
|
||||
private Project project;
|
||||
|
||||
public Project getProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
public void setProject(Project project) {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
public void setTemplateId(Integer templateId)
|
||||
{
|
||||
this.templateId = templateId;
|
||||
}
|
||||
|
||||
public Integer getTemplateId()
|
||||
{
|
||||
return templateId;
|
||||
}
|
||||
public void setTemplateName(String templateName)
|
||||
{
|
||||
this.templateName = templateName;
|
||||
}
|
||||
|
||||
public String getTemplateName()
|
||||
{
|
||||
return templateName;
|
||||
}
|
||||
public void setProjectId(Integer projectId)
|
||||
{
|
||||
this.projectId = projectId;
|
||||
}
|
||||
|
||||
public Integer getProjectId()
|
||||
{
|
||||
return projectId;
|
||||
}
|
||||
public void setHeadMsg(String headMsg)
|
||||
{
|
||||
this.headMsg = headMsg;
|
||||
}
|
||||
|
||||
public String getHeadMsg()
|
||||
{
|
||||
return headMsg;
|
||||
}
|
||||
public void setCerificatePath(String cerificatePath)
|
||||
{
|
||||
this.cerificatePath = cerificatePath;
|
||||
}
|
||||
|
||||
public String getCerificatePath()
|
||||
{
|
||||
return cerificatePath;
|
||||
}
|
||||
public void setEncoding(String encoding)
|
||||
{
|
||||
this.encoding = encoding;
|
||||
}
|
||||
|
||||
public String getEncoding()
|
||||
{
|
||||
return encoding;
|
||||
}
|
||||
public void setTimeout(Integer timeout)
|
||||
{
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
public Integer getTimeout()
|
||||
{
|
||||
return timeout;
|
||||
}
|
||||
public void setIsResponseHead(Integer isResponseHead)
|
||||
{
|
||||
this.isResponseHead = isResponseHead;
|
||||
}
|
||||
|
||||
public Integer getIsResponseHead()
|
||||
{
|
||||
return isResponseHead;
|
||||
}
|
||||
public void setIsResponseCode(Integer isResponseCode)
|
||||
{
|
||||
this.isResponseCode = isResponseCode;
|
||||
}
|
||||
|
||||
public Integer getIsResponseCode()
|
||||
{
|
||||
return isResponseCode;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("templateId", getTemplateId())
|
||||
.append("templateName", getTemplateName())
|
||||
.append("projectId", getProjectId())
|
||||
.append("headMsg", getHeadMsg())
|
||||
.append("cerificatePath", getCerificatePath())
|
||||
.append("encoding", getEncoding())
|
||||
.append("timeout", getTimeout())
|
||||
.append("isResponseHead", getIsResponseHead())
|
||||
.append("isResponseCode", getIsResponseCode())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.append("project", getProject())
|
||||
.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package luckyclient.serverapi.entity;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* 协议模板参数实体
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改 有任何疑问欢迎联系作者讨论。 QQ:1573584944 Seagull
|
||||
* =================================================================
|
||||
* @author Seagull
|
||||
* @date 2019年4月13日
|
||||
*/
|
||||
public class ProjectTemplateParams extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 模板参数ID */
|
||||
private Integer paramsId;
|
||||
/** 模板ID */
|
||||
private Integer templateId;
|
||||
/** 参数名 */
|
||||
private String paramName;
|
||||
/** 参数默认值 */
|
||||
private String paramValue;
|
||||
/** 0 String 1 JSON对象 2 JSONARR对象 3 文件类型 */
|
||||
private Integer paramType;
|
||||
|
||||
public void setParamsId(Integer paramsId)
|
||||
{
|
||||
this.paramsId = paramsId;
|
||||
}
|
||||
|
||||
public Integer getParamsId()
|
||||
{
|
||||
return paramsId;
|
||||
}
|
||||
public void setTemplateId(Integer templateId)
|
||||
{
|
||||
this.templateId = templateId;
|
||||
}
|
||||
|
||||
public Integer getTemplateId()
|
||||
{
|
||||
return templateId;
|
||||
}
|
||||
public void setParamName(String paramName)
|
||||
{
|
||||
this.paramName = paramName;
|
||||
}
|
||||
|
||||
public String getParamName()
|
||||
{
|
||||
return paramName;
|
||||
}
|
||||
public void setParamValue(String paramValue)
|
||||
{
|
||||
this.paramValue = paramValue;
|
||||
}
|
||||
|
||||
public String getParamValue()
|
||||
{
|
||||
return paramValue;
|
||||
}
|
||||
public void setParamType(Integer paramType)
|
||||
{
|
||||
this.paramType = paramType;
|
||||
}
|
||||
|
||||
public Integer getParamType()
|
||||
{
|
||||
return paramType;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("paramsId", getParamsId())
|
||||
.append("templateId", getTemplateId())
|
||||
.append("paramName", getParamName())
|
||||
.append("paramValue", getParamValue())
|
||||
.append("paramType", getParamType())
|
||||
.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,166 @@
|
|||
package luckyclient.serverapi.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* 任务用例执行记录表 task_case_execute
|
||||
*
|
||||
* @author luckyframe
|
||||
* @date 2019-04-08
|
||||
*/
|
||||
public class TaskCaseExecute extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 用例执行ID */
|
||||
private Integer taskCaseId;
|
||||
/** 任务ID */
|
||||
private Integer taskId;
|
||||
/** 项目ID */
|
||||
private Integer projectId;
|
||||
/** 用例ID */
|
||||
private Integer caseId;
|
||||
/** 用例标识 */
|
||||
private String caseSign;
|
||||
/** 用例名称 */
|
||||
private String caseName;
|
||||
/** 0通过 1失败 2锁定 3执行中 4未执行 */
|
||||
private Integer caseStatus;
|
||||
/** 用例结束时间 */
|
||||
private Date finishTime;
|
||||
/** 创建者 */
|
||||
private String createBy;
|
||||
/** 创建时间 */
|
||||
private Date createTime;
|
||||
/** 更新者 */
|
||||
private String updateBy;
|
||||
/** 更新时间 */
|
||||
private Date updateTime;
|
||||
|
||||
public Integer getCaseId() {
|
||||
return caseId;
|
||||
}
|
||||
|
||||
public void setCaseId(Integer caseId) {
|
||||
this.caseId = caseId;
|
||||
}
|
||||
|
||||
public void setTaskCaseId(Integer taskCaseId)
|
||||
{
|
||||
this.taskCaseId = taskCaseId;
|
||||
}
|
||||
|
||||
public Integer getTaskCaseId()
|
||||
{
|
||||
return taskCaseId;
|
||||
}
|
||||
public void setTaskId(Integer taskId)
|
||||
{
|
||||
this.taskId = taskId;
|
||||
}
|
||||
|
||||
public Integer getTaskId()
|
||||
{
|
||||
return taskId;
|
||||
}
|
||||
public void setProjectId(Integer projectId)
|
||||
{
|
||||
this.projectId = projectId;
|
||||
}
|
||||
|
||||
public Integer getProjectId()
|
||||
{
|
||||
return projectId;
|
||||
}
|
||||
public void setCaseSign(String caseSign)
|
||||
{
|
||||
this.caseSign = caseSign;
|
||||
}
|
||||
|
||||
public String getCaseSign()
|
||||
{
|
||||
return caseSign;
|
||||
}
|
||||
public void setCaseName(String caseName)
|
||||
{
|
||||
this.caseName = caseName;
|
||||
}
|
||||
|
||||
public String getCaseName()
|
||||
{
|
||||
return caseName;
|
||||
}
|
||||
public void setCaseStatus(Integer caseStatus)
|
||||
{
|
||||
this.caseStatus = caseStatus;
|
||||
}
|
||||
|
||||
public Integer getCaseStatus()
|
||||
{
|
||||
return caseStatus;
|
||||
}
|
||||
public void setFinishTime(Date finishTime)
|
||||
{
|
||||
this.finishTime = finishTime;
|
||||
}
|
||||
|
||||
public Date getFinishTime()
|
||||
{
|
||||
return finishTime;
|
||||
}
|
||||
public void setCreateBy(String createBy)
|
||||
{
|
||||
this.createBy = createBy;
|
||||
}
|
||||
|
||||
public String getCreateBy()
|
||||
{
|
||||
return createBy;
|
||||
}
|
||||
public void setCreateTime(Date createTime)
|
||||
{
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Date getCreateTime()
|
||||
{
|
||||
return createTime;
|
||||
}
|
||||
public void setUpdateBy(String updateBy)
|
||||
{
|
||||
this.updateBy = updateBy;
|
||||
}
|
||||
|
||||
public String getUpdateBy()
|
||||
{
|
||||
return updateBy;
|
||||
}
|
||||
public void setUpdateTime(Date updateTime)
|
||||
{
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public Date getUpdateTime()
|
||||
{
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("taskCaseId", getTaskCaseId())
|
||||
.append("taskId", getTaskId())
|
||||
.append("projectId", getProjectId())
|
||||
.append("caseSign", getCaseSign())
|
||||
.append("caseName", getCaseName())
|
||||
.append("caseStatus", getCaseStatus())
|
||||
.append("finishTime", getFinishTime())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,130 @@
|
|||
package luckyclient.serverapi.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* 用例日志明细表 task_case_log
|
||||
*
|
||||
* @author luckyframe
|
||||
* @date 2019-04-08
|
||||
*/
|
||||
public class TaskCaseLog extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 用例执行ID */
|
||||
private Integer logId;
|
||||
/** 用例ID */
|
||||
private Integer caseId;
|
||||
/** 用例执行ID */
|
||||
private Integer taskCaseId;
|
||||
/** 任务ID */
|
||||
private Integer taskId;
|
||||
/** 日志明细 */
|
||||
private String logDetail;
|
||||
/** 日志级别 */
|
||||
private String logGrade;
|
||||
/** 日志用例步骤 */
|
||||
private String logStep;
|
||||
/** UI自动化自动截图地址 */
|
||||
private String imgname;
|
||||
/** 创建时间 */
|
||||
private Date createTime;
|
||||
|
||||
public Integer getCaseId() {
|
||||
return caseId;
|
||||
}
|
||||
|
||||
public void setCaseId(Integer caseId) {
|
||||
this.caseId = caseId;
|
||||
}
|
||||
|
||||
public void setLogId(Integer logId)
|
||||
{
|
||||
this.logId = logId;
|
||||
}
|
||||
|
||||
public Integer getLogId()
|
||||
{
|
||||
return logId;
|
||||
}
|
||||
public void setTaskCaseId(Integer taskCaseId)
|
||||
{
|
||||
this.taskCaseId = taskCaseId;
|
||||
}
|
||||
|
||||
public Integer getTaskCaseId()
|
||||
{
|
||||
return taskCaseId;
|
||||
}
|
||||
public void setTaskId(Integer taskId)
|
||||
{
|
||||
this.taskId = taskId;
|
||||
}
|
||||
|
||||
public Integer getTaskId()
|
||||
{
|
||||
return taskId;
|
||||
}
|
||||
public void setLogDetail(String logDetail)
|
||||
{
|
||||
this.logDetail = logDetail;
|
||||
}
|
||||
|
||||
public String getLogDetail()
|
||||
{
|
||||
return logDetail;
|
||||
}
|
||||
public void setLogGrade(String logGrade)
|
||||
{
|
||||
this.logGrade = logGrade;
|
||||
}
|
||||
|
||||
public String getLogGrade()
|
||||
{
|
||||
return logGrade;
|
||||
}
|
||||
public void setLogStep(String logStep)
|
||||
{
|
||||
this.logStep = logStep;
|
||||
}
|
||||
|
||||
public String getLogStep()
|
||||
{
|
||||
return logStep;
|
||||
}
|
||||
public void setImgname(String imgname)
|
||||
{
|
||||
this.imgname = imgname;
|
||||
}
|
||||
|
||||
public String getImgname()
|
||||
{
|
||||
return imgname;
|
||||
}
|
||||
public void setCreateTime(Date createTime)
|
||||
{
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Date getCreateTime()
|
||||
{
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("logId", getLogId())
|
||||
.append("taskCaseId", getTaskCaseId())
|
||||
.append("taskId", getTaskId())
|
||||
.append("logDetail", getLogDetail())
|
||||
.append("logGrade", getLogGrade())
|
||||
.append("logStep", getLogStep())
|
||||
.append("imgname", getImgname())
|
||||
.append("createTime", getCreateTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,227 @@
|
|||
package luckyclient.serverapi.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* 任务执行实体
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改 有任何疑问欢迎联系作者讨论。 QQ:1573584944 Seagull
|
||||
* =================================================================
|
||||
* @author Seagull
|
||||
* @date 2019年4月13日
|
||||
*/
|
||||
public class TaskExecute extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 任务ID */
|
||||
private Integer taskId;
|
||||
/** 调度ID */
|
||||
private Integer schedulingId;
|
||||
/** 项目ID */
|
||||
private Integer projectId;
|
||||
/** 任务名称 */
|
||||
private String taskName;
|
||||
/** 状态 0未执行 1执行中 2 成功 4失败 5 唤起客户端失败 */
|
||||
private Integer taskStatus;
|
||||
/** 总用例数 */
|
||||
private Integer caseTotalCount;
|
||||
/** 成功数 */
|
||||
private Integer caseSuccCount;
|
||||
/** 失败数 */
|
||||
private Integer caseFailCount;
|
||||
/** 锁定数 */
|
||||
private Integer caseLockCount;
|
||||
/** 未执行用例 */
|
||||
private Integer caseNoexecCount;
|
||||
/** 任务结束时间 */
|
||||
private Date finishTime;
|
||||
/** 创建者 */
|
||||
private String createBy;
|
||||
/** 创建时间 */
|
||||
private Date createTime;
|
||||
/** 更新者 */
|
||||
private String updateBy;
|
||||
/** 更新时间 */
|
||||
private Date updateTime;
|
||||
/** 关联项目实体 */
|
||||
private Project project;
|
||||
/** 任务执行百分比 */
|
||||
private Integer taskProgress;
|
||||
|
||||
public Integer getTaskProgress() {
|
||||
return taskProgress;
|
||||
}
|
||||
|
||||
public void setTaskProgress(Integer taskProgress) {
|
||||
this.taskProgress = taskProgress;
|
||||
}
|
||||
|
||||
public Project getProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
public void setProject(Project project) {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
public void setTaskId(Integer taskId)
|
||||
{
|
||||
this.taskId = taskId;
|
||||
}
|
||||
|
||||
public Integer getTaskId()
|
||||
{
|
||||
return taskId;
|
||||
}
|
||||
public void setSchedulingId(Integer schedulingId)
|
||||
{
|
||||
this.schedulingId = schedulingId;
|
||||
}
|
||||
|
||||
public Integer getSchedulingId()
|
||||
{
|
||||
return schedulingId;
|
||||
}
|
||||
public void setProjectId(Integer projectId)
|
||||
{
|
||||
this.projectId = projectId;
|
||||
}
|
||||
|
||||
public Integer getProjectId()
|
||||
{
|
||||
return projectId;
|
||||
}
|
||||
public void setTaskName(String taskName)
|
||||
{
|
||||
this.taskName = taskName;
|
||||
}
|
||||
|
||||
public String getTaskName()
|
||||
{
|
||||
return taskName;
|
||||
}
|
||||
public void setTaskStatus(Integer taskStatus)
|
||||
{
|
||||
this.taskStatus = taskStatus;
|
||||
}
|
||||
|
||||
public Integer getTaskStatus()
|
||||
{
|
||||
return taskStatus;
|
||||
}
|
||||
public void setCaseTotalCount(Integer caseTotalCount)
|
||||
{
|
||||
this.caseTotalCount = caseTotalCount;
|
||||
}
|
||||
|
||||
public Integer getCaseTotalCount()
|
||||
{
|
||||
return caseTotalCount;
|
||||
}
|
||||
public void setCaseSuccCount(Integer caseSuccCount)
|
||||
{
|
||||
this.caseSuccCount = caseSuccCount;
|
||||
}
|
||||
|
||||
public Integer getCaseSuccCount()
|
||||
{
|
||||
return caseSuccCount;
|
||||
}
|
||||
public void setCaseFailCount(Integer caseFailCount)
|
||||
{
|
||||
this.caseFailCount = caseFailCount;
|
||||
}
|
||||
|
||||
public Integer getCaseFailCount()
|
||||
{
|
||||
return caseFailCount;
|
||||
}
|
||||
public void setCaseLockCount(Integer caseLockCount)
|
||||
{
|
||||
this.caseLockCount = caseLockCount;
|
||||
}
|
||||
|
||||
public Integer getCaseLockCount()
|
||||
{
|
||||
return caseLockCount;
|
||||
}
|
||||
public void setCaseNoexecCount(Integer caseNoexecCount)
|
||||
{
|
||||
this.caseNoexecCount = caseNoexecCount;
|
||||
}
|
||||
|
||||
public Integer getCaseNoexecCount()
|
||||
{
|
||||
return caseNoexecCount;
|
||||
}
|
||||
public void setFinishTime(Date finishTime)
|
||||
{
|
||||
this.finishTime = finishTime;
|
||||
}
|
||||
|
||||
public Date getFinishTime()
|
||||
{
|
||||
return finishTime;
|
||||
}
|
||||
public void setCreateBy(String createBy)
|
||||
{
|
||||
this.createBy = createBy;
|
||||
}
|
||||
|
||||
public String getCreateBy()
|
||||
{
|
||||
return createBy;
|
||||
}
|
||||
public void setCreateTime(Date createTime)
|
||||
{
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Date getCreateTime()
|
||||
{
|
||||
return createTime;
|
||||
}
|
||||
public void setUpdateBy(String updateBy)
|
||||
{
|
||||
this.updateBy = updateBy;
|
||||
}
|
||||
|
||||
public String getUpdateBy()
|
||||
{
|
||||
return updateBy;
|
||||
}
|
||||
public void setUpdateTime(Date updateTime)
|
||||
{
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public Date getUpdateTime()
|
||||
{
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("taskId", getTaskId())
|
||||
.append("schedulingId", getSchedulingId())
|
||||
.append("projectId", getProjectId())
|
||||
.append("taskName", getTaskName())
|
||||
.append("taskStatus", getTaskStatus())
|
||||
.append("caseTotalCount", getCaseTotalCount())
|
||||
.append("caseSuccCount", getCaseSuccCount())
|
||||
.append("caseFailCount", getCaseFailCount())
|
||||
.append("caseLockCount", getCaseLockCount())
|
||||
.append("caseNoexecCount", getCaseNoexecCount())
|
||||
.append("finishTime", getFinishTime())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,263 @@
|
|||
package luckyclient.serverapi.entity;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* 任务调度实体
|
||||
* =================================================================
|
||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改 有任何疑问欢迎联系作者讨论。 QQ:1573584944 Seagull
|
||||
* =================================================================
|
||||
* @author Seagull
|
||||
* @date 2019年4月13日
|
||||
*/
|
||||
public class TaskScheduling extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 预约调度ID */
|
||||
private Integer schedulingId;
|
||||
/** 预约调度名称 */
|
||||
private String schedulingName;
|
||||
/** 任务ID */
|
||||
private Integer jobId;
|
||||
/** 项目ID */
|
||||
private Integer projectId;
|
||||
/** 测试计划ID */
|
||||
private Integer planId;
|
||||
/** 客户端ID */
|
||||
private Integer clientId;
|
||||
/** 邮件通知地址 */
|
||||
private String emailAddress;
|
||||
/** 发送邮件通知时的具体逻辑, 0-全部,1-成功,-1-失败 */
|
||||
private Integer emailSendCondition;
|
||||
/** jenkins构建链接 */
|
||||
private String buildingLink;
|
||||
/** 远程执行Shell脚本 */
|
||||
private String remoteShell;
|
||||
/** 客户端执行线程数 */
|
||||
private Integer exThreadCount;
|
||||
/** 任务类型 0 接口 1 Web UI 2 移动 */
|
||||
private Integer taskType;
|
||||
/** UI自动化浏览器类型 0 IE 1 火狐 2 谷歌 3 Edge */
|
||||
private Integer browserType;
|
||||
/** 任务超时时间(分钟) */
|
||||
private Integer taskTimeout;
|
||||
/** 客户端测试驱动桩路径 */
|
||||
private String clientDriverPath;
|
||||
/** 关联项目实体 */
|
||||
private Project project;
|
||||
/** 关联项目计划 */
|
||||
private ProjectPlan projectPlan;
|
||||
/** 任务名称 */
|
||||
private String jobName;
|
||||
/** cron执行表达式 */
|
||||
private String cronExpression;
|
||||
/** 任务状态(0正常 1暂停) */
|
||||
private String status;
|
||||
/** 任务备注 */
|
||||
private String remark;
|
||||
|
||||
public String getSchedulingName() {
|
||||
return schedulingName;
|
||||
}
|
||||
|
||||
public void setSchedulingName(String schedulingName) {
|
||||
this.schedulingName = schedulingName;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public String getJobName() {
|
||||
return jobName;
|
||||
}
|
||||
|
||||
public void setJobName(String jobName) {
|
||||
this.jobName = jobName;
|
||||
}
|
||||
|
||||
public String getCronExpression() {
|
||||
return cronExpression;
|
||||
}
|
||||
|
||||
public void setCronExpression(String cronExpression) {
|
||||
this.cronExpression = cronExpression;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String 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 getEmailAddress()
|
||||
{
|
||||
return emailAddress;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("schedulingId", getSchedulingId())
|
||||
.append("jobId", getJobId())
|
||||
.append("projectId", getProjectId())
|
||||
.append("planId", getPlanId())
|
||||
.append("clientId", getClientId())
|
||||
.append("emailAddress", getEmailAddress())
|
||||
.append("emailSendCondition", getEmailSendCondition())
|
||||
.append("buildingLink", getBuildingLink())
|
||||
.append("remoteShell", getRemoteShell())
|
||||
.append("exThreadCount", getExThreadCount())
|
||||
.append("taskType", getTaskType())
|
||||
.append("browserType", getBrowserType())
|
||||
.append("taskTimeout", getTaskTimeout())
|
||||
.append("clientDriverPath", getClientDriverPath())
|
||||
.toString();
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue