1:根据alibaba JAVA代码规范优化部分代码
2:增加公共参数功能 3:取消单个参数三次引用变量的限制,优化控制逻辑 4:增加包路径、方法名、参数、预期结果全路径引用参数,当遇到局部变量与全局变量同名时,优先使用局部变量 5:其他代码逻辑结构上的优化
This commit is contained in:
parent
b2297473df
commit
c02ce414ea
|
@ -10,7 +10,17 @@ import luckyclient.caserun.exwebdriver.extestlink.WebBatchExecuteTestLink;
|
||||||
import luckyclient.planapi.api.GetServerAPI;
|
import luckyclient.planapi.api.GetServerAPI;
|
||||||
import luckyclient.planapi.entity.TestTaskexcute;
|
import luckyclient.planapi.entity.TestTaskexcute;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class BatchCaseExecute extends TestControl{
|
public class BatchCaseExecute extends TestControl{
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
@ -23,15 +33,18 @@ public class BatchCaseExecute extends TestControl{
|
||||||
TestTaskexcute task=GetServerAPI.cgetTaskbyid(Integer.valueOf(taskid));
|
TestTaskexcute task=GetServerAPI.cgetTaskbyid(Integer.valueOf(taskid));
|
||||||
if(task.getTestJob().getExtype()==0){
|
if(task.getTestJob().getExtype()==0){
|
||||||
if(task.getTestJob().getProjecttype()==1){
|
if(task.getTestJob().getProjecttype()==1){
|
||||||
BatchTestLinkCaseExecution.BatchCaseExecuteForTast(task.getTestJob().getPlanproj(), String.valueOf(task.getId()), batchcase); //½Ó¿Ú²âÊÔ
|
//接口测试
|
||||||
|
BatchTestLinkCaseExecution.batchCaseExecuteForTast(task.getTestJob().getPlanproj(), String.valueOf(task.getId()), batchcase);
|
||||||
}else if(task.getTestJob().getProjecttype()==0){
|
}else if(task.getTestJob().getProjecttype()==0){
|
||||||
BatchTestCaseExecution.BatchCaseExecuteForTast(task.getTestJob().getPlanproj(), String.valueOf(task.getId()), batchcase);
|
BatchTestCaseExecution.batchCaseExecuteForTast(task.getTestJob().getPlanproj(), String.valueOf(task.getId()), batchcase);
|
||||||
}
|
}
|
||||||
}else if(task.getTestJob().getExtype()==1){
|
}else if(task.getTestJob().getExtype()==1){
|
||||||
if(task.getTestJob().getProjecttype()==1){
|
if(task.getTestJob().getProjecttype()==1){
|
||||||
WebBatchExecuteTestLink.BatchCaseExecuteForTast(task.getTestJob().getPlanproj(), String.valueOf(task.getId()), batchcase); //UI²âÊÔ
|
//UI测试
|
||||||
|
WebBatchExecuteTestLink.batchCaseExecuteForTast(task.getTestJob().getPlanproj(), String.valueOf(task.getId()), batchcase);
|
||||||
}else if(task.getTestJob().getProjecttype()==0){
|
}else if(task.getTestJob().getProjecttype()==0){
|
||||||
WebBatchExecute.BatchCaseExecuteForTast(task.getTestJob().getPlanproj(), String.valueOf(task.getId()), batchcase); //UI²âÊÔ
|
//UI测试
|
||||||
|
WebBatchExecute.batchCaseExecuteForTast(task.getTestJob().getPlanproj(), String.valueOf(task.getId()), batchcase);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,17 @@ import luckyclient.caserun.exwebdriver.extestlink.WebOneCaseExecuteTestLink;
|
||||||
import luckyclient.planapi.api.GetServerAPI;
|
import luckyclient.planapi.api.GetServerAPI;
|
||||||
import luckyclient.planapi.entity.TestTaskexcute;
|
import luckyclient.planapi.entity.TestTaskexcute;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class OneCaseExecute extends TestControl{
|
public class OneCaseExecute extends TestControl{
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
@ -23,16 +33,19 @@ public class OneCaseExecute extends TestControl{
|
||||||
TestTaskexcute task=GetServerAPI.cgetTaskbyid(Integer.valueOf(taskid));
|
TestTaskexcute task=GetServerAPI.cgetTaskbyid(Integer.valueOf(taskid));
|
||||||
if(task.getTestJob().getExtype()==0){
|
if(task.getTestJob().getExtype()==0){
|
||||||
if(task.getTestJob().getProjecttype()==1){
|
if(task.getTestJob().getProjecttype()==1){
|
||||||
TestLinkCaseExecution.OneCaseExecuteForTast(task.getTestJob().getPlanproj(), testCaseExternalId,version,String.valueOf(task.getId())); //testlink½Ó¿Ú²âÊÔ
|
//testlink接口测试
|
||||||
|
TestLinkCaseExecution.oneCaseExecuteForTast(task.getTestJob().getPlanproj(), testCaseExternalId,version,String.valueOf(task.getId()));
|
||||||
}else if(task.getTestJob().getProjecttype()==0){
|
}else if(task.getTestJob().getProjecttype()==0){
|
||||||
TestCaseExecution.OneCaseExecuteForTast(task.getTestJob().getPlanproj(), testCaseExternalId,version,String.valueOf(task.getId())); //½Ó¿Ú²âÊÔ
|
//接口测试
|
||||||
|
TestCaseExecution.oneCaseExecuteForTast(task.getTestJob().getPlanproj(), testCaseExternalId,version,String.valueOf(task.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}else if(task.getTestJob().getExtype()==1){
|
}else if(task.getTestJob().getExtype()==1){
|
||||||
if(task.getTestJob().getProjecttype()==1){
|
if(task.getTestJob().getProjecttype()==1){
|
||||||
WebOneCaseExecuteTestLink.OneCaseExecuteForTast(task.getTestJob().getPlanproj(), testCaseExternalId,version,String.valueOf(task.getId())); //UI²âÊÔ
|
//UI测试
|
||||||
|
WebOneCaseExecuteTestLink.oneCaseExecuteForTast(task.getTestJob().getPlanproj(), testCaseExternalId,version,String.valueOf(task.getId()));
|
||||||
}else if(task.getTestJob().getProjecttype()==0){
|
}else if(task.getTestJob().getProjecttype()==0){
|
||||||
WebOneCaseExecute.OneCaseExecuteForTast(task.getTestJob().getPlanproj(), testCaseExternalId,version,String.valueOf(task.getId())); //UI²âÊÔ
|
WebOneCaseExecute.oneCaseExecuteForTast(task.getTestJob().getPlanproj(), testCaseExternalId,version,String.valueOf(task.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,17 @@ import luckyclient.caserun.exwebdriver.WebTestControl;
|
||||||
import luckyclient.planapi.api.GetServerAPI;
|
import luckyclient.planapi.api.GetServerAPI;
|
||||||
import luckyclient.planapi.entity.TestTaskexcute;
|
import luckyclient.planapi.entity.TestTaskexcute;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class RunAutomationTest extends TestControl{
|
public class RunAutomationTest extends TestControl{
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
@ -16,10 +26,13 @@ public class RunAutomationTest extends TestControl{
|
||||||
+ "\\log4j.conf");
|
+ "\\log4j.conf");
|
||||||
String taskid = args[0];
|
String taskid = args[0];
|
||||||
TestTaskexcute task=GetServerAPI.cgetTaskbyid(Integer.valueOf(taskid));
|
TestTaskexcute task=GetServerAPI.cgetTaskbyid(Integer.valueOf(taskid));
|
||||||
|
|
||||||
if(task.getTestJob().getExtype()==0){
|
if(task.getTestJob().getExtype()==0){
|
||||||
TestControl.TastExecutionPlan(taskid, task); //½Ó¿Ú²âÊÔ
|
//接口测试
|
||||||
|
TestControl.taskExecutionPlan(taskid, task);
|
||||||
}else if(task.getTestJob().getExtype()==1){
|
}else if(task.getTestJob().getExtype()==1){
|
||||||
WebTestControl.TaskExecutionPlan(taskid, task); //UI²âÊÔ
|
//UI测试
|
||||||
|
WebTestControl.taskExecutionPlan(taskid, task);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -5,7 +5,17 @@ import org.apache.log4j.PropertyConfigurator;
|
||||||
import luckyclient.caserun.exinterface.TestControl;
|
import luckyclient.caserun.exinterface.TestControl;
|
||||||
import luckyclient.caserun.exinterface.WebTestCaseDebug;
|
import luckyclient.caserun.exinterface.WebTestCaseDebug;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class WebDebugExecute extends TestControl{
|
public class WebDebugExecute extends TestControl{
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
@ -14,6 +24,6 @@ public class WebDebugExecute extends TestControl{
|
||||||
+ "\\log4j.conf");
|
+ "\\log4j.conf");
|
||||||
String sign = args[0];
|
String sign = args[0];
|
||||||
String executor = args[1];
|
String executor = args[1];
|
||||||
WebTestCaseDebug.OneCaseDebug(sign,executor);
|
WebTestCaseDebug.oneCaseDebug(sign,executor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,16 @@
|
||||||
package luckyclient.caserun.exappium;
|
package luckyclient.caserun.exappium;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class AppiumForWebView {
|
public class AppiumForWebView {
|
||||||
/*
|
/*
|
||||||
public static void FindWebView(){
|
public static void FindWebView(){
|
||||||
|
|
|
@ -11,6 +11,17 @@ import org.openqa.selenium.OutputType;
|
||||||
import org.openqa.selenium.TakesScreenshot;
|
import org.openqa.selenium.TakesScreenshot;
|
||||||
import org.openqa.selenium.remote.Augmenter;
|
import org.openqa.selenium.remote.Augmenter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class BaseAppium {
|
public class BaseAppium {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,7 +29,7 @@ public class BaseAppium {
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* 手机报错截图
|
* 手机报错截图
|
||||||
*/
|
*/
|
||||||
public static void APPScreenShot(AppiumDriver driver,String workpath) throws IOException{
|
public static void aPPScreenShot(AppiumDriver driver,String workpath) throws IOException{
|
||||||
java.text.DateFormat timeformat = new java.text.SimpleDateFormat("MMdd-hhmmss");
|
java.text.DateFormat timeformat = new java.text.SimpleDateFormat("MMdd-hhmmss");
|
||||||
String time = timeformat.format(new Date())+".jpg";
|
String time = timeformat.format(new Date())+".jpg";
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -4,6 +4,17 @@ import io.appium.java_client.AppiumDriver;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class InputWord {
|
public class InputWord {
|
||||||
/**
|
/**
|
||||||
* @param args
|
* @param args
|
||||||
|
@ -11,7 +22,7 @@ public class InputWord {
|
||||||
* appium不支持中文输入 参考了robotium的以js方式为元素直接设置value的做法
|
* appium不支持中文输入 参考了robotium的以js方式为元素直接设置value的做法
|
||||||
* 利用Selenium中Webdriver执行js方法实现中文输入
|
* 利用Selenium中Webdriver执行js方法实现中文输入
|
||||||
*/
|
*/
|
||||||
public static void SendChinese(AppiumDriver appium,String preferences,String value){
|
public static void sendChinese(AppiumDriver appium,String preferences,String value){
|
||||||
org.openqa.selenium.JavascriptExecutor jse = (org.openqa.selenium.JavascriptExecutor) appium;
|
org.openqa.selenium.JavascriptExecutor jse = (org.openqa.selenium.JavascriptExecutor) appium;
|
||||||
jse.executeScript("document.getElementByName('"+preferences+"').value='"+value+"'");
|
jse.executeScript("document.getElementByName('"+preferences+"').value='"+value+"'");
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,21 +12,39 @@ import java.util.concurrent.TimeUnit;
|
||||||
import org.openqa.selenium.remote.CapabilityType;
|
import org.openqa.selenium.remote.CapabilityType;
|
||||||
import org.openqa.selenium.remote.DesiredCapabilities;
|
import org.openqa.selenium.remote.DesiredCapabilities;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class PublicAppium extends BaseAppium{
|
public class PublicAppium extends BaseAppium{
|
||||||
//³õʼ»¯¶ÔÏó
|
/**
|
||||||
|
* 初始化appium
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
public static AppiumDriver setUpAppium(String apkname,String version,String apppackage,String appactivity){
|
public static AppiumDriver setUpAppium(String apkname,String version,String apppackage,String appactivity){
|
||||||
AppiumDriver appium = null;
|
AppiumDriver appium = null;
|
||||||
File app=new File(System.getProperty("user.dir")+"//"+apkname); //"MobilePayment.apk"
|
//"MobilePayment.apk"
|
||||||
|
File app=new File(System.getProperty("user.dir")+"//"+apkname);
|
||||||
DesiredCapabilities capabilities = new DesiredCapabilities();
|
DesiredCapabilities capabilities = new DesiredCapabilities();
|
||||||
capabilities.setCapability("deviceName","Android");
|
capabilities.setCapability("deviceName","Android");
|
||||||
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
|
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
|
||||||
capabilities.setCapability(CapabilityType.VERSION, version); //"4.2.2"
|
//"4.2.2"
|
||||||
|
capabilities.setCapability(CapabilityType.VERSION, version);
|
||||||
capabilities.setCapability(CapabilityType.PLATFORM, "Android");
|
capabilities.setCapability(CapabilityType.PLATFORM, "Android");
|
||||||
capabilities.setCapability("unicodeKeyboard", "True");
|
capabilities.setCapability("unicodeKeyboard", "True");
|
||||||
capabilities.setCapability("resetKeyboard", "True");
|
capabilities.setCapability("resetKeyboard", "True");
|
||||||
capabilities.setCapability("app", app.getAbsolutePath());
|
capabilities.setCapability("app", app.getAbsolutePath());
|
||||||
capabilities.setCapability("app-package", apppackage); //"com.ysepay.mobileportal.activity"
|
//"com.ysepay.mobileportal.activity"
|
||||||
capabilities.setCapability("app-activity", appactivity); //"com.ysepay.mobileportal.IndexActivity"
|
capabilities.setCapability("app-package", apppackage);
|
||||||
|
//"com.ysepay.mobileportal.IndexActivity"
|
||||||
|
capabilities.setCapability("app-activity", appactivity);
|
||||||
try {
|
try {
|
||||||
appium = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
|
appium = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
|
|
|
@ -7,13 +7,24 @@ import org.openqa.selenium.JavascriptExecutor;
|
||||||
import io.appium.java_client.AppiumDriver;
|
import io.appium.java_client.AppiumDriver;
|
||||||
import io.appium.java_client.TouchAction;
|
import io.appium.java_client.TouchAction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
class SwipeDriver {
|
class SwipeDriver {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param args
|
* @param args
|
||||||
* TouchAction 支持对触屏的部分操作
|
* TouchAction 支持对触屏的部分操作
|
||||||
*/
|
*/
|
||||||
private static TouchAction SwipeTouchAction(AppiumDriver appium){
|
private static TouchAction swipeTouchAction(AppiumDriver appium){
|
||||||
TouchAction swipetouch = new TouchAction(appium);
|
TouchAction swipetouch = new TouchAction(appium);
|
||||||
return swipetouch;
|
return swipetouch;
|
||||||
}
|
}
|
||||||
|
@ -22,14 +33,14 @@ class SwipeDriver {
|
||||||
* @param args
|
* @param args
|
||||||
* js webview 支持4.1~4.4
|
* js webview 支持4.1~4.4
|
||||||
*/
|
*/
|
||||||
private static void webview_swipe(AppiumDriver appium, Double sX, Double sY,
|
private static void webViewSwipe(AppiumDriver appium, Double sX, Double sY,
|
||||||
Double eX, Double eY, Double duration) throws Exception {
|
Double eX, Double eY, Double duration) throws Exception {
|
||||||
JavascriptExecutor js;
|
JavascriptExecutor js;
|
||||||
HashMap<String, Double> swipeObject;
|
HashMap<String, Double> swipeObject;
|
||||||
try {
|
try {
|
||||||
// 滑动
|
// 滑动
|
||||||
js = (JavascriptExecutor) appium;
|
js = (JavascriptExecutor) appium;
|
||||||
swipeObject = new HashMap<String, Double>();
|
swipeObject = new HashMap<String, Double>(5);
|
||||||
swipeObject.put("startX", sX);
|
swipeObject.put("startX", sX);
|
||||||
swipeObject.put("startY", sY);
|
swipeObject.put("startY", sY);
|
||||||
swipeObject.put("endX", eX);
|
swipeObject.put("endX", eX);
|
||||||
|
@ -82,23 +93,23 @@ class SwipeDriver {
|
||||||
* @param args
|
* @param args
|
||||||
* 调用 ADB直接滑动 支持4.1~4.4
|
* 调用 ADB直接滑动 支持4.1~4.4
|
||||||
*/
|
*/
|
||||||
private static void adb_swipe(AppiumDriver appium, Double sX, Double sY,
|
private static void adbSwipe(AppiumDriver appium, Double sX, Double sY,
|
||||||
Double eX, Double eY) throws Exception {
|
Double eX, Double eY) throws Exception {
|
||||||
int X;
|
int xLine;
|
||||||
int Y;
|
int yLine;
|
||||||
int sX2;
|
int sX2;
|
||||||
int sY2;
|
int sY2;
|
||||||
int eX2;
|
int eX2;
|
||||||
int eY2;
|
int eY2;
|
||||||
try {
|
try {
|
||||||
// 滑动
|
// 滑动
|
||||||
X = appium.manage().window().getSize().getWidth();
|
xLine = appium.manage().window().getSize().getWidth();
|
||||||
Y = appium.manage().window().getSize().getHeight();
|
yLine = appium.manage().window().getSize().getHeight();
|
||||||
|
|
||||||
sX2 = (int) (X * sX);
|
sX2 = (int) (xLine * sX);
|
||||||
sY2 = (int) (Y * sY);
|
sY2 = (int) (yLine * sY);
|
||||||
eX2 = (int) (X * eX);
|
eX2 = (int) (xLine * eX);
|
||||||
eY2 = (int) (Y * eY);
|
eY2 = (int) (yLine * eY);
|
||||||
// logger.info("滑动11111111");
|
// logger.info("滑动11111111");
|
||||||
Runtime.getRuntime().exec(
|
Runtime.getRuntime().exec(
|
||||||
"adb -s " + "Android" + " shell input swipe " + sX2 + " "
|
"adb -s " + "Android" + " shell input swipe " + sX2 + " "
|
||||||
|
@ -119,7 +130,7 @@ class SwipeDriver {
|
||||||
*/
|
*/
|
||||||
private static void clickScreen(AppiumDriver drivers,int x, int y, int duration) {
|
private static void clickScreen(AppiumDriver drivers,int x, int y, int duration) {
|
||||||
JavascriptExecutor js = (JavascriptExecutor) drivers;
|
JavascriptExecutor js = (JavascriptExecutor) drivers;
|
||||||
HashMap<String, Integer> tapObject = new HashMap<String, Integer>();
|
HashMap<String, Integer> tapObject = new HashMap<String, Integer>(3);
|
||||||
tapObject.put("x", x);
|
tapObject.put("x", x);
|
||||||
tapObject.put("y", y);
|
tapObject.put("y", y);
|
||||||
tapObject.put("duration", duration);
|
tapObject.put("duration", duration);
|
||||||
|
|
|
@ -5,17 +5,19 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import luckyclient.caserun.exinterface.AnalyticSteps.InterfaceAnalyticCase;
|
import luckyclient.caserun.exinterface.analyticsteps.InterfaceAnalyticCase;
|
||||||
import luckyclient.planapi.api.GetServerAPI;
|
import luckyclient.planapi.api.GetServerAPI;
|
||||||
import luckyclient.planapi.entity.ProjectCase;
|
import luckyclient.planapi.entity.ProjectCase;
|
||||||
import luckyclient.planapi.entity.ProjectCasesteps;
|
import luckyclient.planapi.entity.ProjectCasesteps;
|
||||||
|
import luckyclient.planapi.entity.PublicCaseParams;
|
||||||
|
import luckyclient.publicclass.ChangString;
|
||||||
import luckyclient.publicclass.DBOperation;
|
import luckyclient.publicclass.DBOperation;
|
||||||
import luckyclient.publicclass.InvokeMethod;
|
import luckyclient.publicclass.InvokeMethod;
|
||||||
/**
|
/**
|
||||||
* =================================================================
|
* =================================================================
|
||||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
* 此测试框架主要采用testlink做分层框架,负责数据驱动以及用例管理部分,有任何疑问欢迎联系作者讨论。
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
* QQ:24163551 seagull1985
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
* =================================================================
|
* =================================================================
|
||||||
* @ClassName: TestCaseDebug
|
* @ClassName: TestCaseDebug
|
||||||
* @Description: 针对自动化用例在编写过程中,对用例脚本进行调试
|
* @Description: 针对自动化用例在编写过程中,对用例脚本进行调试
|
||||||
|
@ -31,7 +33,7 @@ public class ApiTestCaseDebug{
|
||||||
* @param 用例版本号
|
* @param 用例版本号
|
||||||
* 用于在testlink上配置好用例参数后,做单条用例调试
|
* 用于在testlink上配置好用例参数后,做单条用例调试
|
||||||
*/
|
*/
|
||||||
public static void OneCaseDebug(String projectname,String testCaseExternalId){
|
public static void oneCaseDebug(String projectname,String testCaseExternalId){
|
||||||
Map<String,String> variable = new HashMap<String,String>();
|
Map<String,String> variable = new HashMap<String,String>();
|
||||||
String packagename =null;
|
String packagename =null;
|
||||||
String functionname = null;
|
String functionname = null;
|
||||||
|
@ -41,129 +43,48 @@ public class ApiTestCaseDebug{
|
||||||
String testnote = null;
|
String testnote = null;
|
||||||
int k = 0;
|
int k = 0;
|
||||||
ProjectCase testcaseob = GetServerAPI.cgetCaseBysign(testCaseExternalId);
|
ProjectCase testcaseob = GetServerAPI.cgetCaseBysign(testCaseExternalId);
|
||||||
|
List<PublicCaseParams> pcplist=GetServerAPI.cgetParamsByProjectid(String.valueOf(testcaseob.getProjectid()));
|
||||||
|
// 把公共参数加入到MAP中
|
||||||
|
for (PublicCaseParams pcp : pcplist) {
|
||||||
|
variable.put(pcp.getParamsname(), pcp.getParamsvalue());
|
||||||
|
}
|
||||||
List<ProjectCasesteps> steps=GetServerAPI.getStepsbycaseid(testcaseob.getId());
|
List<ProjectCasesteps> steps=GetServerAPI.getStepsbycaseid(testcaseob.getId());
|
||||||
//进入循环,解析用例所有步骤
|
//进入循环,解析用例所有步骤
|
||||||
for(int i=0;i<steps.size();i++){
|
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(testcaseob, steps.get(i),"888888",null);
|
||||||
packagename = casescript.get("PackageName").toString();
|
try {
|
||||||
functionname = casescript.get("FunctionName").toString();
|
packagename = casescript.get("PackageName").toString();
|
||||||
|
packagename = ChangString.changparams(packagename, variable,"包路径");
|
||||||
|
functionname = casescript.get("FunctionName").toString();
|
||||||
|
functionname = ChangString.changparams(functionname, variable,"方法名");
|
||||||
|
} catch (Exception e) {
|
||||||
|
k = 0;
|
||||||
|
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcaseob.getSign() + "解析包名或是方法名失败,请检查!");
|
||||||
|
e.printStackTrace();
|
||||||
|
break; // 某一步骤失败后,此条用例置为失败退出
|
||||||
|
}
|
||||||
//用例名称解析出现异常或是单个步骤参数解析异常
|
//用例名称解析出现异常或是单个步骤参数解析异常
|
||||||
if(functionname.indexOf("解析异常")>-1||k==1){
|
if(functionname.indexOf("解析异常")>-1||k==1){
|
||||||
k=0;
|
k=0;
|
||||||
testnote = "用例第"+(i+1)+"步解析出错啦!";
|
testnote = "用例第"+(i+1)+"步解析出错啦!";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
expectedresults = casescript.get("ExpectedResults").toString(); //预期结果
|
expectedresults = casescript.get("ExpectedResults").toString();
|
||||||
if(expectedresults.indexOf(""")>-1||expectedresults.indexOf("'")>-1){ //页面转义字符转换
|
expectedresults = ChangString.changparams(expectedresults, variable,"预期结果");
|
||||||
expectedresults = expectedresults.replaceAll(""", "\"");
|
|
||||||
expectedresults = expectedresults.replaceAll("'", "\'");
|
|
||||||
}
|
|
||||||
//判断方法是否带参数
|
//判断方法是否带参数
|
||||||
if(casescript.size()>4){
|
if(casescript.size()>4){
|
||||||
//获取传入参数,放入对象中
|
//获取传入参数,放入对象中,初始化参数对象个数
|
||||||
getParameterValues = new Object[casescript.size()-4]; //初始化参数对象个数
|
getParameterValues = new Object[casescript.size()-4];
|
||||||
for(int j=0;j<casescript.size()-4;j++){
|
for(int j=0;j<casescript.size()-4;j++){
|
||||||
if(casescript.get("FunctionParams"+(j+1))==null){
|
if(casescript.get("FunctionParams"+(j+1))==null){
|
||||||
k = 1;
|
k = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(casescript.get("FunctionParams"+(j+1)).indexOf("@")>-1
|
String parameterValues = casescript.get("FunctionParams" + (j + 1));
|
||||||
&&casescript.get("FunctionParams"+(j+1)).indexOf("@@")<0){ //如果存在传参,进行处理
|
parameterValues = ChangString.changparams(parameterValues, variable,"用例参数");
|
||||||
int keyexistidentity = 0;
|
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcaseob.getSign() + "解析包名:" + packagename
|
||||||
//取单个参数中引用变量次数
|
+ " 方法名:" + functionname + " 第" + (j + 1) + "个参数:" + parameterValues);
|
||||||
int sumvariable = DBOperation.sumString(casescript.get("FunctionParams"+(j+1)), "@");
|
getParameterValues[j] = parameterValues;
|
||||||
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{
|
}else{
|
||||||
getParameterValues = null;
|
getParameterValues = null;
|
||||||
|
@ -171,12 +92,14 @@ public class ApiTestCaseDebug{
|
||||||
//调用动态方法,执行测试用例
|
//调用动态方法,执行测试用例
|
||||||
try{
|
try{
|
||||||
luckyclient.publicclass.LogUtil.APP.info("开始调用方法:"+functionname+" .....");
|
luckyclient.publicclass.LogUtil.APP.info("开始调用方法:"+functionname+" .....");
|
||||||
if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("$=")>-1){ //把预期结果前两个字符判断是否是要把结果存入变量
|
//把预期结果前两个字符判断是否是要把结果存入变量
|
||||||
String ExpectedResultVariable = casescript.get("ExpectedResults").toString().substring(2);
|
if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("$=")>-1){
|
||||||
String temptestnote = InvokeMethod.CallCase(packagename,functionname,getParameterValues,steps.get(i).getSteptype(),steps.get(i).getAction());
|
String expectedResultVariable = casescript.get("ExpectedResults").toString().substring(2);
|
||||||
variable.put(ExpectedResultVariable, temptestnote);
|
String temptestnote = InvokeMethod.callCase(packagename,functionname,getParameterValues,steps.get(i).getSteptype(),steps.get(i).getAction());
|
||||||
}else if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("%=")>-1){ //把预期结果与测试结果做模糊匹配
|
variable.put(expectedResultVariable, temptestnote);
|
||||||
testnote = InvokeMethod.CallCase(packagename,functionname,getParameterValues,steps.get(i).getSteptype(),steps.get(i).getAction());
|
//把预期结果与测试结果做模糊匹配
|
||||||
|
}else if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("%=")>-1){
|
||||||
|
testnote = InvokeMethod.callCase(packagename,functionname,getParameterValues,steps.get(i).getSteptype(),steps.get(i).getAction());
|
||||||
if(testnote.indexOf(expectedresults.substring(2))>-1){
|
if(testnote.indexOf(expectedresults.substring(2))>-1){
|
||||||
setresult = 0;
|
setresult = 0;
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例执行结果是:"+testnote+",与预期结果匹配成功!");
|
luckyclient.publicclass.LogUtil.APP.info("用例执行结果是:"+testnote+",与预期结果匹配成功!");
|
||||||
|
@ -188,7 +111,7 @@ public class ApiTestCaseDebug{
|
||||||
break; //某一步骤失败后,此条用例置为失败退出
|
break; //某一步骤失败后,此条用例置为失败退出
|
||||||
}
|
}
|
||||||
}else{ //把预期结果与测试结果做精确匹配
|
}else{ //把预期结果与测试结果做精确匹配
|
||||||
testnote = InvokeMethod.CallCase(packagename,functionname,getParameterValues,steps.get(i).getSteptype(),steps.get(i).getAction());
|
testnote = InvokeMethod.callCase(packagename,functionname,getParameterValues,steps.get(i).getSteptype(),steps.get(i).getAction());
|
||||||
if(expectedresults.equals(testnote)){
|
if(expectedresults.equals(testnote)){
|
||||||
setresult = 0;
|
setresult = 0;
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例执行结果是:"+testnote+",与预期结果匹配成功!");
|
luckyclient.publicclass.LogUtil.APP.info("用例执行结果是:"+testnote+",与预期结果匹配成功!");
|
||||||
|
@ -200,7 +123,8 @@ public class ApiTestCaseDebug{
|
||||||
break; //某一步骤失败后,此条用例置为失败退出
|
break; //某一步骤失败后,此条用例置为失败退出
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int waitsec = Integer.parseInt(casescript.get("StepWait").toString()); //获取步骤间等待时间
|
//获取步骤间等待时间
|
||||||
|
int waitsec = Integer.parseInt(casescript.get("StepWait").toString());
|
||||||
if(waitsec!=0){
|
if(waitsec!=0){
|
||||||
Thread.sleep(waitsec*1000);
|
Thread.sleep(waitsec*1000);
|
||||||
}
|
}
|
||||||
|
@ -233,7 +157,7 @@ public class ApiTestCaseDebug{
|
||||||
* @param 用例版本号
|
* @param 用例版本号
|
||||||
* 用于在testlink上配置好用例参数后,做多条用例串行调试
|
* 用于在testlink上配置好用例参数后,做多条用例串行调试
|
||||||
*/
|
*/
|
||||||
public static void MoreCaseDebug(String projectname,Map<String,Integer> addtestcase){
|
public static void moreCaseDebug(String projectname,Map<String,Integer> addtestcase){
|
||||||
System.out.println(addtestcase.size());
|
System.out.println(addtestcase.size());
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
Iterator it=addtestcase.entrySet().iterator();
|
Iterator it=addtestcase.entrySet().iterator();
|
||||||
|
@ -244,7 +168,7 @@ public class ApiTestCaseDebug{
|
||||||
Integer version = (Integer)entry.getValue();
|
Integer version = (Integer)entry.getValue();
|
||||||
try{
|
try{
|
||||||
luckyclient.publicclass.LogUtil.APP.info("开始调用方法,项目名:"+projectname+",用例编号:"+testCaseExternalId+",用例版本:"+version);
|
luckyclient.publicclass.LogUtil.APP.info("开始调用方法,项目名:"+projectname+",用例编号:"+testCaseExternalId+",用例版本:"+version);
|
||||||
OneCaseDebug(projectname,testCaseExternalId);
|
oneCaseDebug(projectname,testCaseExternalId);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,17 @@ import java.util.concurrent.ArrayBlockingQueue;
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class BatchTestCaseExecution {
|
public class BatchTestCaseExecution {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,16 +28,18 @@ public class BatchTestCaseExecution {
|
||||||
* 创建线程池,多线程执行用例
|
* 创建线程池,多线程执行用例
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static void BatchCaseExecuteForTast(String projectname,String taskid,String batchcase) throws Exception{
|
public static void batchCaseExecuteForTast(String projectname,String taskid,String batchcase) throws Exception{
|
||||||
TestTaskexcute task=GetServerAPI.cgetTaskbyid(Integer.valueOf(taskid));
|
TestTaskexcute task=GetServerAPI.cgetTaskbyid(Integer.valueOf(taskid));
|
||||||
int threadcount = task.getTestJob().getThreadCount();
|
int threadcount = task.getTestJob().getThreadCount();
|
||||||
ThreadPoolExecutor threadExecute = new ThreadPoolExecutor(threadcount, 30, 3, TimeUnit.SECONDS,
|
ThreadPoolExecutor threadExecute = new ThreadPoolExecutor(threadcount, 30, 3, TimeUnit.SECONDS,
|
||||||
new ArrayBlockingQueue<Runnable>(1000),
|
new ArrayBlockingQueue<Runnable>(1000),
|
||||||
new ThreadPoolExecutor.CallerRunsPolicy());
|
new ThreadPoolExecutor.CallerRunsPolicy());
|
||||||
if(batchcase.indexOf("ALLFAIL")>-1){ //执行全部非成功状态用例
|
//执行全部非成功状态用例
|
||||||
LogOperation caselog = new LogOperation(); //初始化写用例结果以及日志模块
|
if(batchcase.indexOf("ALLFAIL")>-1){
|
||||||
String casemore = caselog.UnSucCaseUpdate(taskid);
|
//初始化写用例结果以及日志模块
|
||||||
String temp[]=casemore.split("\\#",-1);
|
LogOperation caselog = new LogOperation();
|
||||||
|
String casemore = caselog.unSucCaseUpdate(taskid);
|
||||||
|
String[] temp=casemore.split("\\#",-1);
|
||||||
for(int i=0;i<temp.length;i++){
|
for(int i=0;i<temp.length;i++){
|
||||||
String testCaseExternalId = temp[i].substring(0, temp[i].indexOf("%"));
|
String testCaseExternalId = temp[i].substring(0, temp[i].indexOf("%"));
|
||||||
int version = Integer.parseInt(temp[i].substring(temp[i].indexOf("%")+1,temp[i].length()-1));
|
int version = Integer.parseInt(temp[i].substring(temp[i].indexOf("%")+1,temp[i].length()-1));
|
||||||
|
@ -34,7 +47,7 @@ public class BatchTestCaseExecution {
|
||||||
threadExecute.execute(new ThreadForBatchCase(projectname,testCaseExternalId,version,taskid));
|
threadExecute.execute(new ThreadForBatchCase(projectname,testCaseExternalId,version,taskid));
|
||||||
}
|
}
|
||||||
}else{ //批量执行用例
|
}else{ //批量执行用例
|
||||||
String temp[]=batchcase.split("\\#",-1);
|
String[] temp=batchcase.split("\\#",-1);
|
||||||
for(int i=0;i<temp.length-1;i++){
|
for(int i=0;i<temp.length-1;i++){
|
||||||
String testCaseExternalId = temp[i].substring(0, temp[i].indexOf("%"));
|
String testCaseExternalId = temp[i].substring(0, temp[i].indexOf("%"));
|
||||||
int version = Integer.parseInt(temp[i].substring(temp[i].indexOf("%")+1,temp[i].length()));
|
int version = Integer.parseInt(temp[i].substring(temp[i].indexOf("%")+1,temp[i].length()));
|
||||||
|
@ -56,7 +69,6 @@ public class BatchTestCaseExecution {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
// BatchTestCaseExecution.BatchCaseExecuteForTast("清算项目", "35", "ALLFAIL");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,30 @@
|
||||||
package luckyclient.caserun.exinterface;
|
package luckyclient.caserun.exinterface;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import luckyclient.caserun.exinterface.TestControl;
|
import luckyclient.caserun.exinterface.analyticsteps.InterfaceAnalyticCase;
|
||||||
import luckyclient.caserun.exinterface.AnalyticSteps.InterfaceAnalyticCase;
|
|
||||||
import luckyclient.dblog.DbLink;
|
import luckyclient.dblog.DbLink;
|
||||||
import luckyclient.dblog.LogOperation;
|
import luckyclient.dblog.LogOperation;
|
||||||
import luckyclient.planapi.api.GetServerAPI;
|
import luckyclient.planapi.api.GetServerAPI;
|
||||||
import luckyclient.planapi.entity.ProjectCase;
|
import luckyclient.planapi.entity.ProjectCase;
|
||||||
import luckyclient.planapi.entity.ProjectCasesteps;
|
import luckyclient.planapi.entity.ProjectCasesteps;
|
||||||
import luckyclient.publicclass.DBOperation;
|
import luckyclient.planapi.entity.PublicCaseParams;
|
||||||
|
import luckyclient.publicclass.ChangString;
|
||||||
import luckyclient.publicclass.InvokeMethod;
|
import luckyclient.publicclass.InvokeMethod;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class TestCaseExecution {
|
public class TestCaseExecution {
|
||||||
/**
|
/**
|
||||||
* @param 项目名
|
* @param 项目名
|
||||||
|
@ -23,12 +33,13 @@ public class TestCaseExecution {
|
||||||
* 用于单条用例调试,并通过日志框架写日志到UTP上,用做UTP上单条用例运行
|
* 用于单条用例调试,并通过日志框架写日志到UTP上,用做UTP上单条用例运行
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("static-access")
|
@SuppressWarnings("static-access")
|
||||||
public static void OneCaseExecuteForTast(String projectname, String testCaseExternalId, int version,
|
public static void oneCaseExecuteForTast(String projectname, String testCaseExternalId, int version,
|
||||||
String taskid) {
|
String taskid) {
|
||||||
Map<String, String> variable = new HashMap<String, String>();
|
Map<String, String> variable = new HashMap<String, String>();
|
||||||
TestControl.TASKID = taskid;
|
TestControl.TASKID = taskid;
|
||||||
DbLink.exetype = 0;
|
DbLink.exetype = 0;
|
||||||
LogOperation caselog = new LogOperation(); // 初始化写用例结果以及日志模块
|
// 初始化写用例结果以及日志模块
|
||||||
|
LogOperation caselog = new LogOperation();
|
||||||
String packagename = null;
|
String packagename = null;
|
||||||
String functionname = null;
|
String functionname = null;
|
||||||
String expectedresults = null;
|
String expectedresults = null;
|
||||||
|
@ -36,149 +47,56 @@ public class TestCaseExecution {
|
||||||
Object[] getParameterValues = null;
|
Object[] getParameterValues = null;
|
||||||
String testnote = null;
|
String testnote = null;
|
||||||
int k = 0;
|
int k = 0;
|
||||||
caselog.DeleteCaseLogDetail(testCaseExternalId, taskid); // 删除旧的日志
|
// 删除旧的日志
|
||||||
|
LogOperation.deleteCaseLogDetail(testCaseExternalId, taskid);
|
||||||
ProjectCase testcaseob = GetServerAPI.cgetCaseBysign(testCaseExternalId);
|
ProjectCase testcaseob = GetServerAPI.cgetCaseBysign(testCaseExternalId);
|
||||||
|
List<PublicCaseParams> pcplist=GetServerAPI.cgetParamsByProjectid(String.valueOf(testcaseob.getProjectid()));
|
||||||
|
// 把公共参数加入到MAP中
|
||||||
|
for (PublicCaseParams pcp : pcplist) {
|
||||||
|
variable.put(pcp.getParamsname(), pcp.getParamsvalue());
|
||||||
|
}
|
||||||
List<ProjectCasesteps> steps = GetServerAPI.getStepsbycaseid(testcaseob.getId());
|
List<ProjectCasesteps> steps = GetServerAPI.getStepsbycaseid(testcaseob.getId());
|
||||||
// 进入循环,解析用例所有步骤
|
// 进入循环,解析用例所有步骤
|
||||||
for (int i = 0; i < steps.size(); i++) {
|
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(testcaseob, steps.get(i), taskid,caselog);
|
||||||
packagename = casescript.get("PackageName").toString();
|
try {
|
||||||
functionname = casescript.get("FunctionName").toString();
|
packagename = casescript.get("PackageName").toString();
|
||||||
|
packagename = ChangString.changparams(packagename, variable,"包路径");
|
||||||
|
functionname = casescript.get("FunctionName").toString();
|
||||||
|
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), "");
|
||||||
|
e.printStackTrace();
|
||||||
|
break; // 某一步骤失败后,此条用例置为失败退出
|
||||||
|
}
|
||||||
// 用例名称解析出现异常或是单个步骤参数解析异常
|
// 用例名称解析出现异常或是单个步骤参数解析异常
|
||||||
if (functionname.indexOf("解析异常") > -1 || k == 1) {
|
if (functionname.indexOf("解析异常") > -1 || k == 1) {
|
||||||
k = 0;
|
k = 0;
|
||||||
testnote = "用例第" + (i + 1) + "步解析出错啦!";
|
testnote = "用例第" + (i + 1) + "步解析出错啦!";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
expectedresults = casescript.get("ExpectedResults").toString(); // 预期结果
|
expectedresults = casescript.get("ExpectedResults").toString();
|
||||||
if (expectedresults.indexOf(""") > -1 || expectedresults.indexOf("'") > -1) { // 页面转义字符转换
|
expectedresults = ChangString.changparams(expectedresults, variable,"预期结果");
|
||||||
expectedresults = expectedresults.replaceAll(""", "\"");
|
|
||||||
expectedresults = expectedresults.replaceAll("'", "\'");
|
|
||||||
}
|
|
||||||
// 判断方法是否带参数
|
// 判断方法是否带参数
|
||||||
if (casescript.size() > 4) {
|
if (casescript.size() > 4) {
|
||||||
// 获取传入参数,放入对象中
|
// 获取传入参数,放入对象中,初始化参数对象个数
|
||||||
getParameterValues = new Object[casescript.size() - 4]; // 初始化参数对象个数
|
getParameterValues = new Object[casescript.size() - 4];
|
||||||
for (int j = 0; j < casescript.size() - 4; j++) {
|
for (int j = 0; j < casescript.size() - 4; j++) {
|
||||||
if (casescript.get("FunctionParams" + (j + 1)) == null) {
|
if (casescript.get("FunctionParams" + (j + 1)) == null) {
|
||||||
k = 1;
|
k = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (casescript.get("FunctionParams" + (j + 1)).indexOf("@") > -1
|
|
||||||
&&casescript.get("FunctionParams"+(j+1)).indexOf("@@")<0) { // 如果存在传参,进行处理
|
String parameterValues = casescript.get("FunctionParams" + (j + 1));
|
||||||
int keyexistidentity = 0;
|
parameterValues = ChangString.changparams(parameterValues, variable,"用例参数");
|
||||||
// 取单个参数中引用变量次数
|
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcaseob.getSign() + "解析包名:" + packagename
|
||||||
int sumvariable = DBOperation.sumString(casescript.get("FunctionParams" + (j + 1)), "@");
|
+ " 方法名:" + functionname + " 第" + (j + 1) + "个参数:" + parameterValues);
|
||||||
String uservariable = null;
|
caselog.caseLogDetail(taskid, testcaseob.getSign(),
|
||||||
String uservariable1 = null;
|
"解析包名:" + packagename + " 方法名:" + functionname + " 第" + (j + 1) + "个参数:" + parameterValues,
|
||||||
String uservariable2 = null;
|
"info", String.valueOf(i + 1), "");
|
||||||
|
getParameterValues[j] = parameterValues;
|
||||||
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.UpdateCaseLogDetail(testCaseExternalId, taskid, "你好像在一个参数中引用了超过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.UpdateCaseLogDetail(testCaseExternalId, taskid, "解析包名:" + packagename + " 方法名:"
|
|
||||||
+ functionname + " 第" + (j + 1) + "个参数:" + ParameterValues, "info",
|
|
||||||
String.valueOf(i + 1));
|
|
||||||
getParameterValues[j] = ParameterValues;
|
|
||||||
} else {
|
|
||||||
luckyclient.publicclass.LogUtil.APP.error("没有找到你要的变量哦,再找下吧!第一个变量名称是:" + uservariable + ",第"
|
|
||||||
+ "二个变量名称是:" + uservariable1 + ",第三个变量名称是:" + uservariable2);
|
|
||||||
caselog.UpdateCaseLogDetail(testCaseExternalId,
|
|
||||||
taskid, "没有找到你要的变量哦,再找下吧!第二变量名称是:" + 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.UpdateCaseLogDetail(testCaseExternalId, taskid, "解析包名:" + packagename + " 方法名:"
|
|
||||||
+ functionname + " 第" + (j + 1) + "个参数:" + ParameterValues1, "info",
|
|
||||||
String.valueOf(i + 1));
|
|
||||||
getParameterValues[j] = ParameterValues1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
getParameterValues = null;
|
getParameterValues = null;
|
||||||
|
@ -186,23 +104,24 @@ public class TestCaseExecution {
|
||||||
// 调用动态方法,执行测试用例
|
// 调用动态方法,执行测试用例
|
||||||
try {
|
try {
|
||||||
luckyclient.publicclass.LogUtil.APP.info("开始调用方法:" + functionname + " .....");
|
luckyclient.publicclass.LogUtil.APP.info("开始调用方法:" + functionname + " .....");
|
||||||
caselog.UpdateCaseLogDetail(testCaseExternalId, taskid, "开始调用方法:" + functionname + " .....", "info",
|
LogOperation.updateCaseLogDetail(testCaseExternalId, taskid, "开始调用方法:" + functionname + " .....", "info",
|
||||||
String.valueOf(i + 1));
|
String.valueOf(i + 1));
|
||||||
if (expectedresults.length() > 2 && expectedresults.substring(0, 2).indexOf("$=") > -1) { // 把预期结果前两个字符判断是否是要把结果存入变量
|
// 把预期结果前两个字符判断是否是要把结果存入变量
|
||||||
String ExpectedResultVariable = casescript.get("ExpectedResults").toString().substring(2);
|
if (expectedresults.length() > 2 && expectedresults.substring(0, 2).indexOf("$=") > -1) {
|
||||||
String temptestnote = InvokeMethod.CallCase(packagename, functionname, getParameterValues,steps.get(i).getSteptype(),steps.get(i).getAction());
|
String expectedResultVariable = casescript.get("ExpectedResults").toString().substring(2);
|
||||||
variable.put(ExpectedResultVariable, temptestnote);
|
String temptestnote = InvokeMethod.callCase(packagename, functionname, getParameterValues,steps.get(i).getSteptype(),steps.get(i).getAction());
|
||||||
} else if (expectedresults.length() > 2 && expectedresults.substring(0, 2).indexOf("%=") > -1) { // 把预期结果与测试结果做模糊匹配
|
variable.put(expectedResultVariable, temptestnote);
|
||||||
testnote = InvokeMethod.CallCase(packagename, functionname, getParameterValues,steps.get(i).getSteptype(),steps.get(i).getAction());
|
} else if (expectedresults.length() > 2 && expectedresults.substring(0, 2).indexOf("%=") > -1) {
|
||||||
|
testnote = InvokeMethod.callCase(packagename, functionname, getParameterValues,steps.get(i).getSteptype(),steps.get(i).getAction());
|
||||||
if (testnote.indexOf(expectedresults.substring(2)) > -1) {
|
if (testnote.indexOf(expectedresults.substring(2)) > -1) {
|
||||||
setresult = 0;
|
setresult = 0;
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例执行结果是:" + testnote + ",与预期结果匹配成功!");
|
luckyclient.publicclass.LogUtil.APP.info("用例执行结果是:" + testnote + ",与预期结果匹配成功!");
|
||||||
caselog.UpdateCaseLogDetail(testCaseExternalId, taskid, "用例执行结果是:" + testnote + ",与预期结果匹配成功!",
|
LogOperation.updateCaseLogDetail(testCaseExternalId, taskid, "用例执行结果是:" + testnote + ",与预期结果匹配成功!",
|
||||||
"info", String.valueOf(i + 1));
|
"info", String.valueOf(i + 1));
|
||||||
} else {
|
} else {
|
||||||
setresult = 1;
|
setresult = 1;
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例第" + (i + 1) + "步执行结果与预期结果匹配失败!");
|
luckyclient.publicclass.LogUtil.APP.error("用例第" + (i + 1) + "步执行结果与预期结果匹配失败!");
|
||||||
caselog.UpdateCaseLogDetail(testCaseExternalId, taskid,
|
LogOperation.updateCaseLogDetail(testCaseExternalId, taskid,
|
||||||
"用例第" + (i + 1) + "步执行结果与预期结果匹配失败!预期结果:" + expectedresults + " 测试结果:" + testnote,
|
"用例第" + (i + 1) + "步执行结果与预期结果匹配失败!预期结果:" + expectedresults + " 测试结果:" + testnote,
|
||||||
"error", String.valueOf(i + 1));
|
"error", String.valueOf(i + 1));
|
||||||
luckyclient.publicclass.LogUtil.APP.error("预期结果:" + expectedresults + " 测试结果:" + testnote);
|
luckyclient.publicclass.LogUtil.APP.error("预期结果:" + expectedresults + " 测试结果:" + testnote);
|
||||||
|
@ -210,16 +129,16 @@ public class TestCaseExecution {
|
||||||
break; // 某一步骤失败后,此条用例置为失败退出
|
break; // 某一步骤失败后,此条用例置为失败退出
|
||||||
}
|
}
|
||||||
} else { // 把预期结果与测试结果做精确匹配
|
} else { // 把预期结果与测试结果做精确匹配
|
||||||
testnote = InvokeMethod.CallCase(packagename, functionname, getParameterValues,steps.get(i).getSteptype(),steps.get(i).getAction());
|
testnote = InvokeMethod.callCase(packagename, functionname, getParameterValues,steps.get(i).getSteptype(),steps.get(i).getAction());
|
||||||
if (expectedresults.equals(testnote)) {
|
if (expectedresults.equals(testnote)) {
|
||||||
setresult = 0;
|
setresult = 0;
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例执行结果是:" + testnote + ",与预期结果匹配成功!");
|
luckyclient.publicclass.LogUtil.APP.info("用例执行结果是:" + testnote + ",与预期结果匹配成功!");
|
||||||
caselog.UpdateCaseLogDetail(testCaseExternalId, taskid, "用例执行结果是:" + testnote + ",与预期结果匹配成功!",
|
LogOperation.updateCaseLogDetail(testCaseExternalId, taskid, "用例执行结果是:" + testnote + ",与预期结果匹配成功!",
|
||||||
"info", String.valueOf(i + 1));
|
"info", String.valueOf(i + 1));
|
||||||
} else {
|
} else {
|
||||||
setresult = 1;
|
setresult = 1;
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例第" + (i + 1) + "步执行结果与预期结果匹配失败!");
|
luckyclient.publicclass.LogUtil.APP.error("用例第" + (i + 1) + "步执行结果与预期结果匹配失败!");
|
||||||
caselog.UpdateCaseLogDetail(testCaseExternalId, taskid,
|
LogOperation.updateCaseLogDetail(testCaseExternalId, taskid,
|
||||||
"用例第" + (i + 1) + "步执行结果与预期结果匹配失败!预期结果:" + expectedresults + " 测试结果:" + testnote,
|
"用例第" + (i + 1) + "步执行结果与预期结果匹配失败!预期结果:" + expectedresults + " 测试结果:" + testnote,
|
||||||
"error", String.valueOf(i + 1));
|
"error", String.valueOf(i + 1));
|
||||||
luckyclient.publicclass.LogUtil.APP.error("预期结果:" + expectedresults + " 测试结果:" + testnote);
|
luckyclient.publicclass.LogUtil.APP.error("预期结果:" + expectedresults + " 测试结果:" + testnote);
|
||||||
|
@ -228,13 +147,14 @@ public class TestCaseExecution {
|
||||||
break; // 某一步骤失败后,此条用例置为失败退出
|
break; // 某一步骤失败后,此条用例置为失败退出
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int waitsec = Integer.parseInt(casescript.get("StepWait").toString()); // 获取步骤间等待时间
|
// 获取步骤间等待时间
|
||||||
|
int waitsec = Integer.parseInt(casescript.get("StepWait").toString());
|
||||||
if (waitsec != 0) {
|
if (waitsec != 0) {
|
||||||
Thread.sleep(waitsec * 1000);
|
Thread.sleep(waitsec * 1000);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
luckyclient.publicclass.LogUtil.APP.error("调用方法过程出错,方法名:" + functionname + " 请重新检查脚本方法名称以及参数!");
|
luckyclient.publicclass.LogUtil.APP.error("调用方法过程出错,方法名:" + functionname + " 请重新检查脚本方法名称以及参数!");
|
||||||
caselog.UpdateCaseLogDetail(testCaseExternalId, taskid,
|
LogOperation.updateCaseLogDetail(testCaseExternalId, taskid,
|
||||||
"调用方法过程出错,方法名:" + functionname + " 请重新检查脚本方法名称以及参数!", "error", String.valueOf(i + 1));
|
"调用方法过程出错,方法名:" + functionname + " 请重新检查脚本方法名称以及参数!", "error", String.valueOf(i + 1));
|
||||||
luckyclient.publicclass.LogUtil.APP.error(e, e);
|
luckyclient.publicclass.LogUtil.APP.error(e, e);
|
||||||
testnote = "CallCase调用出错!";
|
testnote = "CallCase调用出错!";
|
||||||
|
@ -247,29 +167,29 @@ public class TestCaseExecution {
|
||||||
// 如果调用方法过程中未出错,进入设置测试结果流程
|
// 如果调用方法过程中未出错,进入设置测试结果流程
|
||||||
if (testnote.indexOf("CallCase调用出错!") <= -1 && testnote.indexOf("解析出错啦!") <= -1) {
|
if (testnote.indexOf("CallCase调用出错!") <= -1 && testnote.indexOf("解析出错啦!") <= -1) {
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例 " + testCaseExternalId + "解析成功,并成功调用用例中方法,请继续查看执行结果!");
|
luckyclient.publicclass.LogUtil.APP.info("用例 " + testCaseExternalId + "解析成功,并成功调用用例中方法,请继续查看执行结果!");
|
||||||
caselog.UpdateCaseLogDetail(testCaseExternalId, taskid, "解析成功,并成功调用用例中方法,请继续查看执行结果!", "info",
|
LogOperation.updateCaseLogDetail(testCaseExternalId, taskid, "解析成功,并成功调用用例中方法,请继续查看执行结果!", "info",
|
||||||
"SETCASERESULT...");
|
"SETCASERESULT...");
|
||||||
// TCResult =
|
// TCResult =
|
||||||
// TestCaseApi.setTCResult(projectname,testCaseExternalId, testnote,
|
// TestCaseApi.setTCResult(projectname,testCaseExternalId, testnote,
|
||||||
// version,setresult);
|
// version,setresult);
|
||||||
caselog.UpdateCaseDetail(taskid, testCaseExternalId, setresult);
|
caselog.updateCaseDetail(taskid, testCaseExternalId, setresult);
|
||||||
} else {
|
} else {
|
||||||
setresult = 1;
|
setresult = 1;
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例 " + testCaseExternalId + "解析或是调用步骤中的方法出错!");
|
luckyclient.publicclass.LogUtil.APP.error("用例 " + testCaseExternalId + "解析或是调用步骤中的方法出错!");
|
||||||
caselog.UpdateCaseLogDetail(testCaseExternalId, taskid, "解析或是调用步骤中的方法出错!", "error", "SETCASERESULT...");
|
LogOperation.updateCaseLogDetail(testCaseExternalId, taskid, "解析或是调用步骤中的方法出错!", "error", "SETCASERESULT...");
|
||||||
// TCResult =
|
// TCResult =
|
||||||
// TestCaseApi.setTCResult(projectname,testCaseExternalId, testnote,
|
// TestCaseApi.setTCResult(projectname,testCaseExternalId, testnote,
|
||||||
// version,2);
|
// version,2);
|
||||||
caselog.UpdateCaseDetail(taskid, testCaseExternalId, 2);
|
caselog.updateCaseDetail(taskid, testCaseExternalId, 2);
|
||||||
}
|
}
|
||||||
if (0 == setresult) {
|
if (0 == setresult) {
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例 " + testCaseExternalId + "步骤全部执行成功!");
|
luckyclient.publicclass.LogUtil.APP.info("用例 " + testCaseExternalId + "步骤全部执行成功!");
|
||||||
caselog.UpdateCaseLogDetail(testCaseExternalId, taskid, "步骤全部执行成功!", "info", "EXECUTECASESUC...");
|
LogOperation.updateCaseLogDetail(testCaseExternalId, taskid, "步骤全部执行成功!", "info", "EXECUTECASESUC...");
|
||||||
} else {
|
} else {
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例 " + testCaseExternalId + "在执行过程中失败,请检查日志!");
|
luckyclient.publicclass.LogUtil.APP.error("用例 " + testCaseExternalId + "在执行过程中失败,请检查日志!");
|
||||||
caselog.UpdateCaseLogDetail(testCaseExternalId, taskid, "在执行过程中失败,请检查日志!", "error", "EXECUTECASESUC...");
|
LogOperation.updateCaseLogDetail(testCaseExternalId, taskid, "在执行过程中失败,请检查日志!", "error", "EXECUTECASESUC...");
|
||||||
}
|
}
|
||||||
LogOperation.UpdateTastdetail(taskid, 0);
|
LogOperation.updateTastdetail(taskid, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -278,7 +198,7 @@ public class TestCaseExecution {
|
||||||
* @param 用例版本号
|
* @param 用例版本号
|
||||||
* 用于在UI的测试过程中,需要调用接口的测试用例
|
* 用于在UI的测试过程中,需要调用接口的测试用例
|
||||||
*/
|
*/
|
||||||
protected static String OneCaseExecuteForWebDriver(String testCaseExternalId, String taskid,LogOperation caselog) {
|
protected static String oneCaseExecuteForWebDriver(String testCaseExternalId, String taskid,LogOperation caselog) {
|
||||||
Map<String, String> variable = new HashMap<String, String>();
|
Map<String, String> variable = new HashMap<String, String>();
|
||||||
String packagename = null;
|
String packagename = null;
|
||||||
String functionname = null;
|
String functionname = null;
|
||||||
|
@ -288,135 +208,54 @@ public class TestCaseExecution {
|
||||||
String testnote = null;
|
String testnote = null;
|
||||||
int k = 0;
|
int k = 0;
|
||||||
ProjectCase testcaseob = GetServerAPI.cgetCaseBysign(testCaseExternalId);
|
ProjectCase testcaseob = GetServerAPI.cgetCaseBysign(testCaseExternalId);
|
||||||
|
List<PublicCaseParams> pcplist=GetServerAPI.cgetParamsByProjectid(String.valueOf(testcaseob.getProjectid()));
|
||||||
|
// 把公共参数加入到MAP中
|
||||||
|
for (PublicCaseParams pcp : pcplist) {
|
||||||
|
variable.put(pcp.getParamsname(), pcp.getParamsvalue());
|
||||||
|
}
|
||||||
List<ProjectCasesteps> steps = GetServerAPI.getStepsbycaseid(testcaseob.getId());
|
List<ProjectCasesteps> steps = GetServerAPI.getStepsbycaseid(testcaseob.getId());
|
||||||
// 进入循环,解析用例所有步骤
|
// 进入循环,解析用例所有步骤
|
||||||
for (int i = 0; i < steps.size(); i++) {
|
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(testcaseob, steps.get(i), taskid,caselog);
|
||||||
packagename = casescript.get("PackageName").toString();
|
try {
|
||||||
functionname = casescript.get("FunctionName").toString();
|
packagename = casescript.get("PackageName").toString();
|
||||||
|
packagename = ChangString.changparams(packagename, variable,"包路径");
|
||||||
|
functionname = casescript.get("FunctionName").toString();
|
||||||
|
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), "");
|
||||||
|
e.printStackTrace();
|
||||||
|
break; // 某一步骤失败后,此条用例置为失败退出
|
||||||
|
}
|
||||||
// 用例名称解析出现异常或是单个步骤参数解析异常
|
// 用例名称解析出现异常或是单个步骤参数解析异常
|
||||||
if (functionname.indexOf("解析异常") > -1 || k == 1) {
|
if (functionname.indexOf("解析异常") > -1 || k == 1) {
|
||||||
k = 0;
|
k = 0;
|
||||||
testnote = "用例第" + (i + 1) + "步解析出错啦!";
|
testnote = "用例第" + (i + 1) + "步解析出错啦!";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
expectedresults = casescript.get("ExpectedResults").toString(); // 预期结果
|
expectedresults = casescript.get("ExpectedResults").toString();
|
||||||
if (expectedresults.indexOf(""") > -1 || expectedresults.indexOf("'") > -1) { // 页面转义字符转换
|
expectedresults = ChangString.changparams(expectedresults, variable,"预期结果");
|
||||||
expectedresults = expectedresults.replaceAll(""", "\"");
|
|
||||||
expectedresults = expectedresults.replaceAll("'", "\'");
|
|
||||||
}
|
|
||||||
// 判断方法是否带参数
|
// 判断方法是否带参数
|
||||||
if (casescript.size() > 4) {
|
if (casescript.size() > 4) {
|
||||||
// 获取传入参数,放入对象中
|
// 获取传入参数,放入对象中
|
||||||
getParameterValues = new Object[casescript.size() - 4]; // 初始化参数对象个数
|
getParameterValues = new Object[casescript.size() - 4];
|
||||||
for (int j = 0; j < casescript.size() - 4; j++) {
|
for (int j = 0; j < casescript.size() - 4; j++) {
|
||||||
if (casescript.get("FunctionParams" + (j + 1)) == null) {
|
if (casescript.get("FunctionParams" + (j + 1)) == null) {
|
||||||
k = 1;
|
k = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (casescript.get("FunctionParams" + (j + 1)).indexOf("@") > -1
|
|
||||||
&&casescript.get("FunctionParams"+(j+1)).indexOf("@@")<0) { // 如果存在传参,进行处理
|
String parameterValues = casescript.get("FunctionParams" + (j + 1));
|
||||||
int keyexistidentity = 0;
|
parameterValues = ChangString.changparams(parameterValues, variable,"用例参数");
|
||||||
// 取单个参数中引用变量次数
|
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcaseob.getSign() + "解析包名:" + packagename
|
||||||
int sumvariable = DBOperation.sumString(casescript.get("FunctionParams" + (j + 1)), "@");
|
+ " 方法名:" + functionname + " 第" + (j + 1) + "个参数:" + parameterValues);
|
||||||
String uservariable = null;
|
caselog.caseLogDetail(taskid, testcaseob.getSign(),
|
||||||
String uservariable1 = null;
|
"解析包名:" + packagename + " 方法名:" + functionname + " 第" + (j + 1) + "个参数:" + parameterValues,
|
||||||
String uservariable2 = null;
|
"info", String.valueOf(i + 1), "");
|
||||||
|
getParameterValues[j] = parameterValues;
|
||||||
|
|
||||||
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 {
|
} else {
|
||||||
getParameterValues = null;
|
getParameterValues = null;
|
||||||
|
@ -424,12 +263,13 @@ public class TestCaseExecution {
|
||||||
// 调用动态方法,执行测试用例
|
// 调用动态方法,执行测试用例
|
||||||
try {
|
try {
|
||||||
luckyclient.publicclass.LogUtil.APP.info("开始调用方法:" + functionname + " .....");
|
luckyclient.publicclass.LogUtil.APP.info("开始调用方法:" + functionname + " .....");
|
||||||
if (expectedresults.length() > 2 && expectedresults.substring(0, 2).indexOf("$=") > -1) { // 把预期结果前两个字符判断是否是要把结果存入变量
|
// 把预期结果前两个字符判断是否是要把结果存入变量
|
||||||
String ExpectedResultVariable = casescript.get("ExpectedResults").toString().substring(2);
|
if (expectedresults.length() > 2 && expectedresults.substring(0, 2).indexOf("$=") > -1) {
|
||||||
String temptestnote = InvokeMethod.CallCase(packagename, functionname, getParameterValues,steps.get(i).getSteptype(),steps.get(i).getAction());
|
String expectedResultVariable = casescript.get("ExpectedResults").toString().substring(2);
|
||||||
variable.put(ExpectedResultVariable, temptestnote);
|
String temptestnote = InvokeMethod.callCase(packagename, functionname, getParameterValues,steps.get(i).getSteptype(),steps.get(i).getAction());
|
||||||
} else if (expectedresults.length() > 2 && expectedresults.substring(0, 2).indexOf("%=") > -1) { // 把预期结果与测试结果做模糊匹配
|
variable.put(expectedResultVariable, temptestnote);
|
||||||
testnote = InvokeMethod.CallCase(packagename, functionname, getParameterValues,steps.get(i).getSteptype(),steps.get(i).getAction());
|
} else if (expectedresults.length() > 2 && expectedresults.substring(0, 2).indexOf("%=") > -1) {
|
||||||
|
testnote = InvokeMethod.callCase(packagename, functionname, getParameterValues,steps.get(i).getSteptype(),steps.get(i).getAction());
|
||||||
if (testnote.indexOf(expectedresults.substring(2)) > -1) {
|
if (testnote.indexOf(expectedresults.substring(2)) > -1) {
|
||||||
setresult = 0;
|
setresult = 0;
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例执行结果是:" + testnote + ",与预期结果匹配成功!");
|
luckyclient.publicclass.LogUtil.APP.info("用例执行结果是:" + testnote + ",与预期结果匹配成功!");
|
||||||
|
@ -441,7 +281,7 @@ public class TestCaseExecution {
|
||||||
break; // 某一步骤失败后,此条用例置为失败退出
|
break; // 某一步骤失败后,此条用例置为失败退出
|
||||||
}
|
}
|
||||||
} else { // 把预期结果与测试结果做精确匹配
|
} else { // 把预期结果与测试结果做精确匹配
|
||||||
testnote = InvokeMethod.CallCase(packagename, functionname, getParameterValues,steps.get(i).getSteptype(),steps.get(i).getAction());
|
testnote = InvokeMethod.callCase(packagename, functionname, getParameterValues,steps.get(i).getSteptype(),steps.get(i).getAction());
|
||||||
if ("".equals(expectedresults) || testnote.equals(expectedresults)) {
|
if ("".equals(expectedresults) || testnote.equals(expectedresults)) {
|
||||||
setresult = 0;
|
setresult = 0;
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例执行结果是:" + testnote + ",与预期结果匹配成功!");
|
luckyclient.publicclass.LogUtil.APP.info("用例执行结果是:" + testnote + ",与预期结果匹配成功!");
|
||||||
|
@ -454,7 +294,7 @@ public class TestCaseExecution {
|
||||||
break; // 某一步骤失败后,此条用例置为失败退出
|
break; // 某一步骤失败后,此条用例置为失败退出
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int waitsec = Integer.parseInt(casescript.get("StepWait").toString()); // 获取步骤间等待时间
|
int waitsec = Integer.parseInt(casescript.get("StepWait").toString());
|
||||||
if (waitsec != 0) {
|
if (waitsec != 0) {
|
||||||
Thread.sleep(waitsec * 1000);
|
Thread.sleep(waitsec * 1000);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package luckyclient.caserun.exinterface;
|
package luckyclient.caserun.exinterface;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ArrayBlockingQueue;
|
import java.util.concurrent.ArrayBlockingQueue;
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
|
@ -16,6 +17,7 @@ import luckyclient.mail.MailSendInitialization;
|
||||||
import luckyclient.planapi.api.GetServerAPI;
|
import luckyclient.planapi.api.GetServerAPI;
|
||||||
import luckyclient.planapi.entity.ProjectCase;
|
import luckyclient.planapi.entity.ProjectCase;
|
||||||
import luckyclient.planapi.entity.ProjectCasesteps;
|
import luckyclient.planapi.entity.ProjectCasesteps;
|
||||||
|
import luckyclient.planapi.entity.PublicCaseParams;
|
||||||
import luckyclient.planapi.entity.TestTaskexcute;
|
import luckyclient.planapi.entity.TestTaskexcute;
|
||||||
import luckyclient.testlinkapi.TestBuildApi;
|
import luckyclient.testlinkapi.TestBuildApi;
|
||||||
import luckyclient.testlinkapi.TestCaseApi;
|
import luckyclient.testlinkapi.TestCaseApi;
|
||||||
|
@ -23,11 +25,13 @@ import luckyclient.testlinkapi.TestCaseApi;
|
||||||
/**
|
/**
|
||||||
* =================================================================
|
* =================================================================
|
||||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
* 此测试框架主要采用testlink做分层框架,负责数据驱动以及用例管理部分,有任何疑问欢迎联系作者讨论。 QQ:24163551 seagull1985
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
* =================================================================
|
* =================================================================
|
||||||
*
|
*
|
||||||
* @ClassName: TestControl
|
* @ClassName: TestControl
|
||||||
* @Description: 启动扫描指定项目的用例脚本,并调用脚本中的方法 @author: 何彦霖
|
* @Description: 启动扫描指定项目的用例脚本,并调用脚本中的方法
|
||||||
|
* @author: seagull
|
||||||
* @date 2014年8月24日 上午9:29:40
|
* @date 2014年8月24日 上午9:29:40
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -41,14 +45,14 @@ public class TestControl {
|
||||||
* 控制台模式调度计划执行testlink用例
|
* 控制台模式调度计划执行testlink用例
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static void ManualExecutionTestLinkPlan(String projectname, String testplan) throws Exception {
|
public static void manualExecutionTestLinkPlan(String projectname, String testplan) throws Exception {
|
||||||
DbLink.exetype = 1;
|
DbLink.exetype = 1;
|
||||||
int threadcount = 10;
|
int threadcount = 10;
|
||||||
// 创建线程池,多线程执行用例
|
// 创建线程池,多线程执行用例
|
||||||
ThreadPoolExecutor threadExecute = new ThreadPoolExecutor(threadcount, 20, 3, TimeUnit.SECONDS,
|
ThreadPoolExecutor threadExecute = new ThreadPoolExecutor(threadcount, 20, 3, TimeUnit.SECONDS,
|
||||||
new ArrayBlockingQueue<Runnable>(1000), new ThreadPoolExecutor.CallerRunsPolicy());
|
new ArrayBlockingQueue<Runnable>(1000), new ThreadPoolExecutor.CallerRunsPolicy());
|
||||||
|
|
||||||
TestBuildApi.GetBuild(projectname);
|
TestBuildApi.getBuild(projectname);
|
||||||
TestCase[] testCases = TestCaseApi.getplantestcase(projectname, "NULL", testplan);
|
TestCase[] testCases = TestCaseApi.getplantestcase(projectname, "NULL", testplan);
|
||||||
String taskid = "888888";
|
String taskid = "888888";
|
||||||
for (TestCase testcase : testCases) {
|
for (TestCase testcase : testCases) {
|
||||||
|
@ -79,7 +83,7 @@ public class TestControl {
|
||||||
* 控制台模式调度计划执行用例
|
* 控制台模式调度计划执行用例
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static void ManualExecutionPlan(String planname) throws Exception {
|
public static void manualExecutionPlan(String planname) throws Exception {
|
||||||
DbLink.exetype = 1;
|
DbLink.exetype = 1;
|
||||||
int threadcount = 10;
|
int threadcount = 10;
|
||||||
// 创建线程池,多线程执行用例
|
// 创建线程池,多线程执行用例
|
||||||
|
@ -87,6 +91,11 @@ public class TestControl {
|
||||||
new ArrayBlockingQueue<Runnable>(1000), new ThreadPoolExecutor.CallerRunsPolicy());
|
new ArrayBlockingQueue<Runnable>(1000), new ThreadPoolExecutor.CallerRunsPolicy());
|
||||||
|
|
||||||
List<ProjectCase> testCases = GetServerAPI.getCasesbyplanname(planname);
|
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()));
|
||||||
|
}
|
||||||
|
|
||||||
String taskid = "888888";
|
String taskid = "888888";
|
||||||
for (ProjectCase testcase : testCases) {
|
for (ProjectCase testcase : testCases) {
|
||||||
List<ProjectCasesteps> steps = GetServerAPI.getStepsbycaseid(testcase.getId());
|
List<ProjectCasesteps> steps = GetServerAPI.getStepsbycaseid(testcase.getId());
|
||||||
|
@ -95,7 +104,7 @@ public class TestControl {
|
||||||
}
|
}
|
||||||
Debugcount++; // 多线程计数++,用于检测线程是否全部执行完
|
Debugcount++; // 多线程计数++,用于检测线程是否全部执行完
|
||||||
threadExecute
|
threadExecute
|
||||||
.execute(new ThreadForExecuteCase(testcase, steps,taskid));
|
.execute(new ThreadForExecuteCase(testcase, steps,taskid,pcplist));
|
||||||
}
|
}
|
||||||
// 多线程计数,用于检测线程是否全部执行完
|
// 多线程计数,用于检测线程是否全部执行完
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -116,14 +125,15 @@ public class TestControl {
|
||||||
* 计划任务模式调度计划执行用例
|
* 计划任务模式调度计划执行用例
|
||||||
*/
|
*/
|
||||||
|
|
||||||
protected static void TastExecutionPlan(String taskid,TestTaskexcute task) throws Exception {
|
protected static void taskExecutionPlan(String taskid,TestTaskexcute task) throws Exception {
|
||||||
DbLink.exetype = 0;
|
DbLink.exetype = 0;
|
||||||
TestControl.TASKID = taskid;
|
TestControl.TASKID = taskid;
|
||||||
String restartstatus = RestartServerInitialization.RestartServerRun(taskid);
|
String restartstatus = RestartServerInitialization.restartServerRun(taskid);
|
||||||
String buildstatus = BuildingInitialization.BuildingRun(taskid);
|
String buildstatus = BuildingInitialization.buildingRun(taskid);
|
||||||
String jobname = task.getTestJob().getTaskName();
|
String jobname = task.getTestJob().getTaskName();
|
||||||
String projectname=task.getTestJob().getPlanproj();
|
String projectname=task.getTestJob().getPlanproj();
|
||||||
int timeout = task.getTestJob().getTimeout();
|
int timeout = task.getTestJob().getTimeout();
|
||||||
|
List<PublicCaseParams> pcplist=GetServerAPI.cgetParamsByProjectid(task.getTestJob().getProjectid().toString());
|
||||||
// 判断是否要自动重启TOMCAT
|
// 判断是否要自动重启TOMCAT
|
||||||
if (restartstatus.indexOf("Status:true") > -1) {
|
if (restartstatus.indexOf("Status:true") > -1) {
|
||||||
// 判断是否构建是否成功
|
// 判断是否构建是否成功
|
||||||
|
@ -135,9 +145,9 @@ public class TestControl {
|
||||||
|
|
||||||
int[] tastcount=null;
|
int[] tastcount=null;
|
||||||
if(task.getTestJob().getProjecttype()==1){
|
if(task.getTestJob().getProjecttype()==1){
|
||||||
TestBuildApi.GetBuild(projectname);
|
TestBuildApi.getBuild(projectname);
|
||||||
TestCase[] testCases= TestCaseApi.getplantestcase(projectname, taskid, "");
|
TestCase[] testCases= TestCaseApi.getplantestcase(projectname, taskid, "");
|
||||||
LogOperation.UpdateTastStatus(taskid, testCases.length);
|
LogOperation.updateTastStatus(taskid, testCases.length);
|
||||||
for (TestCase testcase : testCases) {
|
for (TestCase testcase : testCases) {
|
||||||
if (testcase.getSteps().size() == 0) {
|
if (testcase.getSteps().size() == 0) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -155,11 +165,11 @@ public class TestControl {
|
||||||
}
|
}
|
||||||
Thread.sleep(6000);
|
Thread.sleep(6000);
|
||||||
}
|
}
|
||||||
tastcount = LogOperation.UpdateTastdetail(taskid, testCases.length);
|
tastcount = LogOperation.updateTastdetail(taskid, testCases.length);
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
List<ProjectCase> cases=GetServerAPI.getCasesbyplanid(task.getTestJob().getPlanid());
|
List<ProjectCase> cases=GetServerAPI.getCasesbyplanid(task.getTestJob().getPlanid());
|
||||||
LogOperation.UpdateTastStatus(taskid, cases.size());
|
LogOperation.updateTastStatus(taskid, cases.size());
|
||||||
for (int j=0;j<cases.size();j++) {
|
for (int j=0;j<cases.size();j++) {
|
||||||
ProjectCase projectcase =cases.get(j);
|
ProjectCase projectcase =cases.get(j);
|
||||||
List<ProjectCasesteps> steps=GetServerAPI.getStepsbycaseid(projectcase.getId());
|
List<ProjectCasesteps> steps=GetServerAPI.getStepsbycaseid(projectcase.getId());
|
||||||
|
@ -168,7 +178,7 @@ public class TestControl {
|
||||||
}
|
}
|
||||||
Debugcount++; // 多线程计数++,用于检测线程是否全部执行完
|
Debugcount++; // 多线程计数++,用于检测线程是否全部执行完
|
||||||
threadExecute.execute(
|
threadExecute.execute(
|
||||||
new ThreadForExecuteCase(projectcase, steps,taskid));
|
new ThreadForExecuteCase(projectcase, steps,taskid,pcplist));
|
||||||
}
|
}
|
||||||
// 多线程计数,用于检测线程是否全部执行完
|
// 多线程计数,用于检测线程是否全部执行完
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -179,29 +189,29 @@ public class TestControl {
|
||||||
}
|
}
|
||||||
Thread.sleep(6000);
|
Thread.sleep(6000);
|
||||||
}
|
}
|
||||||
tastcount = LogOperation.UpdateTastdetail(taskid, cases.size());
|
tastcount = LogOperation.updateTastdetail(taskid, cases.size());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String testtime = LogOperation.GetTestTime(taskid);
|
String testtime = LogOperation.getTestTime(taskid);
|
||||||
MailSendInitialization.SendMailInitialization(HtmlMail.HtmlSubjectFormat(jobname),
|
MailSendInitialization.sendMailInitialization(HtmlMail.htmlSubjectFormat(jobname),
|
||||||
HtmlMail.HtmlContentFormat(tastcount, taskid, buildstatus, restartstatus, testtime,jobname), taskid);
|
HtmlMail.htmlContentFormat(tastcount, taskid, buildstatus, restartstatus, testtime,jobname), taskid);
|
||||||
threadExecute.shutdown();
|
threadExecute.shutdown();
|
||||||
luckyclient.publicclass.LogUtil.APP.info("亲,没有下一条啦!我发现你的用例已经全部执行完毕,快去看看有没有失败的用例吧!");
|
luckyclient.publicclass.LogUtil.APP.info("亲,没有下一条啦!我发现你的用例已经全部执行完毕,快去看看有没有失败的用例吧!");
|
||||||
} else {
|
} else {
|
||||||
luckyclient.publicclass.LogUtil.APP.error("项目构建失败,自动化测试自动退出!请前往JENKINS中检查项目构建情况。");
|
luckyclient.publicclass.LogUtil.APP.error("项目构建失败,自动化测试自动退出!请前往JENKINS中检查项目构建情况。");
|
||||||
MailSendInitialization.SendMailInitialization(jobname,
|
MailSendInitialization.sendMailInitialization(jobname,
|
||||||
"构建项目过程中失败,自动化测试自动退出!请前去JENKINS查看构建情况!", taskid);
|
"构建项目过程中失败,自动化测试自动退出!请前去JENKINS查看构建情况!", taskid);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
luckyclient.publicclass.LogUtil.APP.error("项目TOMCAT重启失败,自动化测试自动退出!请检查项目TOMCAT运行情况。");
|
luckyclient.publicclass.LogUtil.APP.error("项目TOMCAT重启失败,自动化测试自动退出!请检查项目TOMCAT运行情况。");
|
||||||
MailSendInitialization.SendMailInitialization(jobname,
|
MailSendInitialization.sendMailInitialization(jobname,
|
||||||
"项目TOMCAT重启失败,自动化测试自动退出!请检查项目TOMCAT运行情况!", taskid);
|
"项目TOMCAT重启失败,自动化测试自动退出!请检查项目TOMCAT运行情况!", taskid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
ManualExecutionPlan("test");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,16 @@
|
||||||
package luckyclient.caserun.exinterface;
|
package luckyclient.caserun.exinterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class ThreadForBatchCase extends Thread{
|
public class ThreadForBatchCase extends Thread{
|
||||||
|
|
||||||
private String projectname;
|
private String projectname;
|
||||||
|
@ -14,8 +25,9 @@ public class ThreadForBatchCase extends Thread{
|
||||||
this.tastid = tastid;
|
this.tastid = tastid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void run(){
|
public void run(){
|
||||||
TestCaseExecution.OneCaseExecuteForTast(projectname, testCaseExternalId, version, tastid);
|
TestCaseExecution.oneCaseExecuteForTast(projectname, testCaseExternalId, version, tastid);
|
||||||
TestControl.Debugcount--; //多线程计数--,用于检测线程是否全部执行完
|
TestControl.Debugcount--; //多线程计数--,用于检测线程是否全部执行完
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,283 +1,226 @@
|
||||||
package luckyclient.caserun.exinterface;
|
package luckyclient.caserun.exinterface;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import luckyclient.caserun.exinterface.AnalyticSteps.InterfaceAnalyticCase;
|
import luckyclient.caserun.exinterface.analyticsteps.InterfaceAnalyticCase;
|
||||||
import luckyclient.dblog.LogOperation;
|
import luckyclient.dblog.LogOperation;
|
||||||
import luckyclient.planapi.entity.ProjectCase;
|
import luckyclient.planapi.entity.ProjectCase;
|
||||||
import luckyclient.planapi.entity.ProjectCasesteps;
|
import luckyclient.planapi.entity.ProjectCasesteps;
|
||||||
import luckyclient.publicclass.DBOperation;
|
import luckyclient.planapi.entity.PublicCaseParams;
|
||||||
|
import luckyclient.publicclass.ChangString;
|
||||||
import luckyclient.publicclass.InvokeMethod;
|
import luckyclient.publicclass.InvokeMethod;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* =================================================================
|
* =================================================================
|
||||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
* 此测试框架主要采用testlink做分层框架,负责数据驱动以及用例管理部分,有任何疑问欢迎联系作者讨论。
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
* QQ:24163551 seagull1985
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
* =================================================================
|
* =================================================================
|
||||||
* @ClassName: ThreadForExecuteCase
|
*
|
||||||
* @Description: 线程池方式执行用例
|
* @ClassName: ThreadForExecuteCase
|
||||||
|
* @Description: 线程池方式执行用例
|
||||||
* @author: seagull
|
* @author: seagull
|
||||||
* @date 2017年7月13日 上午9:29:40
|
* @date 2017年7月13日 上午9:29:40
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ThreadForExecuteCase extends Thread{
|
public class ThreadForExecuteCase extends Thread {
|
||||||
private String caseid;
|
private String caseid;
|
||||||
private ProjectCase testcaseob;
|
private ProjectCase testcaseob;
|
||||||
private String taskid;
|
private String taskid;
|
||||||
private List<ProjectCasesteps> steps;
|
private List<ProjectCasesteps> steps;
|
||||||
|
private List<PublicCaseParams> pcplist;
|
||||||
public ThreadForExecuteCase(ProjectCase projectcase,List<ProjectCasesteps> steps,String taskid){
|
|
||||||
|
public ThreadForExecuteCase(ProjectCase projectcase, List<ProjectCasesteps> steps, String taskid,
|
||||||
|
List<PublicCaseParams> pcplist) {
|
||||||
this.caseid = projectcase.getSign();
|
this.caseid = projectcase.getSign();
|
||||||
this.testcaseob = projectcase;
|
this.testcaseob = projectcase;
|
||||||
this.taskid = taskid;
|
this.taskid = taskid;
|
||||||
this.steps = steps;
|
this.steps = steps;
|
||||||
|
this.pcplist = pcplist;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(){
|
@Override
|
||||||
Map<String,String> variable = new HashMap<String,String>();
|
public void run() {
|
||||||
LogOperation caselog = new LogOperation(); //初始化写用例结果以及日志模块
|
Map<String, String> variable = new HashMap<String, String>();
|
||||||
|
// 把公共参数加入到MAP中
|
||||||
|
for (PublicCaseParams pcp : pcplist) {
|
||||||
|
variable.put(pcp.getParamsname(), pcp.getParamsvalue());
|
||||||
|
}
|
||||||
|
// 初始化写用例结果以及日志模块
|
||||||
|
LogOperation caselog = new LogOperation();
|
||||||
String functionname = null;
|
String functionname = null;
|
||||||
String packagename =null;
|
String packagename = null;
|
||||||
String expectedresults = null;
|
String expectedresults = null;
|
||||||
Integer setresult = null;
|
Integer setresult = null;
|
||||||
Object[] getParameterValues = null;
|
Object[] getParameterValues = null;
|
||||||
String testnote = null;
|
String testnote = null;
|
||||||
int k = 0;
|
int k = 0;
|
||||||
//进入循环,解析单个用例所有步骤
|
// 进入循环,解析单个用例所有步骤
|
||||||
System.out.println(caseid);
|
// 插入开始执行的用例
|
||||||
caselog.AddCaseDetail(taskid, caseid, "1", testcaseob.getName(), 4); //插入开始执行的用例
|
caselog.addCaseDetail(taskid, caseid, "1", testcaseob.getName(), 4);
|
||||||
for(int i=0;i<steps.size();i++){
|
for (int i = 0; i < steps.size(); i++) {
|
||||||
Map<String,String> casescript = InterfaceAnalyticCase.AnalyticCaseStep(testcaseob, steps.get(i),taskid,caselog); //解析单个步骤中的脚本
|
// 解析单个步骤中的脚本
|
||||||
try{
|
Map<String, String> casescript = InterfaceAnalyticCase.analyticCaseStep(testcaseob, steps.get(i), taskid,
|
||||||
packagename = casescript.get("PackageName").toString();
|
caselog);
|
||||||
functionname = casescript.get("FunctionName").toString();
|
try {
|
||||||
}catch(Exception e){
|
packagename = casescript.get("PackageName").toString();
|
||||||
k=0;
|
packagename = ChangString.changparams(packagename, variable,"包路径");
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例:"+testcaseob.getSign()+"解析包名或是方法名失败,请检查!");
|
functionname = casescript.get("FunctionName").toString();
|
||||||
caselog.CaseLogDetail(taskid, caseid, "解析包名或是方法名失败,请检查!","error",String.valueOf(i+1),"");
|
functionname = ChangString.changparams(functionname, variable,"方法名");
|
||||||
e.printStackTrace();
|
} catch (Exception e) {
|
||||||
break; //某一步骤失败后,此条用例置为失败退出
|
k = 0;
|
||||||
}
|
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcaseob.getSign() + "解析包名或是方法名失败,请检查!");
|
||||||
//用例名称解析出现异常或是单个步骤参数解析异常
|
caselog.caseLogDetail(taskid, caseid, "解析包名或是方法名失败,请检查!", "error", String.valueOf(i + 1), "");
|
||||||
if(functionname.indexOf("解析异常")>-1||k==1){
|
e.printStackTrace();
|
||||||
k=0;
|
break; // 某一步骤失败后,此条用例置为失败退出
|
||||||
testnote = "用例第"+(i+1)+"步解析出错啦!";
|
}
|
||||||
break;
|
// 用例名称解析出现异常或是单个步骤参数解析异常
|
||||||
}
|
if (functionname.indexOf("解析异常") > -1 || k == 1) {
|
||||||
expectedresults = casescript.get("ExpectedResults").toString(); //预期结果
|
k = 0;
|
||||||
if(expectedresults.indexOf(""")>-1||expectedresults.indexOf("'")>-1){ //页面转义字符转换
|
testnote = "用例第" + (i + 1) + "步解析出错啦!";
|
||||||
expectedresults = expectedresults.replaceAll(""", "\"");
|
break;
|
||||||
expectedresults = expectedresults.replaceAll("'", "\'");
|
}
|
||||||
}
|
expectedresults = casescript.get("ExpectedResults").toString();
|
||||||
//判断方法是否带参数
|
expectedresults = ChangString.changparams(expectedresults, variable,"预期结果");
|
||||||
if(casescript.size()>4){
|
// 判断方法是否带参数
|
||||||
//获取传入参数,放入对象中
|
if (casescript.size() > 4) {
|
||||||
getParameterValues = new Object[casescript.size()-4]; //初始化参数对象个数
|
// 获取传入参数,放入对象中
|
||||||
for(int j=0;j<casescript.size()-4;j++){
|
getParameterValues = new Object[casescript.size() - 4];
|
||||||
if(casescript.get("FunctionParams"+(j+1))==null){
|
for (int j = 0; j < casescript.size() - 4; j++) {
|
||||||
k = 1;
|
if (casescript.get("FunctionParams" + (j + 1)) == null) {
|
||||||
break;
|
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, caseid, "你好像在一个参数中引用了超过3个以上的变量哦!我处理不过来啦!","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(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);
|
|
||||||
caselog.CaseLogDetail(taskid, 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(taskid, caseid, "没有找到你要的变量哦,再找下吧!第二变量名称是:"+uservariable+",第"
|
|
||||||
+ "二个变量名称是:"+uservariable1,"error",String.valueOf(i+1),"");
|
|
||||||
}
|
|
||||||
|
|
||||||
}else{
|
String parameterValues = casescript.get("FunctionParams" + (j + 1));
|
||||||
String ParameterValues1 = casescript.get("FunctionParams"+(j+1));
|
parameterValues = ChangString.changparams(parameterValues, variable,"用例参数");
|
||||||
if(ParameterValues1.indexOf(""")>-1 || ParameterValues1.indexOf("'")>-1 || ParameterValues1.indexOf("@@")>-1){ //页面转义字符转换
|
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcaseob.getSign() + "解析包名:" + packagename
|
||||||
ParameterValues1 = ParameterValues1.replaceAll(""", "\"");
|
+ " 方法名:" + functionname + " 第" + (j + 1) + "个参数:" + parameterValues);
|
||||||
ParameterValues1 = ParameterValues1.replaceAll("'", "\'");
|
caselog.caseLogDetail(taskid, caseid,
|
||||||
ParameterValues1 = ParameterValues1.replaceAll("@@", "@");
|
"解析包名:" + packagename + " 方法名:" + functionname + " 第" + (j + 1) + "个参数:" + parameterValues,
|
||||||
}
|
"info", String.valueOf(i + 1), "");
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例:"+testcaseob.getSign()+"解析包名:"+packagename+" 方法名:"+functionname
|
getParameterValues[j] = parameterValues;
|
||||||
+" 第"+(j+1)+"个参数:"+ParameterValues1);
|
}
|
||||||
caselog.CaseLogDetail(taskid, caseid,"解析包名:"+packagename+" 方法名:"+functionname
|
} else {
|
||||||
+" 第"+(j+1)+"个参数:"+ParameterValues1,"info",String.valueOf(i+1),"");
|
getParameterValues = null;
|
||||||
getParameterValues[j] = ParameterValues1;
|
}
|
||||||
}
|
// 调用动态方法,执行测试用例
|
||||||
}
|
try {
|
||||||
}else{
|
luckyclient.publicclass.LogUtil.APP
|
||||||
getParameterValues = null;
|
.info("用例:" + testcaseob.getSign() + "开始调用方法:" + functionname + " .....");
|
||||||
}
|
caselog.caseLogDetail(taskid, caseid, "开始调用方法:" + functionname + " .....", "info",
|
||||||
//调用动态方法,执行测试用例
|
String.valueOf(i + 1), "");
|
||||||
try{
|
// 把预期结果前两个字符判断是否是要把结果存入变量
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例:"+testcaseob.getSign()+"开始调用方法:"+functionname+" .....");
|
if (expectedresults.length() > 2 && expectedresults.substring(0, 2).indexOf("$=") > -1) {
|
||||||
caselog.CaseLogDetail(taskid, caseid,"开始调用方法:"+functionname+" .....","info",String.valueOf(i+1),"");
|
String expectedResultVariable = casescript.get("ExpectedResults").toString().substring(2);
|
||||||
if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("$=")>-1){ //把预期结果前两个字符判断是否是要把结果存入变量
|
String temptestnote = InvokeMethod.callCase(packagename, functionname, getParameterValues,
|
||||||
String ExpectedResultVariable = casescript.get("ExpectedResults").toString().substring(2);
|
steps.get(i).getSteptype(), steps.get(i).getAction());
|
||||||
String temptestnote = InvokeMethod.CallCase(packagename,functionname,getParameterValues,steps.get(i).getSteptype(),steps.get(i).getAction());
|
// 用例参数与公共参数冲突,优先用例参数,自动替换
|
||||||
variable.put(ExpectedResultVariable, temptestnote);
|
variable.put(expectedResultVariable, temptestnote);
|
||||||
}else if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("%=")>-1){ //把预期结果与测试结果做模糊匹配
|
} else if (expectedresults.length() > 2 && expectedresults.substring(0, 2).indexOf("%=") > -1) {
|
||||||
testnote = InvokeMethod.CallCase(packagename,functionname,getParameterValues,steps.get(i).getSteptype(),steps.get(i).getAction());
|
// 把预期结果与测试结果做模糊匹配
|
||||||
if(testnote.indexOf(expectedresults.substring(2))>-1){
|
testnote = InvokeMethod.callCase(packagename, functionname, getParameterValues,
|
||||||
setresult = 0;
|
steps.get(i).getSteptype(), steps.get(i).getAction());
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例:"+testcaseob.getSign()+"执行结果是:"+testnote+",与预期结果匹配成功!");
|
if (testnote.indexOf(expectedresults.substring(2)) > -1) {
|
||||||
caselog.CaseLogDetail(taskid, caseid,"执行结果是:"+testnote+",与预期结果匹配成功!","info",String.valueOf(i+1),"");
|
setresult = 0;
|
||||||
}else{
|
luckyclient.publicclass.LogUtil.APP
|
||||||
setresult = 1;
|
.info("用例:" + testcaseob.getSign() + "执行结果是:" + testnote + ",与预期结果匹配成功!");
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例:"+testcaseob.getSign()+"第"+(i+1)+"步执行结果与预期结果匹配失败!");
|
caselog.caseLogDetail(taskid, caseid, "执行结果是:" + testnote + ",与预期结果匹配成功!", "info",
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例:"+testcaseob.getSign()+"预期结果:"+expectedresults+" 测试结果:"+testnote);
|
String.valueOf(i + 1), "");
|
||||||
caselog.CaseLogDetail(taskid, caseid,"第"+(i+1)+"步执行结果与预期结果匹配失败!"+"预期结果:"+expectedresults+" 测试结果:"+testnote,"error",String.valueOf(i+1),"");
|
} else {
|
||||||
testnote = "用例第"+(i+1)+"步执行结果与预期结果匹配失败!";
|
setresult = 1;
|
||||||
break; //某一步骤失败后,此条用例置为失败退出
|
luckyclient.publicclass.LogUtil.APP
|
||||||
}
|
.error("用例:" + testcaseob.getSign() + "第" + (i + 1) + "步执行结果与预期结果匹配失败!");
|
||||||
}else{ //把预期结果与测试结果做精确匹配
|
luckyclient.publicclass.LogUtil.APP.error(
|
||||||
testnote = InvokeMethod.CallCase(packagename,functionname,getParameterValues,steps.get(i).getSteptype(),steps.get(i).getAction());
|
"用例:" + testcaseob.getSign() + "预期结果:" + expectedresults + " 测试结果:" + testnote);
|
||||||
if(expectedresults.equals(testnote)){
|
caselog.caseLogDetail(taskid, caseid, "第" + (i + 1) + "步执行结果与预期结果匹配失败!" + "预期结果:"
|
||||||
setresult = 0;
|
+ expectedresults + " 测试结果:" + testnote, "error", String.valueOf(i + 1), "");
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例:"+testcaseob.getSign()+"执行结果是:"+testnote+",与预期结果匹配成功!");
|
testnote = "用例第" + (i + 1) + "步执行结果与预期结果匹配失败!";
|
||||||
caselog.CaseLogDetail(taskid, caseid,"执行结果是:"+testnote+",与预期结果匹配成功!","info",String.valueOf(i+1),"");
|
break; // 某一步骤失败后,此条用例置为失败退出
|
||||||
}else{
|
}
|
||||||
setresult = 1;
|
} else { // 把预期结果与测试结果做精确匹配
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例:"+testcaseob.getSign()+"第"+(i+1)+"步执行结果与预期结果匹配失败!");
|
testnote = InvokeMethod.callCase(packagename, functionname, getParameterValues,
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例:"+testcaseob.getSign()+"预期结果:"+expectedresults+" 测试结果:"+testnote);
|
steps.get(i).getSteptype(), steps.get(i).getAction());
|
||||||
caselog.CaseLogDetail(taskid, caseid,"第"+(i+1)+"步执行结果与预期结果匹配失败!"+"预期结果:"+expectedresults+" 测试结果:"+testnote,"error",String.valueOf(i+1),"");
|
if (expectedresults.equals(testnote)) {
|
||||||
testnote = "用例第"+(i+1)+"步执行结果与预期结果匹配失败!预期结果:"+expectedresults+" 测试结果:"+testnote;
|
setresult = 0;
|
||||||
break; //某一步骤失败后,此条用例置为失败退出
|
luckyclient.publicclass.LogUtil.APP
|
||||||
}
|
.info("用例:" + testcaseob.getSign() + "执行结果是:" + testnote + ",与预期结果匹配成功!");
|
||||||
}
|
caselog.caseLogDetail(taskid, caseid, "执行结果是:" + testnote + ",与预期结果匹配成功!", "info",
|
||||||
int waitsec = Integer.parseInt(casescript.get("StepWait").toString()); //获取步骤间等待时间
|
String.valueOf(i + 1), "");
|
||||||
if(waitsec!=0){
|
} else {
|
||||||
Thread.sleep(waitsec*1000);
|
setresult = 1;
|
||||||
}
|
luckyclient.publicclass.LogUtil.APP
|
||||||
}catch(Exception e){
|
.error("用例:" + testcaseob.getSign() + "第" + (i + 1) + "步执行结果与预期结果匹配失败!");
|
||||||
luckyclient.publicclass.LogUtil.ERROR.error("用例:"+testcaseob.getSign()+"调用方法过程出错,方法名:"+functionname+" 请重新检查脚本方法名称以及参数!");
|
luckyclient.publicclass.LogUtil.APP.error(
|
||||||
caselog.CaseLogDetail(taskid, caseid,"调用方法过程出错,方法名:"+functionname+" 请重新检查脚本方法名称以及参数!","error",String.valueOf(i+1),"");
|
"用例:" + testcaseob.getSign() + "预期结果:" + expectedresults + " 测试结果:" + testnote);
|
||||||
luckyclient.publicclass.LogUtil.ERROR.error(e,e);
|
caselog.caseLogDetail(taskid, caseid, "第" + (i + 1) + "步执行结果与预期结果匹配失败!" + "预期结果:"
|
||||||
testnote = "CallCase调用出错!调用方法过程出错,方法名:"+functionname+" 请重新检查脚本方法名称以及参数!";
|
+ expectedresults + " 测试结果:" + testnote, "error", String.valueOf(i + 1), "");
|
||||||
|
testnote = "用例第" + (i + 1) + "步执行结果与预期结果匹配失败!预期结果:" + expectedresults + " 测试结果:"
|
||||||
|
+ testnote;
|
||||||
|
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.getSign() + "调用方法过程出错,方法名:" + functionname + " 请重新检查脚本方法名称以及参数!");
|
||||||
|
caselog.caseLogDetail(taskid, caseid, "调用方法过程出错,方法名:" + functionname + " 请重新检查脚本方法名称以及参数!", "error",
|
||||||
|
String.valueOf(i + 1), "");
|
||||||
|
luckyclient.publicclass.LogUtil.ERROR.error(e, e);
|
||||||
|
testnote = "CallCase调用出错!调用方法过程出错,方法名:" + functionname + " 请重新检查脚本方法名称以及参数!";
|
||||||
setresult = 1;
|
setresult = 1;
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//如果调用方法过程中未出错,进入设置测试结果流程
|
// 如果调用方法过程中未出错,进入设置测试结果流程
|
||||||
try{
|
try {
|
||||||
if(testnote.indexOf("CallCase调用出错!")<=-1&&testnote.indexOf("解析出错啦!")<=-1){ //成功跟失败的用例走此流程
|
// 成功跟失败的用例走此流程
|
||||||
caselog.UpdateCaseDetail(taskid, caseid, setresult);
|
if (testnote.indexOf("CallCase调用出错!") <= -1 && testnote.indexOf("解析出错啦!") <= -1) {
|
||||||
}else{
|
caselog.updateCaseDetail(taskid, caseid, setresult);
|
||||||
luckyclient.publicclass.LogUtil.ERROR.error("用例:"+testcaseob.getSign()+"设置执行结果为锁定,请参考错误日志查找锁定用例的原因....."); //解析用例或是调用方法出错,全部把用例置为锁定
|
} else {
|
||||||
caselog.CaseLogDetail(taskid, caseid,"设置执行结果为锁定,请参考错误日志查找锁定用例的原因.....","error","SETCASERESULT...","");
|
// 解析用例或是调用方法出错,全部把用例置为锁定
|
||||||
setresult = 2;
|
luckyclient.publicclass.LogUtil.ERROR
|
||||||
caselog.UpdateCaseDetail(taskid, caseid, setresult);
|
.error("用例:" + testcaseob.getSign() + "设置执行结果为锁定,请参考错误日志查找锁定用例的原因.....");
|
||||||
}
|
caselog.caseLogDetail(taskid, caseid, "设置执行结果为锁定,请参考错误日志查找锁定用例的原因.....", "error", "SETCASERESULT...",
|
||||||
if(setresult==0){
|
"");
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例:"+testcaseob.getSign()+"执行结果成功......");
|
setresult = 2;
|
||||||
caselog.CaseLogDetail(taskid, caseid,"用例步骤执行全部成功......","info","ending","");
|
caselog.updateCaseDetail(taskid, caseid, setresult);
|
||||||
luckyclient.publicclass.LogUtil.APP.info("******************************分割线*************************************");
|
}
|
||||||
}else if(setresult==1){
|
if (setresult == 0) {
|
||||||
luckyclient.publicclass.LogUtil.ERROR.error("用例:"+testcaseob.getSign()+"执行结果失败......");
|
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcaseob.getSign() + "执行结果成功......");
|
||||||
caselog.CaseLogDetail(taskid, caseid,"用例执行结果失败......","error","ending","");
|
caselog.caseLogDetail(taskid, caseid, "用例步骤执行全部成功......", "info", "ending", "");
|
||||||
luckyclient.publicclass.LogUtil.APP.info("******************************分割线*************************************");
|
luckyclient.publicclass.LogUtil.APP
|
||||||
}else{
|
.info("*********用例【"+testcaseob.getSign()+"】执行完成,测试结果:成功*********");
|
||||||
luckyclient.publicclass.LogUtil.ERROR.error("用例:"+testcaseob.getSign()+"执行结果锁定......");
|
} else if (setresult == 1) {
|
||||||
caselog.CaseLogDetail(taskid, caseid,"用例执行结果锁定......","error","ending","");
|
luckyclient.publicclass.LogUtil.ERROR.error("用例:" + testcaseob.getSign() + "执行结果失败......");
|
||||||
luckyclient.publicclass.LogUtil.APP.info("******************************分割线*************************************");
|
caselog.caseLogDetail(taskid, caseid, "用例执行结果失败......", "error", "ending", "");
|
||||||
}
|
luckyclient.publicclass.LogUtil.APP
|
||||||
}catch(Exception e){
|
.info("*********用例【"+testcaseob.getSign()+"】执行完成,测试结果:失败*********");
|
||||||
luckyclient.publicclass.LogUtil.ERROR.error("用例:"+testcaseob.getSign()+"设置执行结果过程出错......");
|
} else {
|
||||||
caselog.CaseLogDetail(taskid, caseid,"设置执行结果过程出错......","error","ending","");
|
luckyclient.publicclass.LogUtil.ERROR.error("用例:" + testcaseob.getSign() + "执行结果锁定......");
|
||||||
luckyclient.publicclass.LogUtil.ERROR.error(e,e);
|
caselog.caseLogDetail(taskid, caseid, "用例执行结果锁定......", "error", "ending", "");
|
||||||
|
luckyclient.publicclass.LogUtil.APP
|
||||||
|
.info("*********用例【"+testcaseob.getSign()+"】执行完成,测试结果:锁定*********");
|
||||||
|
}
|
||||||
|
} 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();
|
e.printStackTrace();
|
||||||
}finally{
|
} finally {
|
||||||
variable.clear(); //一条用例结束后,清空变量存储空间
|
variable.clear(); // 一条用例结束后,清空变量存储空间
|
||||||
TestControl.Debugcount--; //多线程计数--,用于检测线程是否全部执行完
|
TestControl.Debugcount--; // 多线程计数--,用于检测线程是否全部执行完
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
package luckyclient.caserun.exinterface;
|
package luckyclient.caserun.exinterface;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import luckyclient.caserun.exinterface.AnalyticSteps.InterfaceAnalyticCase;
|
import luckyclient.caserun.exinterface.analyticsteps.InterfaceAnalyticCase;
|
||||||
import luckyclient.planapi.api.GetServerAPI;
|
import luckyclient.planapi.api.GetServerAPI;
|
||||||
import luckyclient.planapi.entity.ProjectCase;
|
import luckyclient.planapi.entity.ProjectCase;
|
||||||
import luckyclient.planapi.entity.ProjectCasesteps;
|
import luckyclient.planapi.entity.ProjectCasesteps;
|
||||||
import luckyclient.publicclass.DBOperation;
|
import luckyclient.planapi.entity.PublicCaseParams;
|
||||||
|
import luckyclient.publicclass.ChangString;
|
||||||
import luckyclient.publicclass.InvokeMethod;
|
import luckyclient.publicclass.InvokeMethod;
|
||||||
/**
|
/**
|
||||||
* =================================================================
|
* =================================================================
|
||||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
* 此测试框架主要采用testlink做分层框架,负责数据驱动以及用例管理部分,有任何疑问欢迎联系作者讨论。
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
* QQ:24163551 seagull1985
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
* =================================================================
|
* =================================================================
|
||||||
* @ClassName: WebTestCaseDebug
|
* @ClassName: WebTestCaseDebug
|
||||||
* @Description: 提供Web端调试接口
|
* @Description: 提供Web端调试接口
|
||||||
|
@ -30,7 +30,7 @@ public class WebTestCaseDebug{
|
||||||
* @param 用例编号
|
* @param 用例编号
|
||||||
* 用于在WEB页面上调试用例时提供的接口
|
* 用于在WEB页面上调试用例时提供的接口
|
||||||
*/
|
*/
|
||||||
public static void OneCaseDebug(String sign,String executor){
|
public static void oneCaseDebug(String sign,String executor){
|
||||||
Map<String,String> variable = new HashMap<String,String>();
|
Map<String,String> variable = new HashMap<String,String>();
|
||||||
String packagename =null;
|
String packagename =null;
|
||||||
String functionname = null;
|
String functionname = null;
|
||||||
|
@ -40,13 +40,20 @@ public class WebTestCaseDebug{
|
||||||
String testnote = null;
|
String testnote = null;
|
||||||
int k = 0;
|
int k = 0;
|
||||||
ProjectCase testcaseob = GetServerAPI.cgetCaseBysign(sign);
|
ProjectCase testcaseob = GetServerAPI.cgetCaseBysign(sign);
|
||||||
|
List<PublicCaseParams> pcplist=GetServerAPI.cgetParamsByProjectid(String.valueOf(testcaseob.getProjectid()));
|
||||||
|
// 把公共参数加入到MAP中
|
||||||
|
for (PublicCaseParams pcp : pcplist) {
|
||||||
|
variable.put(pcp.getParamsname(), pcp.getParamsvalue());
|
||||||
|
}
|
||||||
List<ProjectCasesteps> steps=GetServerAPI.getStepsbycaseid(testcaseob.getId());
|
List<ProjectCasesteps> steps=GetServerAPI.getStepsbycaseid(testcaseob.getId());
|
||||||
//进入循环,解析用例所有步骤
|
//进入循环,解析用例所有步骤
|
||||||
for(int i=0;i<steps.size();i++){
|
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(testcaseob, steps.get(i),"888888",null);
|
||||||
try{
|
try{
|
||||||
packagename = casescript.get("PackageName").toString();
|
packagename = casescript.get("PackageName").toString();
|
||||||
|
packagename = ChangString.changparams(packagename, variable,"包路径");
|
||||||
functionname = casescript.get("FunctionName").toString();
|
functionname = casescript.get("FunctionName").toString();
|
||||||
|
functionname = ChangString.changparams(functionname, variable,"方法名");
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
k=0;
|
k=0;
|
||||||
GetServerAPI.cPostDebugLog(sign, executor, "ERROR", "解析包名或是方法名失败,请检查!");
|
GetServerAPI.cPostDebugLog(sign, executor, "ERROR", "解析包名或是方法名失败,请检查!");
|
||||||
|
@ -59,117 +66,23 @@ public class WebTestCaseDebug{
|
||||||
testnote = "用例第"+(i+1)+"步解析出错啦!";
|
testnote = "用例第"+(i+1)+"步解析出错啦!";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
expectedresults = casescript.get("ExpectedResults").toString(); //预期结果
|
expectedresults = casescript.get("ExpectedResults").toString();
|
||||||
if(expectedresults.indexOf(""")>-1||expectedresults.indexOf("'")>-1){ //页面转义字符转换
|
expectedresults = ChangString.changparams(expectedresults, variable,"预期结果");
|
||||||
expectedresults = expectedresults.replaceAll(""", "\"");
|
|
||||||
expectedresults = expectedresults.replaceAll("'", "\'");
|
|
||||||
}
|
|
||||||
//判断方法是否带参数
|
//判断方法是否带参数
|
||||||
if(casescript.size()>4){
|
if(casescript.size()>4){
|
||||||
//获取传入参数,放入对象中
|
//获取传入参数,放入对象中
|
||||||
getParameterValues = new Object[casescript.size()-4]; //初始化参数对象个数
|
getParameterValues = new Object[casescript.size()-4];
|
||||||
for(int j=0;j<casescript.size()-4;j++){
|
for(int j=0;j<casescript.size()-4;j++){
|
||||||
if(casescript.get("FunctionParams"+(j+1))==null){
|
if(casescript.get("FunctionParams"+(j+1))==null){
|
||||||
k = 1;
|
k = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(casescript.get("FunctionParams"+(j+1)).indexOf("@")>-1
|
|
||||||
&&casescript.get("FunctionParams"+(j+1)).indexOf("@@")<0){ //如果存在传参,进行处理
|
String parameterValues = casescript.get("FunctionParams" + (j + 1));
|
||||||
int keyexistidentity = 0;
|
parameterValues = ChangString.changparams(parameterValues, variable,"用例参数");
|
||||||
//取单个参数中引用变量次数
|
GetServerAPI.cPostDebugLog(sign, executor, "INFO", "解析包名:"+packagename+" 方法名:"+functionname
|
||||||
int sumvariable = DBOperation.sumString(casescript.get("FunctionParams"+(j+1)), "@");
|
+" 第"+(j+1)+"个参数:"+parameterValues);
|
||||||
String uservariable = null;
|
getParameterValues[j] = parameterValues;
|
||||||
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{
|
|
||||||
GetServerAPI.cPostDebugLog(sign, executor, "WARNING", "你好像在一个参数中引用了超过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("'", "\'");
|
|
||||||
}
|
|
||||||
GetServerAPI.cPostDebugLog(sign, executor, "INFO", "解析包名:"+packagename+" 方法名:"+functionname
|
|
||||||
+" 第"+(j+1)+"个参数:"+ParameterValues);
|
|
||||||
getParameterValues[j] = ParameterValues;
|
|
||||||
}else{
|
|
||||||
GetServerAPI.cPostDebugLog(sign, executor, "WARNING", "没有找到你要的变量哦,再找下吧!第一个变量名称是:"+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("@@", "@");
|
|
||||||
}
|
|
||||||
GetServerAPI.cPostDebugLog(sign, executor, "INFO", "解析包名:"+packagename+" 方法名:"+functionname
|
|
||||||
+" 第"+(j+1)+"个参数:"+ParameterValues1);
|
|
||||||
getParameterValues[j] = ParameterValues1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
getParameterValues = null;
|
getParameterValues = null;
|
||||||
|
@ -177,13 +90,13 @@ public class WebTestCaseDebug{
|
||||||
//调用动态方法,执行测试用例
|
//调用动态方法,执行测试用例
|
||||||
try{
|
try{
|
||||||
GetServerAPI.cPostDebugLog(sign, executor, "INFO", "开始调用方法:"+functionname+" .....");
|
GetServerAPI.cPostDebugLog(sign, executor, "INFO", "开始调用方法:"+functionname+" .....");
|
||||||
if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("$=")>-1){ //把预期结果前两个字符判断是否是要把结果存入变量
|
if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("$=")>-1){
|
||||||
String ExpectedResultVariable = casescript.get("ExpectedResults").toString().substring(2);
|
String expectedResultVariable = casescript.get("ExpectedResults").toString().substring(2);
|
||||||
String temptestnote = InvokeMethod.CallCase(packagename,functionname,getParameterValues,steps.get(i).getSteptype(),steps.get(i).getAction());
|
String temptestnote = InvokeMethod.callCase(packagename,functionname,getParameterValues,steps.get(i).getSteptype(),steps.get(i).getAction());
|
||||||
variable.put(ExpectedResultVariable, temptestnote);
|
variable.put(expectedResultVariable, temptestnote);
|
||||||
GetServerAPI.cPostDebugLog(sign, executor, "INFO", "赋值变量【"+expectedresults.substring(2, expectedresults.length())+"】: "+temptestnote);
|
GetServerAPI.cPostDebugLog(sign, executor, "INFO", "赋值变量【"+expectedresults.substring(2, expectedresults.length())+"】: "+temptestnote);
|
||||||
}else if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("%=")>-1){ //把预期结果与测试结果做模糊匹配
|
}else if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("%=")>-1){
|
||||||
testnote = InvokeMethod.CallCase(packagename,functionname,getParameterValues,steps.get(i).getSteptype(),steps.get(i).getAction());
|
testnote = InvokeMethod.callCase(packagename,functionname,getParameterValues,steps.get(i).getSteptype(),steps.get(i).getAction());
|
||||||
if(testnote.indexOf(expectedresults.substring(2))>-1){
|
if(testnote.indexOf(expectedresults.substring(2))>-1){
|
||||||
setresult = 0;
|
setresult = 0;
|
||||||
GetServerAPI.cPostDebugLog(sign, executor, "INFO", "用例执行结果是:"+testnote+",与预期结果匹配成功!");
|
GetServerAPI.cPostDebugLog(sign, executor, "INFO", "用例执行结果是:"+testnote+",与预期结果匹配成功!");
|
||||||
|
@ -194,7 +107,7 @@ public class WebTestCaseDebug{
|
||||||
break; //某一步骤失败后,此条用例置为失败退出
|
break; //某一步骤失败后,此条用例置为失败退出
|
||||||
}
|
}
|
||||||
}else{ //把预期结果与测试结果做精确匹配
|
}else{ //把预期结果与测试结果做精确匹配
|
||||||
testnote = InvokeMethod.CallCase(packagename,functionname,getParameterValues,steps.get(i).getSteptype(),steps.get(i).getAction());
|
testnote = InvokeMethod.callCase(packagename,functionname,getParameterValues,steps.get(i).getSteptype(),steps.get(i).getAction());
|
||||||
if(expectedresults.equals(testnote)){
|
if(expectedresults.equals(testnote)){
|
||||||
setresult = 0;
|
setresult = 0;
|
||||||
GetServerAPI.cPostDebugLog(sign, executor, "INFO", "用例执行结果是:"+testnote+",与预期结果匹配成功!");
|
GetServerAPI.cPostDebugLog(sign, executor, "INFO", "用例执行结果是:"+testnote+",与预期结果匹配成功!");
|
||||||
|
@ -205,7 +118,7 @@ public class WebTestCaseDebug{
|
||||||
break; //某一步骤失败后,此条用例置为失败退出
|
break; //某一步骤失败后,此条用例置为失败退出
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int waitsec = Integer.parseInt(casescript.get("StepWait").toString()); //获取步骤间等待时间
|
int waitsec = Integer.parseInt(casescript.get("StepWait").toString());
|
||||||
if(waitsec!=0){
|
if(waitsec!=0){
|
||||||
Thread.sleep(waitsec*1000);
|
Thread.sleep(waitsec*1000);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package luckyclient.caserun.exinterface.AnalyticSteps;
|
package luckyclient.caserun.exinterface.analyticsteps;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -11,8 +11,8 @@ import luckyclient.planapi.entity.ProjectCasesteps;
|
||||||
/**
|
/**
|
||||||
* =================================================================
|
* =================================================================
|
||||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
* 此测试框架主要采用testlink做分层框架,负责数据驱动以及用例管理部分,有任何疑问欢迎联系作者讨论。
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
* QQ:24163551 seagull1985
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
* =================================================================
|
* =================================================================
|
||||||
* @ClassName: AnalyticCase
|
* @ClassName: AnalyticCase
|
||||||
* @Description: 解析单个用例中描述部分的脚本
|
* @Description: 解析单个用例中描述部分的脚本
|
||||||
|
@ -27,7 +27,7 @@ public class InterfaceAnalyticCase{
|
||||||
* @param args
|
* @param args
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("finally")
|
@SuppressWarnings("finally")
|
||||||
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){
|
||||||
String time = "0";
|
String time = "0";
|
||||||
Map<String,String> params = new HashMap<String,String>();
|
Map<String,String> params = new HashMap<String,String>();
|
||||||
|
|
||||||
|
@ -36,22 +36,23 @@ public class InterfaceAnalyticCase{
|
||||||
String functionname = step.getOperation();
|
String functionname = step.getOperation();
|
||||||
String resultstr = step.getExpectedresult();
|
String resultstr = step.getExpectedresult();
|
||||||
String action = step.getAction();
|
String action = step.getAction();
|
||||||
params.put("PackageName", packagenage.trim()); //set包名
|
params.put("PackageName", packagenage.trim());
|
||||||
params.put("FunctionName", functionname.trim()); //set方法名称
|
params.put("FunctionName", functionname.trim());
|
||||||
String Params = step.getParameters();
|
String stepParams = step.getParameters();
|
||||||
String temp[]=Params.split(splitFlag,-1);
|
String[] temp=stepParams.split(splitFlag,-1);
|
||||||
for(int i=0;i<temp.length;i++){
|
for(int i=0;i<temp.length;i++){
|
||||||
if(temp[i].equals("")){
|
if("".equals(temp[i])){
|
||||||
continue;
|
continue;
|
||||||
}else{
|
}else{
|
||||||
params.put("FunctionParams"+(i+1), temp[i]); //set第N个传入参数
|
//set第N个传入参数
|
||||||
|
params.put("FunctionParams"+(i+1), temp[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//set预期结果
|
//set预期结果
|
||||||
if(resultstr.equals("")){
|
if("".equals(resultstr)){
|
||||||
params.put("ExpectedResults", "");
|
params.put("ExpectedResults", "");
|
||||||
}else{
|
}else{
|
||||||
params.put("ExpectedResults", SubComment(resultstr));
|
params.put("ExpectedResults", subComment(resultstr));
|
||||||
}
|
}
|
||||||
//set后续操作
|
//set后续操作
|
||||||
if(null!=action&&action.toLowerCase().indexOf("*wait")>-1){
|
if(null!=action&&action.toLowerCase().indexOf("*wait")>-1){
|
||||||
|
@ -60,57 +61,71 @@ public class InterfaceAnalyticCase{
|
||||||
params.put("StepWait", time);
|
params.put("StepWait", time);
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例编号:"+projectcase.getSign()+" 步骤编号:"+step.getStepnum()+" 解析自动化用例步骤脚本完成!");
|
luckyclient.publicclass.LogUtil.APP.info("用例编号:"+projectcase.getSign()+" 步骤编号:"+step.getStepnum()+" 解析自动化用例步骤脚本完成!");
|
||||||
if(null!=caselog){
|
if(null!=caselog){
|
||||||
caselog.CaseLogDetail(taskid, projectcase.getSign(),"步骤编号:"+step.getStepnum()+" 解析自动化用例步骤脚本完成!","info",String.valueOf(step.getStepnum()),"");
|
caselog.caseLogDetail(taskid, projectcase.getSign(),"步骤编号:"+step.getStepnum()+" 解析自动化用例步骤脚本完成!","info",String.valueOf(step.getStepnum()),"");
|
||||||
}
|
}
|
||||||
}catch(Exception e) {
|
}catch(Exception e) {
|
||||||
luckyclient.publicclass.LogUtil.ERROR.error("用例编号:"+projectcase.getSign()+" 步骤编号:"+step.getStepnum()+" 解析自动化用例步骤脚本出错!");
|
luckyclient.publicclass.LogUtil.ERROR.error("用例编号:"+projectcase.getSign()+" 步骤编号:"+step.getStepnum()+" 解析自动化用例步骤脚本出错!");
|
||||||
if(null!=caselog){
|
if(null!=caselog){
|
||||||
caselog.CaseLogDetail(taskid, projectcase.getSign(),"步骤编号:"+step.getStepnum()+" 解析自动化用例步骤脚本出错!","error",String.valueOf(step.getStepnum()),"");
|
caselog.caseLogDetail(taskid, projectcase.getSign(),"步骤编号:"+step.getStepnum()+" 解析自动化用例步骤脚本出错!","error",String.valueOf(step.getStepnum()),"");
|
||||||
}
|
}
|
||||||
luckyclient.publicclass.LogUtil.ERROR.error(e,e);
|
luckyclient.publicclass.LogUtil.ERROR.error(e,e);
|
||||||
params.put("FunctionName","用例编号:"+projectcase.getSign()+"|解析异常,用例步骤为空或是用例脚本错误!");
|
params.put("FunctionName","用例编号:"+projectcase.getSign()+"|解析异常,用例步骤为空或是用例脚本错误!");
|
||||||
}finally{
|
return params;
|
||||||
return params;
|
|
||||||
}
|
}
|
||||||
|
return params;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String SubComment(String htmlStr) throws InterruptedException{
|
public static String subComment(String htmlStr) throws InterruptedException{
|
||||||
String regEx_script = "<script[^>]*?>[\\s\\S]*?<\\/script>"; // 定义script的正则表达式
|
// 定义script的正则表达式
|
||||||
String regEx_style = "<style[^>]*?>[\\s\\S]*?<\\/style>"; // 定义style的正则表达式
|
String regExscript = "<script[^>]*?>[\\s\\S]*?<\\/script>";
|
||||||
String regEx_html = "<[^>]+>"; // 定义HTML标签的正则表达式
|
// 定义style的正则表达式
|
||||||
String regEx_space = "\t|\r|\n";//定义空格回车换行符
|
String regExstyle = "<style[^>]*?>[\\s\\S]*?<\\/style>";
|
||||||
|
// 定义HTML标签的正则表达式
|
||||||
|
String regExhtml = "<[^>]+>";
|
||||||
|
//定义空格回车换行符
|
||||||
|
String regExspace = "\t|\r|\n";
|
||||||
|
|
||||||
String scriptstr = null;
|
String scriptstr = null;
|
||||||
if (htmlStr!=null) {
|
if (htmlStr!=null) {
|
||||||
Pattern p_script = Pattern.compile(regEx_script, Pattern.CASE_INSENSITIVE);
|
Pattern pScript = Pattern.compile(regExscript, Pattern.CASE_INSENSITIVE);
|
||||||
Matcher m_script = p_script.matcher(htmlStr);
|
Matcher mScript = pScript.matcher(htmlStr);
|
||||||
htmlStr = m_script.replaceAll(""); // 过滤script标签
|
// 过滤script标签
|
||||||
|
htmlStr = mScript.replaceAll("");
|
||||||
|
|
||||||
Pattern p_style = Pattern.compile(regEx_style, Pattern.CASE_INSENSITIVE);
|
Pattern pStyle = Pattern.compile(regExstyle, Pattern.CASE_INSENSITIVE);
|
||||||
Matcher m_style = p_style.matcher(htmlStr);
|
Matcher mStyle = pStyle.matcher(htmlStr);
|
||||||
htmlStr = m_style.replaceAll(""); // 过滤style标签
|
// 过滤style标签
|
||||||
|
htmlStr = mStyle.replaceAll("");
|
||||||
|
|
||||||
Pattern p_html = Pattern.compile(regEx_html, Pattern.CASE_INSENSITIVE);
|
Pattern pHtml = Pattern.compile(regExhtml, Pattern.CASE_INSENSITIVE);
|
||||||
Matcher m_html = p_html.matcher(htmlStr);
|
Matcher mHtml = pHtml.matcher(htmlStr);
|
||||||
htmlStr = m_html.replaceAll(""); // 过滤html标签
|
// 过滤html标签
|
||||||
|
htmlStr = mHtml.replaceAll("");
|
||||||
|
|
||||||
Pattern p_space = Pattern.compile(regEx_space, Pattern.CASE_INSENSITIVE);
|
Pattern pSpace = Pattern.compile(regExspace, Pattern.CASE_INSENSITIVE);
|
||||||
Matcher m_space = p_space.matcher(htmlStr);
|
Matcher mSpace = pSpace.matcher(htmlStr);
|
||||||
htmlStr = m_space.replaceAll(""); // 过滤空格回车标签
|
// 过滤空格回车标签
|
||||||
|
htmlStr = mSpace.replaceAll("");
|
||||||
|
|
||||||
}
|
}
|
||||||
if(htmlStr.indexOf("/*")>-1&&htmlStr.indexOf("*/")>-1){
|
if(htmlStr.indexOf("/*")>-1&&htmlStr.indexOf("*/")>-1){
|
||||||
String commentstr = htmlStr.substring(htmlStr.trim().indexOf("/*"),htmlStr.indexOf("*/")+2);
|
String commentstr = htmlStr.substring(htmlStr.trim().indexOf("/*"),htmlStr.indexOf("*/")+2);
|
||||||
scriptstr = htmlStr.replace(commentstr, ""); //去注释
|
//去注释
|
||||||
|
scriptstr = htmlStr.replace(commentstr, "");
|
||||||
}else{
|
}else{
|
||||||
scriptstr = htmlStr;
|
scriptstr = htmlStr;
|
||||||
}
|
}
|
||||||
|
//去掉字符串前后的空格
|
||||||
scriptstr = trimInnerSpaceStr(scriptstr); //去掉字符串前后的空格
|
scriptstr = trimInnerSpaceStr(scriptstr);
|
||||||
scriptstr = scriptstr.replaceAll(" ", " "); //替换空格转义
|
//替换空格转义
|
||||||
scriptstr = scriptstr.replaceAll(""", "\""); //转义双引号
|
scriptstr = scriptstr.replaceAll(" ", " ");
|
||||||
scriptstr = scriptstr.replaceAll("'", "\'"); //转义单引号
|
//转义双引号
|
||||||
scriptstr = scriptstr.replaceAll("&", "&"); //转义链接符
|
scriptstr = scriptstr.replaceAll(""", "\"");
|
||||||
|
//转义单引号
|
||||||
|
scriptstr = scriptstr.replaceAll("'", "\'");
|
||||||
|
//转义链接符
|
||||||
|
scriptstr = scriptstr.replaceAll("&", "&");
|
||||||
scriptstr = scriptstr.replaceAll("<", "<");
|
scriptstr = scriptstr.replaceAll("<", "<");
|
||||||
scriptstr = scriptstr.replaceAll(">", ">");
|
scriptstr = scriptstr.replaceAll(">", ">");
|
||||||
|
|
|
@ -9,6 +9,17 @@ import java.util.concurrent.ArrayBlockingQueue;
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class BatchTestLinkCaseExecution {
|
public class BatchTestLinkCaseExecution {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,16 +28,17 @@ public class BatchTestLinkCaseExecution {
|
||||||
* 创建线程池,多线程执行用例
|
* 创建线程池,多线程执行用例
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static void BatchCaseExecuteForTast(String projectname,String taskid,String batchcase) throws Exception{
|
public static void batchCaseExecuteForTast(String projectname,String taskid,String batchcase) throws Exception{
|
||||||
TestTaskexcute task=GetServerAPI.cgetTaskbyid(Integer.valueOf(taskid));
|
TestTaskexcute task=GetServerAPI.cgetTaskbyid(Integer.valueOf(taskid));
|
||||||
int threadcount = task.getTestJob().getThreadCount();
|
int threadcount = task.getTestJob().getThreadCount();
|
||||||
ThreadPoolExecutor threadExecute = new ThreadPoolExecutor(threadcount, 30, 3, TimeUnit.SECONDS,
|
ThreadPoolExecutor threadExecute = new ThreadPoolExecutor(threadcount, 30, 3, TimeUnit.SECONDS,
|
||||||
new ArrayBlockingQueue<Runnable>(1000),
|
new ArrayBlockingQueue<Runnable>(1000),
|
||||||
new ThreadPoolExecutor.CallerRunsPolicy());
|
new ThreadPoolExecutor.CallerRunsPolicy());
|
||||||
if(batchcase.indexOf("ALLFAIL")>-1){ //执行全部非成功状态用例
|
//执行全部非成功状态用例
|
||||||
LogOperation caselog = new LogOperation(); //初始化写用例结果以及日志模块
|
if(batchcase.indexOf("ALLFAIL")>-1){
|
||||||
String casemore = caselog.UnSucCaseUpdate(taskid);
|
LogOperation caselog = new LogOperation();
|
||||||
String temp[]=casemore.split("\\#",-1);
|
String casemore = caselog.unSucCaseUpdate(taskid);
|
||||||
|
String[] temp=casemore.split("\\#",-1);
|
||||||
for(int i=0;i<temp.length;i++){
|
for(int i=0;i<temp.length;i++){
|
||||||
String testCaseExternalId = temp[i].substring(0, temp[i].indexOf("%"));
|
String testCaseExternalId = temp[i].substring(0, temp[i].indexOf("%"));
|
||||||
int version = Integer.parseInt(temp[i].substring(temp[i].indexOf("%")+1,temp[i].length()-1));
|
int version = Integer.parseInt(temp[i].substring(temp[i].indexOf("%")+1,temp[i].length()-1));
|
||||||
|
@ -34,7 +46,7 @@ public class BatchTestLinkCaseExecution {
|
||||||
threadExecute.execute(new ThreadForTestLinkBatchCase(projectname,testCaseExternalId,version,taskid));
|
threadExecute.execute(new ThreadForTestLinkBatchCase(projectname,testCaseExternalId,version,taskid));
|
||||||
}
|
}
|
||||||
}else{ //批量执行用例
|
}else{ //批量执行用例
|
||||||
String temp[]=batchcase.split("\\#",-1);
|
String[] temp=batchcase.split("\\#",-1);
|
||||||
for(int i=0;i<temp.length;i++){
|
for(int i=0;i<temp.length;i++){
|
||||||
String testCaseExternalId = temp[i].substring(0, temp[i].indexOf("%"));
|
String testCaseExternalId = temp[i].substring(0, temp[i].indexOf("%"));
|
||||||
int version = Integer.parseInt(temp[i].substring(temp[i].indexOf("%")+1,temp[i].length()));
|
int version = Integer.parseInt(temp[i].substring(temp[i].indexOf("%")+1,temp[i].length()));
|
||||||
|
|
|
@ -13,8 +13,8 @@ import luckyclient.testlinkapi.TestCaseApi;
|
||||||
/**
|
/**
|
||||||
* =================================================================
|
* =================================================================
|
||||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
* 此测试框架主要采用testlink做分层框架,负责数据驱动以及用例管理部分,有任何疑问欢迎联系作者讨论。
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
* QQ:24163551 seagull1985
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
* =================================================================
|
* =================================================================
|
||||||
* @ClassName: TestCaseDebug
|
* @ClassName: TestCaseDebug
|
||||||
* @Description: 针对自动化用例在编写过程中,对用例脚本进行调试
|
* @Description: 针对自动化用例在编写过程中,对用例脚本进行调试
|
||||||
|
@ -30,7 +30,7 @@ public class TestLinkCaseDebug{
|
||||||
* @param 用例版本号
|
* @param 用例版本号
|
||||||
* 用于在testlink上配置好用例参数后,做单条用例调试
|
* 用于在testlink上配置好用例参数后,做单条用例调试
|
||||||
*/
|
*/
|
||||||
public static void OneCaseDebug(String projectname,String testCaseExternalId,int version){
|
public static void oneCaseDebug(String projectname,String testCaseExternalId,int version){
|
||||||
Map<String,String> variable = new HashMap<String,String>();
|
Map<String,String> variable = new HashMap<String,String>();
|
||||||
String packagename =null;
|
String packagename =null;
|
||||||
String functionname = null;
|
String functionname = null;
|
||||||
|
@ -43,7 +43,7 @@ public class TestLinkCaseDebug{
|
||||||
if(testcaseob.getExecutionType()==ExecutionType.AUTOMATED){
|
if(testcaseob.getExecutionType()==ExecutionType.AUTOMATED){
|
||||||
//进入循环,解析用例所有步骤
|
//进入循环,解析用例所有步骤
|
||||||
for(int i=0;i<testcaseob.getSteps().size();i++){
|
for(int i=0;i<testcaseob.getSteps().size();i++){
|
||||||
Map<String,String> casescript = InterfaceAnalyticTestLinkCase.AnalyticCaseStep(testcaseob, i+1,"888888",null); //解析单个步骤中的脚本
|
Map<String,String> casescript = InterfaceAnalyticTestLinkCase.analyticCaseStep(testcaseob, i+1,"888888",null);
|
||||||
packagename = casescript.get("PackageName").toString();
|
packagename = casescript.get("PackageName").toString();
|
||||||
functionname = casescript.get("FunctionName").toString();
|
functionname = casescript.get("FunctionName").toString();
|
||||||
//用例名称解析出现异常或是单个步骤参数解析异常
|
//用例名称解析出现异常或是单个步骤参数解析异常
|
||||||
|
@ -52,22 +52,22 @@ public class TestLinkCaseDebug{
|
||||||
testnote = "用例第"+(i+1)+"步解析出错啦!";
|
testnote = "用例第"+(i+1)+"步解析出错啦!";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
expectedresults = casescript.get("ExpectedResults").toString(); //预期结果
|
expectedresults = casescript.get("ExpectedResults").toString();
|
||||||
if(expectedresults.indexOf(""")>-1||expectedresults.indexOf("'")>-1){ //页面转义字符转换
|
if(expectedresults.indexOf(""")>-1||expectedresults.indexOf("'")>-1){
|
||||||
expectedresults = expectedresults.replaceAll(""", "\"");
|
expectedresults = expectedresults.replaceAll(""", "\"");
|
||||||
expectedresults = expectedresults.replaceAll("'", "\'");
|
expectedresults = expectedresults.replaceAll("'", "\'");
|
||||||
}
|
}
|
||||||
//判断方法是否带参数
|
//判断方法是否带参数
|
||||||
if(casescript.size()>4){
|
if(casescript.size()>4){
|
||||||
//获取传入参数,放入对象中
|
//获取传入参数,放入对象中
|
||||||
getParameterValues = new Object[casescript.size()-4]; //初始化参数对象个数
|
getParameterValues = new Object[casescript.size()-4];
|
||||||
for(int j=0;j<casescript.size()-4;j++){
|
for(int j=0;j<casescript.size()-4;j++){
|
||||||
if(casescript.get("FunctionParams"+(j+1))==null){
|
if(casescript.get("FunctionParams"+(j+1))==null){
|
||||||
k = 1;
|
k = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(casescript.get("FunctionParams"+(j+1)).indexOf("@")>-1
|
if(casescript.get("FunctionParams"+(j+1)).indexOf("@")>-1
|
||||||
&&casescript.get("FunctionParams"+(j+1)).indexOf("@@")<0){ //如果存在传参,进行处理
|
&&casescript.get("FunctionParams"+(j+1)).indexOf("@@")<0){
|
||||||
int keyexistidentity = 0;
|
int keyexistidentity = 0;
|
||||||
//取单个参数中引用变量次数
|
//取单个参数中引用变量次数
|
||||||
int sumvariable = DBOperation.sumString(casescript.get("FunctionParams"+(j+1)), "@");
|
int sumvariable = DBOperation.sumString(casescript.get("FunctionParams"+(j+1)), "@");
|
||||||
|
@ -78,7 +78,7 @@ public class TestLinkCaseDebug{
|
||||||
if(sumvariable==1){
|
if(sumvariable==1){
|
||||||
uservariable = casescript.get("FunctionParams"+(j+1)).substring(
|
uservariable = casescript.get("FunctionParams"+(j+1)).substring(
|
||||||
casescript.get("FunctionParams"+(j+1)).indexOf("@")+1);
|
casescript.get("FunctionParams"+(j+1)).indexOf("@")+1);
|
||||||
}else if(sumvariable==2){ //单个参数中引用第二个变量
|
}else if(sumvariable==2){
|
||||||
uservariable = casescript.get("FunctionParams"+(j+1)).substring(casescript.get("FunctionParams"+(j+1)).indexOf("@")+1,
|
uservariable = casescript.get("FunctionParams"+(j+1)).substring(casescript.get("FunctionParams"+(j+1)).indexOf("@")+1,
|
||||||
casescript.get("FunctionParams"+(j+1)).lastIndexOf("@"));
|
casescript.get("FunctionParams"+(j+1)).lastIndexOf("@"));
|
||||||
uservariable1 = casescript.get("FunctionParams"+(j+1)).substring(
|
uservariable1 = casescript.get("FunctionParams"+(j+1)).substring(
|
||||||
|
@ -105,7 +105,7 @@ public class TestLinkCaseDebug{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(sumvariable==2||sumvariable==3){ //处理第二个传参
|
if(sumvariable==2||sumvariable==3){
|
||||||
keys = variable.keySet().iterator();
|
keys = variable.keySet().iterator();
|
||||||
while(keys.hasNext()){
|
while(keys.hasNext()){
|
||||||
keyexistidentity = 0;
|
keyexistidentity = 0;
|
||||||
|
@ -117,7 +117,7 @@ public class TestLinkCaseDebug{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(sumvariable==3){ //处理第三个传参
|
if(sumvariable==3){
|
||||||
keys = variable.keySet().iterator();
|
keys = variable.keySet().iterator();
|
||||||
while(keys.hasNext()){
|
while(keys.hasNext()){
|
||||||
keyexistidentity = 0;
|
keyexistidentity = 0;
|
||||||
|
@ -131,37 +131,37 @@ public class TestLinkCaseDebug{
|
||||||
}
|
}
|
||||||
if(keyexistidentity == 1){
|
if(keyexistidentity == 1){
|
||||||
//拼装参数(传参+原有字符串)
|
//拼装参数(传参+原有字符串)
|
||||||
String ParameterValues =casescript.get("FunctionParams"+(j+1)).replaceAll("@"+uservariable, variable.get(uservariable).toString());
|
String parameterValues =casescript.get("FunctionParams"+(j+1)).replaceAll("@"+uservariable, variable.get(uservariable).toString());
|
||||||
//处理第二个传参
|
//处理第二个传参
|
||||||
if(sumvariable==2||sumvariable==3){
|
if(sumvariable==2||sumvariable==3){
|
||||||
ParameterValues = ParameterValues.replaceAll("@"+uservariable1, variable.get(uservariable1).toString());
|
parameterValues = parameterValues.replaceAll("@"+uservariable1, variable.get(uservariable1).toString());
|
||||||
}
|
}
|
||||||
//处理第三个传参
|
//处理第三个传参
|
||||||
if(sumvariable==3){
|
if(sumvariable==3){
|
||||||
ParameterValues = ParameterValues.replaceAll("@"+uservariable2, variable.get(uservariable2).toString());
|
parameterValues = parameterValues.replaceAll("@"+uservariable2, variable.get(uservariable2).toString());
|
||||||
}
|
}
|
||||||
if(ParameterValues.indexOf(""")>-1 || ParameterValues.indexOf("'")>-1){ //页面转义字符转换
|
if(parameterValues.indexOf(""")>-1 || parameterValues.indexOf("'")>-1){
|
||||||
ParameterValues = ParameterValues.replaceAll(""", "\"");
|
parameterValues = parameterValues.replaceAll(""", "\"");
|
||||||
ParameterValues = ParameterValues.replaceAll("'", "\'");
|
parameterValues = parameterValues.replaceAll("'", "\'");
|
||||||
}
|
}
|
||||||
luckyclient.publicclass.LogUtil.APP.info("解析包名:"+packagename+" 方法名:"+functionname
|
luckyclient.publicclass.LogUtil.APP.info("解析包名:"+packagename+" 方法名:"+functionname
|
||||||
+" 第"+(j+1)+"个参数:"+ParameterValues);
|
+" 第"+(j+1)+"个参数:"+parameterValues);
|
||||||
getParameterValues[j] = ParameterValues;
|
getParameterValues[j] = parameterValues;
|
||||||
}else{
|
}else{
|
||||||
luckyclient.publicclass.LogUtil.APP.error("没有找到你要的变量哦,再找下吧!第一个变量名称是:"+uservariable+",第"
|
luckyclient.publicclass.LogUtil.APP.error("没有找到你要的变量哦,再找下吧!第一个变量名称是:"+uservariable+",第"
|
||||||
+ "二个变量名称是:"+uservariable1+",第三个变量名称是:"+uservariable2);
|
+ "二个变量名称是:"+uservariable1+",第三个变量名称是:"+uservariable2);
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
String ParameterValues1 = casescript.get("FunctionParams"+(j+1));
|
String parameterValues1 = casescript.get("FunctionParams"+(j+1));
|
||||||
if(ParameterValues1.indexOf(""")>-1 || ParameterValues1.indexOf("'")>-1 || ParameterValues1.indexOf("@@")>-1){ //页面转义字符转换
|
if(parameterValues1.indexOf(""")>-1 || parameterValues1.indexOf("'")>-1 || parameterValues1.indexOf("@@")>-1){
|
||||||
ParameterValues1 = ParameterValues1.replaceAll(""", "\"");
|
parameterValues1 = parameterValues1.replaceAll(""", "\"");
|
||||||
ParameterValues1 = ParameterValues1.replaceAll("'", "\'");
|
parameterValues1 = parameterValues1.replaceAll("'", "\'");
|
||||||
ParameterValues1 = ParameterValues1.replaceAll("@@", "@");
|
parameterValues1 = parameterValues1.replaceAll("@@", "@");
|
||||||
}
|
}
|
||||||
luckyclient.publicclass.LogUtil.APP.info("解析包名:"+packagename+" 方法名:"+functionname
|
luckyclient.publicclass.LogUtil.APP.info("解析包名:"+packagename+" 方法名:"+functionname
|
||||||
+" 第"+(j+1)+"个参数:"+ParameterValues1);
|
+" 第"+(j+1)+"个参数:"+parameterValues1);
|
||||||
getParameterValues[j] = ParameterValues1;
|
getParameterValues[j] = parameterValues1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
@ -170,12 +170,12 @@ public class TestLinkCaseDebug{
|
||||||
//调用动态方法,执行测试用例
|
//调用动态方法,执行测试用例
|
||||||
try{
|
try{
|
||||||
luckyclient.publicclass.LogUtil.APP.info("开始调用方法:"+functionname+" .....");
|
luckyclient.publicclass.LogUtil.APP.info("开始调用方法:"+functionname+" .....");
|
||||||
if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("$=")>-1){ //把预期结果前两个字符判断是否是要把结果存入变量
|
if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("$=")>-1){
|
||||||
String ExpectedResultVariable = casescript.get("ExpectedResults").toString().substring(2);
|
String expectedResultVariable = casescript.get("ExpectedResults").toString().substring(2);
|
||||||
String temptestnote = InvokeMethod.CallCase(packagename,functionname,getParameterValues,0,"");
|
String temptestnote = InvokeMethod.callCase(packagename,functionname,getParameterValues,0,"");
|
||||||
variable.put(ExpectedResultVariable, temptestnote);
|
variable.put(expectedResultVariable, temptestnote);
|
||||||
}else if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("%=")>-1){ //把预期结果与测试结果做模糊匹配
|
}else if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("%=")>-1){
|
||||||
testnote = InvokeMethod.CallCase(packagename,functionname,getParameterValues,0,"");
|
testnote = InvokeMethod.callCase(packagename,functionname,getParameterValues,0,"");
|
||||||
if(testnote.indexOf(expectedresults.substring(2))>-1){
|
if(testnote.indexOf(expectedresults.substring(2))>-1){
|
||||||
setresult = 0;
|
setresult = 0;
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例执行结果是:"+testnote+",与预期结果匹配成功!");
|
luckyclient.publicclass.LogUtil.APP.info("用例执行结果是:"+testnote+",与预期结果匹配成功!");
|
||||||
|
@ -187,7 +187,7 @@ public class TestLinkCaseDebug{
|
||||||
break; //某一步骤失败后,此条用例置为失败退出
|
break; //某一步骤失败后,此条用例置为失败退出
|
||||||
}
|
}
|
||||||
}else{ //把预期结果与测试结果做精确匹配
|
}else{ //把预期结果与测试结果做精确匹配
|
||||||
testnote = InvokeMethod.CallCase(packagename,functionname,getParameterValues,0,"");
|
testnote = InvokeMethod.callCase(packagename,functionname,getParameterValues,0,"");
|
||||||
if(expectedresults.equals(testnote)){
|
if(expectedresults.equals(testnote)){
|
||||||
setresult = 0;
|
setresult = 0;
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例执行结果是:"+testnote+",与预期结果匹配成功!");
|
luckyclient.publicclass.LogUtil.APP.info("用例执行结果是:"+testnote+",与预期结果匹配成功!");
|
||||||
|
@ -199,7 +199,7 @@ public class TestLinkCaseDebug{
|
||||||
break; //某一步骤失败后,此条用例置为失败退出
|
break; //某一步骤失败后,此条用例置为失败退出
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int waitsec = Integer.parseInt(casescript.get("StepWait").toString()); //获取步骤间等待时间
|
int waitsec = Integer.parseInt(casescript.get("StepWait").toString());
|
||||||
if(waitsec!=0){
|
if(waitsec!=0){
|
||||||
Thread.sleep(waitsec*1000);
|
Thread.sleep(waitsec*1000);
|
||||||
}
|
}
|
||||||
|
@ -235,7 +235,7 @@ public class TestLinkCaseDebug{
|
||||||
* @param 用例版本号
|
* @param 用例版本号
|
||||||
* 用于在testlink上配置好用例参数后,做多条用例串行调试
|
* 用于在testlink上配置好用例参数后,做多条用例串行调试
|
||||||
*/
|
*/
|
||||||
public static void MoreCaseDebug(String projectname,Map<String,Integer> addtestcase){
|
public static void moreCaseDebug(String projectname,Map<String,Integer> addtestcase){
|
||||||
System.out.println(addtestcase.size());
|
System.out.println(addtestcase.size());
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
Iterator it=addtestcase.entrySet().iterator();
|
Iterator it=addtestcase.entrySet().iterator();
|
||||||
|
@ -246,7 +246,7 @@ public class TestLinkCaseDebug{
|
||||||
Integer version = (Integer)entry.getValue();
|
Integer version = (Integer)entry.getValue();
|
||||||
try{
|
try{
|
||||||
luckyclient.publicclass.LogUtil.APP.info("开始调用方法,项目名:"+projectname+",用例编号:"+testCaseExternalId+",用例版本:"+version);
|
luckyclient.publicclass.LogUtil.APP.info("开始调用方法,项目名:"+projectname+",用例编号:"+testCaseExternalId+",用例版本:"+version);
|
||||||
OneCaseDebug(projectname,testCaseExternalId,version);
|
oneCaseDebug(projectname,testCaseExternalId,version);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,17 @@ import luckyclient.publicclass.InvokeMethod;
|
||||||
import luckyclient.testlinkapi.InterfaceAnalyticTestLinkCase;
|
import luckyclient.testlinkapi.InterfaceAnalyticTestLinkCase;
|
||||||
import luckyclient.testlinkapi.TestCaseApi;
|
import luckyclient.testlinkapi.TestCaseApi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class TestLinkCaseExecution{
|
public class TestLinkCaseExecution{
|
||||||
/**
|
/**
|
||||||
* @param 项目名
|
* @param 项目名
|
||||||
|
@ -22,11 +33,11 @@ public class TestLinkCaseExecution{
|
||||||
* 用于在testlink上配置好用例参数后,做单条用例调试,并通过日志框架写日志到UTP上,用做UTP上单条用例运行
|
* 用于在testlink上配置好用例参数后,做单条用例调试,并通过日志框架写日志到UTP上,用做UTP上单条用例运行
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("static-access")
|
@SuppressWarnings("static-access")
|
||||||
public static void OneCaseExecuteForTast(String projectname,String testCaseExternalId,int version,String tastid){
|
public static void oneCaseExecuteForTast(String projectname,String testCaseExternalId,int version,String tastid){
|
||||||
Map<String,String> variable = new HashMap<String,String>();
|
Map<String,String> variable = new HashMap<String,String>();
|
||||||
TestControl.TASKID = tastid;
|
TestControl.TASKID = tastid;
|
||||||
DbLink.exetype = 0;
|
DbLink.exetype = 0;
|
||||||
LogOperation caselog = new LogOperation(); //初始化写用例结果以及日志模块
|
LogOperation caselog = new LogOperation();
|
||||||
String packagename =null;
|
String packagename =null;
|
||||||
String functionname = null;
|
String functionname = null;
|
||||||
String expectedresults = null;
|
String expectedresults = null;
|
||||||
|
@ -34,12 +45,12 @@ public class TestLinkCaseExecution{
|
||||||
Object[] getParameterValues = null;
|
Object[] getParameterValues = null;
|
||||||
String testnote = null;
|
String testnote = null;
|
||||||
int k = 0;
|
int k = 0;
|
||||||
caselog.DeleteCaseLogDetail(testCaseExternalId, tastid); //删除旧的日志
|
LogOperation.deleteCaseLogDetail(testCaseExternalId, tastid);
|
||||||
TestCase testcaseob = TestCaseApi.getTestCaseByExternalId(testCaseExternalId, version);
|
TestCase testcaseob = TestCaseApi.getTestCaseByExternalId(testCaseExternalId, version);
|
||||||
if(testcaseob.getExecutionType()==ExecutionType.AUTOMATED){
|
if(testcaseob.getExecutionType()==ExecutionType.AUTOMATED){
|
||||||
//进入循环,解析用例所有步骤
|
//进入循环,解析用例所有步骤
|
||||||
for(int i=0;i<testcaseob.getSteps().size();i++){
|
for(int i=0;i<testcaseob.getSteps().size();i++){
|
||||||
Map<String,String> casescript = InterfaceAnalyticTestLinkCase.AnalyticCaseStep(testcaseob, i+1,tastid,caselog); //解析单个步骤中的脚本
|
Map<String,String> casescript = InterfaceAnalyticTestLinkCase.analyticCaseStep(testcaseob, i+1,tastid,caselog);
|
||||||
packagename = casescript.get("PackageName").toString();
|
packagename = casescript.get("PackageName").toString();
|
||||||
functionname = casescript.get("FunctionName").toString();
|
functionname = casescript.get("FunctionName").toString();
|
||||||
//用例名称解析出现异常或是单个步骤参数解析异常
|
//用例名称解析出现异常或是单个步骤参数解析异常
|
||||||
|
@ -48,22 +59,22 @@ public class TestLinkCaseExecution{
|
||||||
testnote = "用例第"+(i+1)+"步解析出错啦!";
|
testnote = "用例第"+(i+1)+"步解析出错啦!";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
expectedresults = casescript.get("ExpectedResults").toString(); //预期结果
|
expectedresults = casescript.get("ExpectedResults").toString();
|
||||||
if(expectedresults.indexOf(""")>-1||expectedresults.indexOf("'")>-1){ //页面转义字符转换
|
if(expectedresults.indexOf(""")>-1||expectedresults.indexOf("'")>-1){
|
||||||
expectedresults = expectedresults.replaceAll(""", "\"");
|
expectedresults = expectedresults.replaceAll(""", "\"");
|
||||||
expectedresults = expectedresults.replaceAll("'", "\'");
|
expectedresults = expectedresults.replaceAll("'", "\'");
|
||||||
}
|
}
|
||||||
//判断方法是否带参数
|
//判断方法是否带参数
|
||||||
if(casescript.size()>4){
|
if(casescript.size()>4){
|
||||||
//获取传入参数,放入对象中
|
//获取传入参数,放入对象中
|
||||||
getParameterValues = new Object[casescript.size()-4]; //初始化参数对象个数
|
getParameterValues = new Object[casescript.size()-4];
|
||||||
for(int j=0;j<casescript.size()-4;j++){
|
for(int j=0;j<casescript.size()-4;j++){
|
||||||
if(casescript.get("FunctionParams"+(j+1))==null){
|
if(casescript.get("FunctionParams"+(j+1))==null){
|
||||||
k = 1;
|
k = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(casescript.get("FunctionParams"+(j+1)).indexOf("@")>-1
|
if(casescript.get("FunctionParams"+(j+1)).indexOf("@")>-1
|
||||||
&&casescript.get("FunctionParams"+(j+1)).indexOf("@@")<0){ //如果存在传参,进行处理
|
&&casescript.get("FunctionParams"+(j+1)).indexOf("@@")<0){
|
||||||
int keyexistidentity = 0;
|
int keyexistidentity = 0;
|
||||||
//取单个参数中引用变量次数
|
//取单个参数中引用变量次数
|
||||||
int sumvariable = DBOperation.sumString(casescript.get("FunctionParams"+(j+1)), "@");
|
int sumvariable = DBOperation.sumString(casescript.get("FunctionParams"+(j+1)), "@");
|
||||||
|
@ -74,7 +85,7 @@ public class TestLinkCaseExecution{
|
||||||
if(sumvariable==1){
|
if(sumvariable==1){
|
||||||
uservariable = casescript.get("FunctionParams"+(j+1)).substring(
|
uservariable = casescript.get("FunctionParams"+(j+1)).substring(
|
||||||
casescript.get("FunctionParams"+(j+1)).indexOf("@")+1);
|
casescript.get("FunctionParams"+(j+1)).indexOf("@")+1);
|
||||||
}else if(sumvariable==2){ //单个参数中引用第二个变量
|
}else if(sumvariable==2){
|
||||||
uservariable = casescript.get("FunctionParams"+(j+1)).substring(casescript.get("FunctionParams"+(j+1)).indexOf("@")+1,
|
uservariable = casescript.get("FunctionParams"+(j+1)).substring(casescript.get("FunctionParams"+(j+1)).indexOf("@")+1,
|
||||||
casescript.get("FunctionParams"+(j+1)).lastIndexOf("@"));
|
casescript.get("FunctionParams"+(j+1)).lastIndexOf("@"));
|
||||||
uservariable1 = casescript.get("FunctionParams"+(j+1)).substring(
|
uservariable1 = casescript.get("FunctionParams"+(j+1)).substring(
|
||||||
|
@ -89,7 +100,7 @@ public class TestLinkCaseExecution{
|
||||||
casescript.get("FunctionParams"+(j+1)).indexOf(uservariable1)-1);
|
casescript.get("FunctionParams"+(j+1)).indexOf(uservariable1)-1);
|
||||||
}else{
|
}else{
|
||||||
luckyclient.publicclass.LogUtil.APP.error("你好像在一个参数中引用了超过3个以上的变量哦!我处理不过来啦!");
|
luckyclient.publicclass.LogUtil.APP.error("你好像在一个参数中引用了超过3个以上的变量哦!我处理不过来啦!");
|
||||||
caselog.UpdateCaseLogDetail(testCaseExternalId, tastid, "你好像在一个参数中引用了超过2个以上的变量哦!我处理不过来啦!", "error",String.valueOf(i+1));
|
LogOperation.updateCaseLogDetail(testCaseExternalId, tastid, "你好像在一个参数中引用了超过2个以上的变量哦!我处理不过来啦!", "error",String.valueOf(i+1));
|
||||||
}
|
}
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
Iterator keys = variable.keySet().iterator();
|
Iterator keys = variable.keySet().iterator();
|
||||||
|
@ -102,7 +113,7 @@ public class TestLinkCaseExecution{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(sumvariable==2||sumvariable==3){ //处理第二个传参
|
if(sumvariable==2||sumvariable==3){
|
||||||
keys = variable.keySet().iterator();
|
keys = variable.keySet().iterator();
|
||||||
while(keys.hasNext()){
|
while(keys.hasNext()){
|
||||||
keyexistidentity = 0;
|
keyexistidentity = 0;
|
||||||
|
@ -114,7 +125,7 @@ public class TestLinkCaseExecution{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(sumvariable==3){ //处理第三个传参
|
if(sumvariable==3){
|
||||||
keys = variable.keySet().iterator();
|
keys = variable.keySet().iterator();
|
||||||
while(keys.hasNext()){
|
while(keys.hasNext()){
|
||||||
keyexistidentity = 0;
|
keyexistidentity = 0;
|
||||||
|
@ -128,43 +139,43 @@ public class TestLinkCaseExecution{
|
||||||
}
|
}
|
||||||
if(keyexistidentity == 1){
|
if(keyexistidentity == 1){
|
||||||
//拼装参数(传参+原有字符串)
|
//拼装参数(传参+原有字符串)
|
||||||
String ParameterValues =casescript.get("FunctionParams"+(j+1)).replaceAll("@"+uservariable, variable.get(uservariable).toString());
|
String parameterValues =casescript.get("FunctionParams"+(j+1)).replaceAll("@"+uservariable, variable.get(uservariable).toString());
|
||||||
//处理第二个传参
|
//处理第二个传参
|
||||||
if(sumvariable==2||sumvariable==3){
|
if(sumvariable==2||sumvariable==3){
|
||||||
ParameterValues = ParameterValues.replaceAll("@"+uservariable1, variable.get(uservariable1).toString());
|
parameterValues = parameterValues.replaceAll("@"+uservariable1, variable.get(uservariable1).toString());
|
||||||
}
|
}
|
||||||
//处理第三个传参
|
//处理第三个传参
|
||||||
if(sumvariable==3){
|
if(sumvariable==3){
|
||||||
ParameterValues = ParameterValues.replaceAll("@"+uservariable2, variable.get(uservariable2).toString());
|
parameterValues = parameterValues.replaceAll("@"+uservariable2, variable.get(uservariable2).toString());
|
||||||
}
|
}
|
||||||
if(ParameterValues.indexOf(""")>-1 || ParameterValues.indexOf("'")>-1){ //页面转义字符转换
|
if(parameterValues.indexOf(""")>-1 || parameterValues.indexOf("'")>-1){
|
||||||
ParameterValues = ParameterValues.replaceAll(""", "\"");
|
parameterValues = parameterValues.replaceAll(""", "\"");
|
||||||
ParameterValues = ParameterValues.replaceAll("'", "\'");
|
parameterValues = parameterValues.replaceAll("'", "\'");
|
||||||
}
|
}
|
||||||
luckyclient.publicclass.LogUtil.APP.info("解析包名:"+packagename+" 方法名:"+functionname
|
luckyclient.publicclass.LogUtil.APP.info("解析包名:"+packagename+" 方法名:"+functionname
|
||||||
+" 第"+(j+1)+"个参数:"+ParameterValues);
|
+" 第"+(j+1)+"个参数:"+parameterValues);
|
||||||
caselog.UpdateCaseLogDetail(testCaseExternalId, tastid, "解析包名:"+packagename+" 方法名:"+functionname
|
LogOperation.updateCaseLogDetail(testCaseExternalId, tastid, "解析包名:"+packagename+" 方法名:"+functionname
|
||||||
+" 第"+(j+1)+"个参数:"+ParameterValues, "info",String.valueOf(i+1));
|
+" 第"+(j+1)+"个参数:"+parameterValues, "info",String.valueOf(i+1));
|
||||||
getParameterValues[j] = ParameterValues;
|
getParameterValues[j] = parameterValues;
|
||||||
}else{
|
}else{
|
||||||
luckyclient.publicclass.LogUtil.APP.error("没有找到你要的变量哦,再找下吧!第一个变量名称是:"+uservariable+",第"
|
luckyclient.publicclass.LogUtil.APP.error("没有找到你要的变量哦,再找下吧!第一个变量名称是:"+uservariable+",第"
|
||||||
+ "二个变量名称是:"+uservariable1+",第三个变量名称是:"+uservariable2);
|
+ "二个变量名称是:"+uservariable1+",第三个变量名称是:"+uservariable2);
|
||||||
caselog.UpdateCaseLogDetail(testCaseExternalId, tastid, "没有找到你要的变量哦,再找下吧!第二变量名称是:"+uservariable+",第"
|
LogOperation.updateCaseLogDetail(testCaseExternalId, tastid, "没有找到你要的变量哦,再找下吧!第二变量名称是:"+uservariable+",第"
|
||||||
+ "二个变量名称是:"+uservariable1+",第三个变量名称是:"+uservariable2, "error",String.valueOf(i+1));
|
+ "二个变量名称是:"+uservariable1+",第三个变量名称是:"+uservariable2, "error",String.valueOf(i+1));
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
String ParameterValues1 = casescript.get("FunctionParams"+(j+1));
|
String parameterValues1 = casescript.get("FunctionParams"+(j+1));
|
||||||
if(ParameterValues1.indexOf(""")>-1 || ParameterValues1.indexOf("'")>-1 || ParameterValues1.indexOf("@@")>-1){ //页面转义字符转换
|
if(parameterValues1.indexOf(""")>-1 || parameterValues1.indexOf("'")>-1 || parameterValues1.indexOf("@@")>-1){
|
||||||
ParameterValues1 = ParameterValues1.replaceAll(""", "\"");
|
parameterValues1 = parameterValues1.replaceAll(""", "\"");
|
||||||
ParameterValues1 = ParameterValues1.replaceAll("'", "\'");
|
parameterValues1 = parameterValues1.replaceAll("'", "\'");
|
||||||
ParameterValues1 = ParameterValues1.replaceAll("@@", "@");
|
parameterValues1 = parameterValues1.replaceAll("@@", "@");
|
||||||
}
|
}
|
||||||
luckyclient.publicclass.LogUtil.APP.info("解析包名:"+packagename+" 方法名:"+functionname
|
luckyclient.publicclass.LogUtil.APP.info("解析包名:"+packagename+" 方法名:"+functionname
|
||||||
+" 第"+(j+1)+"个参数:"+ParameterValues1);
|
+" 第"+(j+1)+"个参数:"+parameterValues1);
|
||||||
caselog.UpdateCaseLogDetail(testCaseExternalId, tastid, "解析包名:"+packagename+" 方法名:"+functionname
|
LogOperation.updateCaseLogDetail(testCaseExternalId, tastid, "解析包名:"+packagename+" 方法名:"+functionname
|
||||||
+" 第"+(j+1)+"个参数:"+ParameterValues1, "info",String.valueOf(i+1));
|
+" 第"+(j+1)+"个参数:"+parameterValues1, "info",String.valueOf(i+1));
|
||||||
getParameterValues[j] = ParameterValues1;
|
getParameterValues[j] = parameterValues1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
@ -173,48 +184,48 @@ public class TestLinkCaseExecution{
|
||||||
//调用动态方法,执行测试用例
|
//调用动态方法,执行测试用例
|
||||||
try{
|
try{
|
||||||
luckyclient.publicclass.LogUtil.APP.info("开始调用方法:"+functionname+" .....");
|
luckyclient.publicclass.LogUtil.APP.info("开始调用方法:"+functionname+" .....");
|
||||||
caselog.UpdateCaseLogDetail(testCaseExternalId, tastid, "开始调用方法:"+functionname+" .....", "info",String.valueOf(i+1));
|
LogOperation.updateCaseLogDetail(testCaseExternalId, tastid, "开始调用方法:"+functionname+" .....", "info",String.valueOf(i+1));
|
||||||
if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("$=")>-1){ //把预期结果前两个字符判断是否是要把结果存入变量
|
if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("$=")>-1){
|
||||||
String ExpectedResultVariable = casescript.get("ExpectedResults").toString().substring(2);
|
String expectedResultVariable = casescript.get("ExpectedResults").toString().substring(2);
|
||||||
String temptestnote = InvokeMethod.CallCase(packagename,functionname,getParameterValues,0,"");
|
String temptestnote = InvokeMethod.callCase(packagename,functionname,getParameterValues,0,"");
|
||||||
variable.put(ExpectedResultVariable, temptestnote);
|
variable.put(expectedResultVariable, temptestnote);
|
||||||
}else if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("%=")>-1){ //把预期结果与测试结果做模糊匹配
|
}else if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("%=")>-1){
|
||||||
testnote = InvokeMethod.CallCase(packagename,functionname,getParameterValues,0,"");
|
testnote = InvokeMethod.callCase(packagename,functionname,getParameterValues,0,"");
|
||||||
if(testnote.indexOf(expectedresults.substring(2))>-1){
|
if(testnote.indexOf(expectedresults.substring(2))>-1){
|
||||||
setresult = 0;
|
setresult = 0;
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例执行结果是:"+testnote+",与预期结果匹配成功!");
|
luckyclient.publicclass.LogUtil.APP.info("用例执行结果是:"+testnote+",与预期结果匹配成功!");
|
||||||
caselog.UpdateCaseLogDetail(testCaseExternalId, tastid, "用例执行结果是:"+testnote+",与预期结果匹配成功!", "info",String.valueOf(i+1));
|
LogOperation.updateCaseLogDetail(testCaseExternalId, tastid, "用例执行结果是:"+testnote+",与预期结果匹配成功!", "info",String.valueOf(i+1));
|
||||||
}else{
|
}else{
|
||||||
setresult = 1;
|
setresult = 1;
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例第"+(i+1)+"步执行结果与预期结果匹配失败!");
|
luckyclient.publicclass.LogUtil.APP.error("用例第"+(i+1)+"步执行结果与预期结果匹配失败!");
|
||||||
caselog.UpdateCaseLogDetail(testCaseExternalId, tastid, "用例第"+(i+1)+"步执行结果与预期结果匹配失败!预期结果:"+expectedresults+" 测试结果:"+testnote, "error",String.valueOf(i+1));
|
LogOperation.updateCaseLogDetail(testCaseExternalId, tastid, "用例第"+(i+1)+"步执行结果与预期结果匹配失败!预期结果:"+expectedresults+" 测试结果:"+testnote, "error",String.valueOf(i+1));
|
||||||
luckyclient.publicclass.LogUtil.APP.error("预期结果:"+expectedresults+" 测试结果:"+testnote);
|
luckyclient.publicclass.LogUtil.APP.error("预期结果:"+expectedresults+" 测试结果:"+testnote);
|
||||||
testnote = "用例第"+(i+1)+"步执行结果与预期结果匹配失败!";
|
testnote = "用例第"+(i+1)+"步执行结果与预期结果匹配失败!";
|
||||||
break; //某一步骤失败后,此条用例置为失败退出
|
break; //某一步骤失败后,此条用例置为失败退出
|
||||||
}
|
}
|
||||||
}else{ //把预期结果与测试结果做精确匹配
|
}else{ //把预期结果与测试结果做精确匹配
|
||||||
testnote = InvokeMethod.CallCase(packagename,functionname,getParameterValues,0,"");
|
testnote = InvokeMethod.callCase(packagename,functionname,getParameterValues,0,"");
|
||||||
if(expectedresults.equals(testnote)){
|
if(expectedresults.equals(testnote)){
|
||||||
setresult = 0;
|
setresult = 0;
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例执行结果是:"+testnote+",与预期结果匹配成功!");
|
luckyclient.publicclass.LogUtil.APP.info("用例执行结果是:"+testnote+",与预期结果匹配成功!");
|
||||||
caselog.UpdateCaseLogDetail(testCaseExternalId, tastid, "用例执行结果是:"+testnote+",与预期结果匹配成功!", "info",String.valueOf(i+1));
|
LogOperation.updateCaseLogDetail(testCaseExternalId, tastid, "用例执行结果是:"+testnote+",与预期结果匹配成功!", "info",String.valueOf(i+1));
|
||||||
}else{
|
}else{
|
||||||
setresult = 1;
|
setresult = 1;
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例第"+(i+1)+"步执行结果与预期结果匹配失败!");
|
luckyclient.publicclass.LogUtil.APP.error("用例第"+(i+1)+"步执行结果与预期结果匹配失败!");
|
||||||
caselog.UpdateCaseLogDetail(testCaseExternalId, tastid, "用例第"+(i+1)+"步执行结果与预期结果匹配失败!预期结果:"
|
LogOperation.updateCaseLogDetail(testCaseExternalId, tastid, "用例第"+(i+1)+"步执行结果与预期结果匹配失败!预期结果:"
|
||||||
+expectedresults+" 测试结果:"+testnote, "error",String.valueOf(i+1));
|
+expectedresults+" 测试结果:"+testnote, "error",String.valueOf(i+1));
|
||||||
luckyclient.publicclass.LogUtil.APP.error("预期结果:"+expectedresults+" 测试结果:"+testnote);
|
luckyclient.publicclass.LogUtil.APP.error("预期结果:"+expectedresults+" 测试结果:"+testnote);
|
||||||
testnote = "用例第"+(i+1)+"步执行结果与预期结果匹配失败!预期结果:"+expectedresults+" 测试结果:"+testnote;
|
testnote = "用例第"+(i+1)+"步执行结果与预期结果匹配失败!预期结果:"+expectedresults+" 测试结果:"+testnote;
|
||||||
break; //某一步骤失败后,此条用例置为失败退出
|
break; //某一步骤失败后,此条用例置为失败退出
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int waitsec = Integer.parseInt(casescript.get("StepWait").toString()); //获取步骤间等待时间
|
int waitsec = Integer.parseInt(casescript.get("StepWait").toString());
|
||||||
if(waitsec!=0){
|
if(waitsec!=0){
|
||||||
Thread.sleep(waitsec*1000);
|
Thread.sleep(waitsec*1000);
|
||||||
}
|
}
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
luckyclient.publicclass.LogUtil.APP.error("调用方法过程出错,方法名:"+functionname+" 请重新检查脚本方法名称以及参数!");
|
luckyclient.publicclass.LogUtil.APP.error("调用方法过程出错,方法名:"+functionname+" 请重新检查脚本方法名称以及参数!");
|
||||||
caselog.UpdateCaseLogDetail(testCaseExternalId, tastid, "调用方法过程出错,方法名:"+functionname+" 请重新检查脚本方法名称以及参数!", "error",String.valueOf(i+1));
|
LogOperation.updateCaseLogDetail(testCaseExternalId, tastid, "调用方法过程出错,方法名:"+functionname+" 请重新检查脚本方法名称以及参数!", "error",String.valueOf(i+1));
|
||||||
luckyclient.publicclass.LogUtil.APP.error(e,e);
|
luckyclient.publicclass.LogUtil.APP.error(e,e);
|
||||||
testnote = "CallCase调用出错!";
|
testnote = "CallCase调用出错!";
|
||||||
setresult = 1;
|
setresult = 1;
|
||||||
|
@ -226,28 +237,28 @@ public class TestLinkCaseExecution{
|
||||||
//如果调用方法过程中未出错,进入设置测试结果流程
|
//如果调用方法过程中未出错,进入设置测试结果流程
|
||||||
if(testnote.indexOf("CallCase调用出错!")<=-1&&testnote.indexOf("解析出错啦!")<=-1){
|
if(testnote.indexOf("CallCase调用出错!")<=-1&&testnote.indexOf("解析出错啦!")<=-1){
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例 "+testCaseExternalId+"解析成功,并成功调用用例中方法,请继续查看执行结果!");
|
luckyclient.publicclass.LogUtil.APP.info("用例 "+testCaseExternalId+"解析成功,并成功调用用例中方法,请继续查看执行结果!");
|
||||||
caselog.UpdateCaseLogDetail(testCaseExternalId, tastid, "解析成功,并成功调用用例中方法,请继续查看执行结果!", "info","SETCASERESULT...");
|
LogOperation.updateCaseLogDetail(testCaseExternalId, tastid, "解析成功,并成功调用用例中方法,请继续查看执行结果!", "info","SETCASERESULT...");
|
||||||
//TCResult = TestCaseApi.setTCResult(projectname,testCaseExternalId, testnote, version,setresult);
|
//TCResult = TestCaseApi.setTCResult(projectname,testCaseExternalId, testnote, version,setresult);
|
||||||
caselog.UpdateCaseDetail(tastid, testCaseExternalId, setresult);
|
caselog.updateCaseDetail(tastid, testCaseExternalId, setresult);
|
||||||
}else{
|
}else{
|
||||||
setresult = 1;
|
setresult = 1;
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例 "+testCaseExternalId+"解析或是调用步骤中的方法出错!");
|
luckyclient.publicclass.LogUtil.APP.error("用例 "+testCaseExternalId+"解析或是调用步骤中的方法出错!");
|
||||||
caselog.UpdateCaseLogDetail(testCaseExternalId, tastid, "解析或是调用步骤中的方法出错!", "error","SETCASERESULT...");
|
LogOperation.updateCaseLogDetail(testCaseExternalId, tastid, "解析或是调用步骤中的方法出错!", "error","SETCASERESULT...");
|
||||||
// TCResult = TestCaseApi.setTCResult(projectname,testCaseExternalId, testnote, version,2);
|
// TCResult = TestCaseApi.setTCResult(projectname,testCaseExternalId, testnote, version,2);
|
||||||
caselog.UpdateCaseDetail(tastid, testCaseExternalId, 2);
|
caselog.updateCaseDetail(tastid, testCaseExternalId, 2);
|
||||||
}
|
}
|
||||||
if(0==setresult){
|
if(0==setresult){
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例 "+testCaseExternalId+"步骤全部执行成功!");
|
luckyclient.publicclass.LogUtil.APP.info("用例 "+testCaseExternalId+"步骤全部执行成功!");
|
||||||
caselog.UpdateCaseLogDetail(testCaseExternalId, tastid, "步骤全部执行成功!", "info","EXECUTECASESUC...");
|
LogOperation.updateCaseLogDetail(testCaseExternalId, tastid, "步骤全部执行成功!", "info","EXECUTECASESUC...");
|
||||||
}else{
|
}else{
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例 "+testCaseExternalId+"在执行过程中失败,请检查日志!");
|
luckyclient.publicclass.LogUtil.APP.error("用例 "+testCaseExternalId+"在执行过程中失败,请检查日志!");
|
||||||
caselog.UpdateCaseLogDetail(testCaseExternalId, tastid, "在执行过程中失败,请检查日志!", "error","EXECUTECASESUC...");
|
LogOperation.updateCaseLogDetail(testCaseExternalId, tastid, "在执行过程中失败,请检查日志!", "error","EXECUTECASESUC...");
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例 "+testCaseExternalId+"不是一个自动化的用例哦!先去把它设置一下吧!");
|
luckyclient.publicclass.LogUtil.APP.error("用例 "+testCaseExternalId+"不是一个自动化的用例哦!先去把它设置一下吧!");
|
||||||
caselog.UpdateCaseLogDetail(testCaseExternalId, tastid, "不是一个自动化的用例哦!先去把它设置一下吧!", "error","EXECUTECASEFAIL...");
|
LogOperation.updateCaseLogDetail(testCaseExternalId, tastid, "不是一个自动化的用例哦!先去把它设置一下吧!", "error","EXECUTECASEFAIL...");
|
||||||
}
|
}
|
||||||
LogOperation.UpdateTastdetail(tastid, 0);
|
LogOperation.updateTastdetail(tastid, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -257,7 +268,7 @@ public class TestLinkCaseExecution{
|
||||||
* @param 用例版本号
|
* @param 用例版本号
|
||||||
* 用于在UI的测试过程中,需要调用接口的测试用例
|
* 用于在UI的测试过程中,需要调用接口的测试用例
|
||||||
*/
|
*/
|
||||||
protected static String OneCaseExecuteForWebDriver(String testCaseExternalId,int version,String tastid,LogOperation caselog){
|
protected static String oneCaseExecuteForWebDriver(String testCaseExternalId,int version,String tastid,LogOperation caselog){
|
||||||
Map<String,String> variable = new HashMap<String,String>();
|
Map<String,String> variable = new HashMap<String,String>();
|
||||||
String packagename =null;
|
String packagename =null;
|
||||||
String functionname = null;
|
String functionname = null;
|
||||||
|
@ -270,7 +281,7 @@ public class TestLinkCaseExecution{
|
||||||
if(testcaseob.getExecutionType()==ExecutionType.AUTOMATED){
|
if(testcaseob.getExecutionType()==ExecutionType.AUTOMATED){
|
||||||
//进入循环,解析用例所有步骤
|
//进入循环,解析用例所有步骤
|
||||||
for(int i=0;i<testcaseob.getSteps().size();i++){
|
for(int i=0;i<testcaseob.getSteps().size();i++){
|
||||||
Map<String,String> casescript = InterfaceAnalyticTestLinkCase.AnalyticCaseStep(testcaseob, i+1,tastid,caselog); //解析单个步骤中的脚本
|
Map<String,String> casescript = InterfaceAnalyticTestLinkCase.analyticCaseStep(testcaseob, i+1,tastid,caselog);
|
||||||
packagename = casescript.get("PackageName").toString();
|
packagename = casescript.get("PackageName").toString();
|
||||||
functionname = casescript.get("FunctionName").toString();
|
functionname = casescript.get("FunctionName").toString();
|
||||||
//用例名称解析出现异常或是单个步骤参数解析异常
|
//用例名称解析出现异常或是单个步骤参数解析异常
|
||||||
|
@ -279,22 +290,22 @@ public class TestLinkCaseExecution{
|
||||||
testnote = "用例第"+(i+1)+"步解析出错啦!";
|
testnote = "用例第"+(i+1)+"步解析出错啦!";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
expectedresults = casescript.get("ExpectedResults").toString(); //预期结果
|
expectedresults = casescript.get("ExpectedResults").toString();
|
||||||
if(expectedresults.indexOf(""")>-1||expectedresults.indexOf("'")>-1){ //页面转义字符转换
|
if(expectedresults.indexOf(""")>-1||expectedresults.indexOf("'")>-1){
|
||||||
expectedresults = expectedresults.replaceAll(""", "\"");
|
expectedresults = expectedresults.replaceAll(""", "\"");
|
||||||
expectedresults = expectedresults.replaceAll("'", "\'");
|
expectedresults = expectedresults.replaceAll("'", "\'");
|
||||||
}
|
}
|
||||||
//判断方法是否带参数
|
//判断方法是否带参数
|
||||||
if(casescript.size()>4){
|
if(casescript.size()>4){
|
||||||
//获取传入参数,放入对象中
|
//获取传入参数,放入对象中
|
||||||
getParameterValues = new Object[casescript.size()-4]; //初始化参数对象个数
|
getParameterValues = new Object[casescript.size()-4];
|
||||||
for(int j=0;j<casescript.size()-4;j++){
|
for(int j=0;j<casescript.size()-4;j++){
|
||||||
if(casescript.get("FunctionParams"+(j+1))==null){
|
if(casescript.get("FunctionParams"+(j+1))==null){
|
||||||
k = 1;
|
k = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(casescript.get("FunctionParams"+(j+1)).indexOf("@")>-1
|
if(casescript.get("FunctionParams"+(j+1)).indexOf("@")>-1
|
||||||
&&casescript.get("FunctionParams"+(j+1)).indexOf("@@")<0){ //如果存在传参,进行处理
|
&&casescript.get("FunctionParams"+(j+1)).indexOf("@@")<0){
|
||||||
int keyexistidentity = 0;
|
int keyexistidentity = 0;
|
||||||
//取单个参数中引用变量次数
|
//取单个参数中引用变量次数
|
||||||
int sumvariable = DBOperation.sumString(casescript.get("FunctionParams"+(j+1)), "@");
|
int sumvariable = DBOperation.sumString(casescript.get("FunctionParams"+(j+1)), "@");
|
||||||
|
@ -305,7 +316,7 @@ public class TestLinkCaseExecution{
|
||||||
if(sumvariable==1){
|
if(sumvariable==1){
|
||||||
uservariable = casescript.get("FunctionParams"+(j+1)).substring(
|
uservariable = casescript.get("FunctionParams"+(j+1)).substring(
|
||||||
casescript.get("FunctionParams"+(j+1)).indexOf("@")+1);
|
casescript.get("FunctionParams"+(j+1)).indexOf("@")+1);
|
||||||
}else if(sumvariable==2){ //单个参数中引用第二个变量
|
}else if(sumvariable==2){
|
||||||
uservariable = casescript.get("FunctionParams"+(j+1)).substring(casescript.get("FunctionParams"+(j+1)).indexOf("@")+1,
|
uservariable = casescript.get("FunctionParams"+(j+1)).substring(casescript.get("FunctionParams"+(j+1)).indexOf("@")+1,
|
||||||
casescript.get("FunctionParams"+(j+1)).lastIndexOf("@"));
|
casescript.get("FunctionParams"+(j+1)).lastIndexOf("@"));
|
||||||
uservariable1 = casescript.get("FunctionParams"+(j+1)).substring(
|
uservariable1 = casescript.get("FunctionParams"+(j+1)).substring(
|
||||||
|
@ -332,7 +343,7 @@ public class TestLinkCaseExecution{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(sumvariable==2||sumvariable==3){ //处理第二个传参
|
if(sumvariable==2||sumvariable==3){
|
||||||
keys = variable.keySet().iterator();
|
keys = variable.keySet().iterator();
|
||||||
while(keys.hasNext()){
|
while(keys.hasNext()){
|
||||||
keyexistidentity = 0;
|
keyexistidentity = 0;
|
||||||
|
@ -344,7 +355,7 @@ public class TestLinkCaseExecution{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(sumvariable==3){ //处理第三个传参
|
if(sumvariable==3){
|
||||||
keys = variable.keySet().iterator();
|
keys = variable.keySet().iterator();
|
||||||
while(keys.hasNext()){
|
while(keys.hasNext()){
|
||||||
keyexistidentity = 0;
|
keyexistidentity = 0;
|
||||||
|
@ -358,37 +369,37 @@ public class TestLinkCaseExecution{
|
||||||
}
|
}
|
||||||
if(keyexistidentity == 1){
|
if(keyexistidentity == 1){
|
||||||
//拼装参数(传参+原有字符串)
|
//拼装参数(传参+原有字符串)
|
||||||
String ParameterValues =casescript.get("FunctionParams"+(j+1)).replaceAll("@"+uservariable, variable.get(uservariable).toString());
|
String parameterValues =casescript.get("FunctionParams"+(j+1)).replaceAll("@"+uservariable, variable.get(uservariable).toString());
|
||||||
//处理第二个传参
|
//处理第二个传参
|
||||||
if(sumvariable==2||sumvariable==3){
|
if(sumvariable==2||sumvariable==3){
|
||||||
ParameterValues = ParameterValues.replaceAll("@"+uservariable1, variable.get(uservariable1).toString());
|
parameterValues = parameterValues.replaceAll("@"+uservariable1, variable.get(uservariable1).toString());
|
||||||
}
|
}
|
||||||
//处理第三个传参
|
//处理第三个传参
|
||||||
if(sumvariable==3){
|
if(sumvariable==3){
|
||||||
ParameterValues = ParameterValues.replaceAll("@"+uservariable2, variable.get(uservariable2).toString());
|
parameterValues = parameterValues.replaceAll("@"+uservariable2, variable.get(uservariable2).toString());
|
||||||
}
|
}
|
||||||
if(ParameterValues.indexOf(""")>-1 || ParameterValues.indexOf("'")>-1){ //页面转义字符转换
|
if(parameterValues.indexOf(""")>-1 || parameterValues.indexOf("'")>-1){
|
||||||
ParameterValues = ParameterValues.replaceAll(""", "\"");
|
parameterValues = parameterValues.replaceAll(""", "\"");
|
||||||
ParameterValues = ParameterValues.replaceAll("'", "\'");
|
parameterValues = parameterValues.replaceAll("'", "\'");
|
||||||
}
|
}
|
||||||
luckyclient.publicclass.LogUtil.APP.info("解析包名:"+packagename+" 方法名:"+functionname
|
luckyclient.publicclass.LogUtil.APP.info("解析包名:"+packagename+" 方法名:"+functionname
|
||||||
+" 第"+(j+1)+"个参数:"+ParameterValues);
|
+" 第"+(j+1)+"个参数:"+parameterValues);
|
||||||
getParameterValues[j] = ParameterValues;
|
getParameterValues[j] = parameterValues;
|
||||||
}else{
|
}else{
|
||||||
luckyclient.publicclass.LogUtil.APP.error("没有找到你要的变量哦,再找下吧!第一个变量名称是:"+uservariable+",第"
|
luckyclient.publicclass.LogUtil.APP.error("没有找到你要的变量哦,再找下吧!第一个变量名称是:"+uservariable+",第"
|
||||||
+ "二个变量名称是:"+uservariable1+",第三个变量名称是:"+uservariable2);
|
+ "二个变量名称是:"+uservariable1+",第三个变量名称是:"+uservariable2);
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
String ParameterValues1 = casescript.get("FunctionParams"+(j+1));
|
String parameterValues1 = casescript.get("FunctionParams"+(j+1));
|
||||||
if(ParameterValues1.indexOf(""")>-1 || ParameterValues1.indexOf("'")>-1 || ParameterValues1.indexOf("@@")>-1){ //页面转义字符转换
|
if(parameterValues1.indexOf(""")>-1 || parameterValues1.indexOf("'")>-1 || parameterValues1.indexOf("@@")>-1){
|
||||||
ParameterValues1 = ParameterValues1.replaceAll(""", "\"");
|
parameterValues1 = parameterValues1.replaceAll(""", "\"");
|
||||||
ParameterValues1 = ParameterValues1.replaceAll("'", "\'");
|
parameterValues1 = parameterValues1.replaceAll("'", "\'");
|
||||||
ParameterValues1 = ParameterValues1.replaceAll("@@", "@");
|
parameterValues1 = parameterValues1.replaceAll("@@", "@");
|
||||||
}
|
}
|
||||||
luckyclient.publicclass.LogUtil.APP.info("解析包名:"+packagename+" 方法名:"+functionname
|
luckyclient.publicclass.LogUtil.APP.info("解析包名:"+packagename+" 方法名:"+functionname
|
||||||
+" 第"+(j+1)+"个参数:"+ParameterValues1);
|
+" 第"+(j+1)+"个参数:"+parameterValues1);
|
||||||
getParameterValues[j] = ParameterValues1;
|
getParameterValues[j] = parameterValues1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
@ -397,12 +408,12 @@ public class TestLinkCaseExecution{
|
||||||
//调用动态方法,执行测试用例
|
//调用动态方法,执行测试用例
|
||||||
try{
|
try{
|
||||||
luckyclient.publicclass.LogUtil.APP.info("开始调用方法:"+functionname+" .....");
|
luckyclient.publicclass.LogUtil.APP.info("开始调用方法:"+functionname+" .....");
|
||||||
if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("$=")>-1){ //把预期结果前两个字符判断是否是要把结果存入变量
|
if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("$=")>-1){
|
||||||
String ExpectedResultVariable = casescript.get("ExpectedResults").toString().substring(2);
|
String expectedResultVariable = casescript.get("ExpectedResults").toString().substring(2);
|
||||||
String temptestnote = InvokeMethod.CallCase(packagename,functionname,getParameterValues,0,"");
|
String temptestnote = InvokeMethod.callCase(packagename,functionname,getParameterValues,0,"");
|
||||||
variable.put(ExpectedResultVariable, temptestnote);
|
variable.put(expectedResultVariable, temptestnote);
|
||||||
}else if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("%=")>-1){ //把预期结果与测试结果做模糊匹配
|
}else if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("%=")>-1){
|
||||||
testnote = InvokeMethod.CallCase(packagename,functionname,getParameterValues,0,"");
|
testnote = InvokeMethod.callCase(packagename,functionname,getParameterValues,0,"");
|
||||||
if(testnote.indexOf(expectedresults.substring(2))>-1){
|
if(testnote.indexOf(expectedresults.substring(2))>-1){
|
||||||
setresult = 0;
|
setresult = 0;
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例执行结果是:"+testnote+",与预期结果匹配成功!");
|
luckyclient.publicclass.LogUtil.APP.info("用例执行结果是:"+testnote+",与预期结果匹配成功!");
|
||||||
|
@ -414,7 +425,7 @@ public class TestLinkCaseExecution{
|
||||||
break; //某一步骤失败后,此条用例置为失败退出
|
break; //某一步骤失败后,此条用例置为失败退出
|
||||||
}
|
}
|
||||||
}else{ //把预期结果与测试结果做精确匹配
|
}else{ //把预期结果与测试结果做精确匹配
|
||||||
testnote = InvokeMethod.CallCase(packagename,functionname,getParameterValues,0,"");
|
testnote = InvokeMethod.callCase(packagename,functionname,getParameterValues,0,"");
|
||||||
if("".equals(expectedresults)||testnote.equals(expectedresults)){
|
if("".equals(expectedresults)||testnote.equals(expectedresults)){
|
||||||
setresult = 0;
|
setresult = 0;
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例执行结果是:"+testnote+",与预期结果匹配成功!");
|
luckyclient.publicclass.LogUtil.APP.info("用例执行结果是:"+testnote+",与预期结果匹配成功!");
|
||||||
|
@ -426,7 +437,7 @@ public class TestLinkCaseExecution{
|
||||||
break; //某一步骤失败后,此条用例置为失败退出
|
break; //某一步骤失败后,此条用例置为失败退出
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int waitsec = Integer.parseInt(casescript.get("StepWait").toString()); //获取步骤间等待时间
|
int waitsec = Integer.parseInt(casescript.get("StepWait").toString());
|
||||||
if(waitsec!=0){
|
if(waitsec!=0){
|
||||||
Thread.sleep(waitsec*1000);
|
Thread.sleep(waitsec*1000);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,17 @@ package luckyclient.caserun.exinterface.testlink;
|
||||||
|
|
||||||
import luckyclient.caserun.exinterface.TestControl;
|
import luckyclient.caserun.exinterface.TestControl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class ThreadForTestLinkBatchCase extends Thread{
|
public class ThreadForTestLinkBatchCase extends Thread{
|
||||||
|
|
||||||
private String projectname;
|
private String projectname;
|
||||||
|
@ -16,8 +27,9 @@ public class ThreadForTestLinkBatchCase extends Thread{
|
||||||
this.tastid = tastid;
|
this.tastid = tastid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void run(){
|
public void run(){
|
||||||
TestLinkCaseExecution.OneCaseExecuteForTast(projectname, testCaseExternalId, version, tastid);
|
TestLinkCaseExecution.oneCaseExecuteForTast(projectname, testCaseExternalId, version, tastid);
|
||||||
TestControl.Debugcount--; //多线程计数--,用于检测线程是否全部执行完
|
TestControl.Debugcount--; //多线程计数--,用于检测线程是否全部执行完
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,8 @@ import luckyclient.testlinkapi.InterfaceAnalyticTestLinkCase;
|
||||||
/**
|
/**
|
||||||
* =================================================================
|
* =================================================================
|
||||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
* 此测试框架主要采用testlink做分层框架,负责数据驱动以及用例管理部分,有任何疑问欢迎联系作者讨论。
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
* QQ:24163551 seagull1985
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
* =================================================================
|
* =================================================================
|
||||||
* @ClassName: ThreadForExecuteCase
|
* @ClassName: ThreadForExecuteCase
|
||||||
* @Description: 线程池方式执行用例
|
* @Description: 线程池方式执行用例
|
||||||
|
@ -33,6 +33,7 @@ public class ThreadForTestLinkExecuteCase extends Thread{
|
||||||
this.tastid = tastid;
|
this.tastid = tastid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void run(){
|
public void run(){
|
||||||
Map<String,String> variable = new HashMap<String,String>();
|
Map<String,String> variable = new HashMap<String,String>();
|
||||||
LogOperation caselog = new LogOperation(); //初始化写用例结果以及日志模块
|
LogOperation caselog = new LogOperation(); //初始化写用例结果以及日志模块
|
||||||
|
@ -45,16 +46,16 @@ public class ThreadForTestLinkExecuteCase extends Thread{
|
||||||
int k = 0;
|
int k = 0;
|
||||||
//进入循环,解析单个用例所有步骤
|
//进入循环,解析单个用例所有步骤
|
||||||
System.out.println(caseid);
|
System.out.println(caseid);
|
||||||
caselog.AddCaseDetail(tastid, testcaseob.getFullExternalId(), testcaseob.getVersion().toString(), testcaseob.getName(), 4); //插入开始执行的用例
|
caselog.addCaseDetail(tastid, testcaseob.getFullExternalId(), testcaseob.getVersion().toString(), testcaseob.getName(), 4); //插入开始执行的用例
|
||||||
for(int i=0;i<testcaseob.getSteps().size();i++){
|
for(int i=0;i<testcaseob.getSteps().size();i++){
|
||||||
Map<String,String> casescript = InterfaceAnalyticTestLinkCase.AnalyticCaseStep(testcaseob, i+1,tastid,caselog); //解析单个步骤中的脚本
|
Map<String,String> casescript = InterfaceAnalyticTestLinkCase.analyticCaseStep(testcaseob, i+1,tastid,caselog); //解析单个步骤中的脚本
|
||||||
try{
|
try{
|
||||||
packagename = casescript.get("PackageName").toString();
|
packagename = casescript.get("PackageName").toString();
|
||||||
functionname = casescript.get("FunctionName").toString();
|
functionname = casescript.get("FunctionName").toString();
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
k=0;
|
k=0;
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例:"+testcaseob.getFullExternalId()+"解析包名或是方法名失败,请检查!");
|
luckyclient.publicclass.LogUtil.APP.error("用例:"+testcaseob.getFullExternalId()+"解析包名或是方法名失败,请检查!");
|
||||||
caselog.CaseLogDetail(tastid, caseid, "解析包名或是方法名失败,请检查!","error",String.valueOf(i+1),"");
|
caselog.caseLogDetail(tastid, caseid, "解析包名或是方法名失败,请检查!","error",String.valueOf(i+1),"");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
break; //某一步骤失败后,此条用例置为失败退出
|
break; //某一步骤失败后,此条用例置为失败退出
|
||||||
}
|
}
|
||||||
|
@ -105,7 +106,7 @@ public class ThreadForTestLinkExecuteCase extends Thread{
|
||||||
casescript.get("FunctionParams"+(j+1)).indexOf(uservariable1)-1);
|
casescript.get("FunctionParams"+(j+1)).indexOf(uservariable1)-1);
|
||||||
}else{
|
}else{
|
||||||
luckyclient.publicclass.LogUtil.APP.error("你好像在一个参数中引用了超过3个以上的变量哦!我处理不过来啦!");
|
luckyclient.publicclass.LogUtil.APP.error("你好像在一个参数中引用了超过3个以上的变量哦!我处理不过来啦!");
|
||||||
caselog.CaseLogDetail(tastid, caseid, "你好像在一个参数中引用了超过2个以上的变量哦!我处理不过来啦!","error",String.valueOf(i+1),"");
|
caselog.caseLogDetail(tastid, caseid, "你好像在一个参数中引用了超过2个以上的变量哦!我处理不过来啦!","error",String.valueOf(i+1),"");
|
||||||
}
|
}
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
Iterator keys = variable.keySet().iterator();
|
Iterator keys = variable.keySet().iterator();
|
||||||
|
@ -144,43 +145,43 @@ public class ThreadForTestLinkExecuteCase extends Thread{
|
||||||
}
|
}
|
||||||
if(keyexistidentity == 1){
|
if(keyexistidentity == 1){
|
||||||
//拼装参数(传参+原有字符串)
|
//拼装参数(传参+原有字符串)
|
||||||
String ParameterValues =casescript.get("FunctionParams"+(j+1)).replaceAll("@"+uservariable, variable.get(uservariable).toString());
|
String parameterValues =casescript.get("FunctionParams"+(j+1)).replaceAll("@"+uservariable, variable.get(uservariable).toString());
|
||||||
//处理第二个传参
|
//处理第二个传参
|
||||||
if(sumvariable==2||sumvariable==3){
|
if(sumvariable==2||sumvariable==3){
|
||||||
ParameterValues = ParameterValues.replaceAll("@"+uservariable1, variable.get(uservariable1).toString());
|
parameterValues = parameterValues.replaceAll("@"+uservariable1, variable.get(uservariable1).toString());
|
||||||
}
|
}
|
||||||
//处理第三个传参
|
//处理第三个传参
|
||||||
if(sumvariable==3){
|
if(sumvariable==3){
|
||||||
ParameterValues = ParameterValues.replaceAll("@"+uservariable2, variable.get(uservariable2).toString());
|
parameterValues = parameterValues.replaceAll("@"+uservariable2, variable.get(uservariable2).toString());
|
||||||
}
|
}
|
||||||
if(ParameterValues.indexOf(""")>-1 || ParameterValues.indexOf("'")>-1){ //页面转义字符转换
|
if(parameterValues.indexOf(""")>-1 || parameterValues.indexOf("'")>-1){ //页面转义字符转换
|
||||||
ParameterValues = ParameterValues.replaceAll(""", "\"");
|
parameterValues = parameterValues.replaceAll(""", "\"");
|
||||||
ParameterValues = ParameterValues.replaceAll("'", "\'");
|
parameterValues = parameterValues.replaceAll("'", "\'");
|
||||||
}
|
}
|
||||||
luckyclient.publicclass.LogUtil.APP.info("解析包名:"+packagename+" 方法名:"+functionname
|
luckyclient.publicclass.LogUtil.APP.info("解析包名:"+packagename+" 方法名:"+functionname
|
||||||
+" 第"+(j+1)+"个参数:"+ParameterValues);
|
+" 第"+(j+1)+"个参数:"+parameterValues);
|
||||||
caselog.CaseLogDetail(tastid, caseid, "解析包名:"+packagename+" 方法名:"+functionname
|
caselog.caseLogDetail(tastid, caseid, "解析包名:"+packagename+" 方法名:"+functionname
|
||||||
+" 第"+(j+1)+"个参数:"+ParameterValues,"info",String.valueOf(i+1),"");
|
+" 第"+(j+1)+"个参数:"+parameterValues,"info",String.valueOf(i+1),"");
|
||||||
getParameterValues[j] = ParameterValues;
|
getParameterValues[j] = parameterValues;
|
||||||
}else{
|
}else{
|
||||||
luckyclient.publicclass.LogUtil.APP.error("没有找到你要的变量哦,再找下吧!第一个变量名称是:"+uservariable+",第"
|
luckyclient.publicclass.LogUtil.APP.error("没有找到你要的变量哦,再找下吧!第一个变量名称是:"+uservariable+",第"
|
||||||
+ "二个变量名称是:"+uservariable1+",第三个变量名称是:"+uservariable2);
|
+ "二个变量名称是:"+uservariable1+",第三个变量名称是:"+uservariable2);
|
||||||
caselog.CaseLogDetail(tastid, caseid, "没有找到你要的变量哦,再找下吧!第二变量名称是:"+uservariable+",第"
|
caselog.caseLogDetail(tastid, caseid, "没有找到你要的变量哦,再找下吧!第二变量名称是:"+uservariable+",第"
|
||||||
+ "二个变量名称是:"+uservariable1,"error",String.valueOf(i+1),"");
|
+ "二个变量名称是:"+uservariable1,"error",String.valueOf(i+1),"");
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
String ParameterValues1 = casescript.get("FunctionParams"+(j+1));
|
String parameterValues1 = casescript.get("FunctionParams"+(j+1));
|
||||||
if(ParameterValues1.indexOf(""")>-1 || ParameterValues1.indexOf("'")>-1 || ParameterValues1.indexOf("@@")>-1){ //页面转义字符转换
|
if(parameterValues1.indexOf(""")>-1 || parameterValues1.indexOf("'")>-1 || parameterValues1.indexOf("@@")>-1){ //页面转义字符转换
|
||||||
ParameterValues1 = ParameterValues1.replaceAll(""", "\"");
|
parameterValues1 = parameterValues1.replaceAll(""", "\"");
|
||||||
ParameterValues1 = ParameterValues1.replaceAll("'", "\'");
|
parameterValues1 = parameterValues1.replaceAll("'", "\'");
|
||||||
ParameterValues1 = ParameterValues1.replaceAll("@@", "@");
|
parameterValues1 = parameterValues1.replaceAll("@@", "@");
|
||||||
}
|
}
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例:"+testcaseob.getFullExternalId()+"解析包名:"+packagename+" 方法名:"+functionname
|
luckyclient.publicclass.LogUtil.APP.info("用例:"+testcaseob.getFullExternalId()+"解析包名:"+packagename+" 方法名:"+functionname
|
||||||
+" 第"+(j+1)+"个参数:"+ParameterValues1);
|
+" 第"+(j+1)+"个参数:"+parameterValues1);
|
||||||
caselog.CaseLogDetail(tastid, caseid,"解析包名:"+packagename+" 方法名:"+functionname
|
caselog.caseLogDetail(tastid, caseid,"解析包名:"+packagename+" 方法名:"+functionname
|
||||||
+" 第"+(j+1)+"个参数:"+ParameterValues1,"info",String.valueOf(i+1),"");
|
+" 第"+(j+1)+"个参数:"+parameterValues1,"info",String.valueOf(i+1),"");
|
||||||
getParameterValues[j] = ParameterValues1;
|
getParameterValues[j] = parameterValues1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
@ -189,36 +190,36 @@ public class ThreadForTestLinkExecuteCase extends Thread{
|
||||||
//调用动态方法,执行测试用例
|
//调用动态方法,执行测试用例
|
||||||
try{
|
try{
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例:"+testcaseob.getFullExternalId()+"开始调用方法:"+functionname+" .....");
|
luckyclient.publicclass.LogUtil.APP.info("用例:"+testcaseob.getFullExternalId()+"开始调用方法:"+functionname+" .....");
|
||||||
caselog.CaseLogDetail(tastid, caseid,"开始调用方法:"+functionname+" .....","info",String.valueOf(i+1),"");
|
caselog.caseLogDetail(tastid, caseid,"开始调用方法:"+functionname+" .....","info",String.valueOf(i+1),"");
|
||||||
if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("$=")>-1){ //把预期结果前两个字符判断是否是要把结果存入变量
|
if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("$=")>-1){ //把预期结果前两个字符判断是否是要把结果存入变量
|
||||||
String ExpectedResultVariable = casescript.get("ExpectedResults").toString().substring(2);
|
String expectedResultVariable = casescript.get("ExpectedResults").toString().substring(2);
|
||||||
String temptestnote = InvokeMethod.CallCase(packagename,functionname,getParameterValues,0,"");
|
String temptestnote = InvokeMethod.callCase(packagename,functionname,getParameterValues,0,"");
|
||||||
variable.put(ExpectedResultVariable, temptestnote);
|
variable.put(expectedResultVariable, temptestnote);
|
||||||
}else if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("%=")>-1){ //把预期结果与测试结果做模糊匹配
|
}else if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("%=")>-1){ //把预期结果与测试结果做模糊匹配
|
||||||
testnote = InvokeMethod.CallCase(packagename,functionname,getParameterValues,0,"");
|
testnote = InvokeMethod.callCase(packagename,functionname,getParameterValues,0,"");
|
||||||
if(testnote.indexOf(expectedresults.substring(2))>-1){
|
if(testnote.indexOf(expectedresults.substring(2))>-1){
|
||||||
setresult = 0;
|
setresult = 0;
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例:"+testcaseob.getFullExternalId()+"执行结果是:"+testnote+",与预期结果匹配成功!");
|
luckyclient.publicclass.LogUtil.APP.info("用例:"+testcaseob.getFullExternalId()+"执行结果是:"+testnote+",与预期结果匹配成功!");
|
||||||
caselog.CaseLogDetail(tastid, caseid,"执行结果是:"+testnote+",与预期结果匹配成功!","info",String.valueOf(i+1),"");
|
caselog.caseLogDetail(tastid, caseid,"执行结果是:"+testnote+",与预期结果匹配成功!","info",String.valueOf(i+1),"");
|
||||||
}else{
|
}else{
|
||||||
setresult = 1;
|
setresult = 1;
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例:"+testcaseob.getFullExternalId()+"第"+(i+1)+"步执行结果与预期结果匹配失败!");
|
luckyclient.publicclass.LogUtil.APP.error("用例:"+testcaseob.getFullExternalId()+"第"+(i+1)+"步执行结果与预期结果匹配失败!");
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例:"+testcaseob.getFullExternalId()+"预期结果:"+expectedresults+" 测试结果:"+testnote);
|
luckyclient.publicclass.LogUtil.APP.error("用例:"+testcaseob.getFullExternalId()+"预期结果:"+expectedresults+" 测试结果:"+testnote);
|
||||||
caselog.CaseLogDetail(tastid, caseid,"第"+(i+1)+"步执行结果与预期结果匹配失败!"+"预期结果:"+expectedresults+" 测试结果:"+testnote,"error",String.valueOf(i+1),"");
|
caselog.caseLogDetail(tastid, caseid,"第"+(i+1)+"步执行结果与预期结果匹配失败!"+"预期结果:"+expectedresults+" 测试结果:"+testnote,"error",String.valueOf(i+1),"");
|
||||||
testnote = "用例第"+(i+1)+"步执行结果与预期结果匹配失败!";
|
testnote = "用例第"+(i+1)+"步执行结果与预期结果匹配失败!";
|
||||||
break; //某一步骤失败后,此条用例置为失败退出
|
break; //某一步骤失败后,此条用例置为失败退出
|
||||||
}
|
}
|
||||||
}else{ //把预期结果与测试结果做精确匹配
|
}else{ //把预期结果与测试结果做精确匹配
|
||||||
testnote = InvokeMethod.CallCase(packagename,functionname,getParameterValues,0,"");
|
testnote = InvokeMethod.callCase(packagename,functionname,getParameterValues,0,"");
|
||||||
if(expectedresults.equals(testnote)){
|
if(expectedresults.equals(testnote)){
|
||||||
setresult = 0;
|
setresult = 0;
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例:"+testcaseob.getFullExternalId()+"执行结果是:"+testnote+",与预期结果匹配成功!");
|
luckyclient.publicclass.LogUtil.APP.info("用例:"+testcaseob.getFullExternalId()+"执行结果是:"+testnote+",与预期结果匹配成功!");
|
||||||
caselog.CaseLogDetail(tastid, caseid,"执行结果是:"+testnote+",与预期结果匹配成功!","info",String.valueOf(i+1),"");
|
caselog.caseLogDetail(tastid, caseid,"执行结果是:"+testnote+",与预期结果匹配成功!","info",String.valueOf(i+1),"");
|
||||||
}else{
|
}else{
|
||||||
setresult = 1;
|
setresult = 1;
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例:"+testcaseob.getFullExternalId()+"第"+(i+1)+"步执行结果与预期结果匹配失败!");
|
luckyclient.publicclass.LogUtil.APP.error("用例:"+testcaseob.getFullExternalId()+"第"+(i+1)+"步执行结果与预期结果匹配失败!");
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例:"+testcaseob.getFullExternalId()+"预期结果:"+expectedresults+" 测试结果:"+testnote);
|
luckyclient.publicclass.LogUtil.APP.error("用例:"+testcaseob.getFullExternalId()+"预期结果:"+expectedresults+" 测试结果:"+testnote);
|
||||||
caselog.CaseLogDetail(tastid, caseid,"第"+(i+1)+"步执行结果与预期结果匹配失败!"+"预期结果:"+expectedresults+" 测试结果:"+testnote,"error",String.valueOf(i+1),"");
|
caselog.caseLogDetail(tastid, caseid,"第"+(i+1)+"步执行结果与预期结果匹配失败!"+"预期结果:"+expectedresults+" 测试结果:"+testnote,"error",String.valueOf(i+1),"");
|
||||||
testnote = "用例第"+(i+1)+"步执行结果与预期结果匹配失败!预期结果:"+expectedresults+" 测试结果:"+testnote;
|
testnote = "用例第"+(i+1)+"步执行结果与预期结果匹配失败!预期结果:"+expectedresults+" 测试结果:"+testnote;
|
||||||
break; //某一步骤失败后,此条用例置为失败退出
|
break; //某一步骤失败后,此条用例置为失败退出
|
||||||
}
|
}
|
||||||
|
@ -229,7 +230,7 @@ public class ThreadForTestLinkExecuteCase extends Thread{
|
||||||
}
|
}
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
luckyclient.publicclass.LogUtil.ERROR.error("用例:"+testcaseob.getFullExternalId()+"调用方法过程出错,方法名:"+functionname+" 请重新检查脚本方法名称以及参数!");
|
luckyclient.publicclass.LogUtil.ERROR.error("用例:"+testcaseob.getFullExternalId()+"调用方法过程出错,方法名:"+functionname+" 请重新检查脚本方法名称以及参数!");
|
||||||
caselog.CaseLogDetail(tastid, caseid,"调用方法过程出错,方法名:"+functionname+" 请重新检查脚本方法名称以及参数!","error",String.valueOf(i+1),"");
|
caselog.caseLogDetail(tastid, caseid,"调用方法过程出错,方法名:"+functionname+" 请重新检查脚本方法名称以及参数!","error",String.valueOf(i+1),"");
|
||||||
luckyclient.publicclass.LogUtil.ERROR.error(e,e);
|
luckyclient.publicclass.LogUtil.ERROR.error(e,e);
|
||||||
testnote = "CallCase调用出错!调用方法过程出错,方法名:"+functionname+" 请重新检查脚本方法名称以及参数!";
|
testnote = "CallCase调用出错!调用方法过程出错,方法名:"+functionname+" 请重新检查脚本方法名称以及参数!";
|
||||||
setresult = 1;
|
setresult = 1;
|
||||||
|
@ -241,32 +242,32 @@ public class ThreadForTestLinkExecuteCase extends Thread{
|
||||||
try{
|
try{
|
||||||
if(testnote.indexOf("CallCase调用出错!")<=-1&&testnote.indexOf("解析出错啦!")<=-1){ //成功跟失败的用例走此流程
|
if(testnote.indexOf("CallCase调用出错!")<=-1&&testnote.indexOf("解析出错啦!")<=-1){ //成功跟失败的用例走此流程
|
||||||
//luckyclient.publicclass.LogUtil.APP.info("用例:"+testcaseob.getFullExternalId()+"开始设置测试用例执行结果 .....");
|
//luckyclient.publicclass.LogUtil.APP.info("用例:"+testcaseob.getFullExternalId()+"开始设置测试用例执行结果 .....");
|
||||||
//caselog.CaseLogDetail(tastid, caseid,"开始设置测试用例执行结果 .....","info","SETCASERESULT...");
|
//caselog.caseLogDetail(tastid, caseid,"开始设置测试用例执行结果 .....","info","SETCASERESULT...");
|
||||||
//TCResult = TestCaseApi.setTCResult(projectname,caseid, testnote, testcaseob.getVersion(),setresult);
|
//TCResult = TestCaseApi.setTCResult(projectname,caseid, testnote, testcaseob.getVersion(),setresult);
|
||||||
caselog.UpdateCaseDetail(tastid, caseid, setresult);
|
caselog.updateCaseDetail(tastid, caseid, setresult);
|
||||||
}else{
|
}else{
|
||||||
luckyclient.publicclass.LogUtil.ERROR.error("用例:"+testcaseob.getFullExternalId()+"设置执行结果为锁定,请参考错误日志查找锁定用例的原因....."); //解析用例或是调用方法出错,全部把用例置为锁定
|
luckyclient.publicclass.LogUtil.ERROR.error("用例:"+testcaseob.getFullExternalId()+"设置执行结果为锁定,请参考错误日志查找锁定用例的原因....."); //解析用例或是调用方法出错,全部把用例置为锁定
|
||||||
caselog.CaseLogDetail(tastid, caseid,"设置执行结果为锁定,请参考错误日志查找锁定用例的原因.....","error","SETCASERESULT...","");
|
caselog.caseLogDetail(tastid, caseid,"设置执行结果为锁定,请参考错误日志查找锁定用例的原因.....","error","SETCASERESULT...","");
|
||||||
//TCResult = TestCaseApi.setTCResult(projectname,caseid, testnote, testcaseob.getVersion(),2);
|
//TCResult = TestCaseApi.setTCResult(projectname,caseid, testnote, testcaseob.getVersion(),2);
|
||||||
setresult = 2;
|
setresult = 2;
|
||||||
caselog.UpdateCaseDetail(tastid, caseid, setresult);
|
caselog.updateCaseDetail(tastid, caseid, setresult);
|
||||||
}
|
}
|
||||||
if(setresult==0){
|
if(setresult==0){
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例:"+testcaseob.getFullExternalId()+"执行结果成功......");
|
luckyclient.publicclass.LogUtil.APP.info("用例:"+testcaseob.getFullExternalId()+"执行结果成功......");
|
||||||
caselog.CaseLogDetail(tastid, caseid,"用例步骤执行全部成功......","info","ending","");
|
caselog.caseLogDetail(tastid, caseid,"用例步骤执行全部成功......","info","ending","");
|
||||||
luckyclient.publicclass.LogUtil.APP.info("******************************分割线*************************************");
|
luckyclient.publicclass.LogUtil.APP.info("******************************分割线*************************************");
|
||||||
}else if(setresult==1){
|
}else if(setresult==1){
|
||||||
luckyclient.publicclass.LogUtil.ERROR.error("用例:"+testcaseob.getFullExternalId()+"执行结果失败......");
|
luckyclient.publicclass.LogUtil.ERROR.error("用例:"+testcaseob.getFullExternalId()+"执行结果失败......");
|
||||||
caselog.CaseLogDetail(tastid, caseid,"用例执行结果失败......","error","ending","");
|
caselog.caseLogDetail(tastid, caseid,"用例执行结果失败......","error","ending","");
|
||||||
luckyclient.publicclass.LogUtil.APP.info("******************************分割线*************************************");
|
luckyclient.publicclass.LogUtil.APP.info("******************************分割线*************************************");
|
||||||
}else{
|
}else{
|
||||||
luckyclient.publicclass.LogUtil.ERROR.error("用例:"+testcaseob.getFullExternalId()+"执行结果锁定......");
|
luckyclient.publicclass.LogUtil.ERROR.error("用例:"+testcaseob.getFullExternalId()+"执行结果锁定......");
|
||||||
caselog.CaseLogDetail(tastid, caseid,"用例执行结果锁定......","error","ending","");
|
caselog.caseLogDetail(tastid, caseid,"用例执行结果锁定......","error","ending","");
|
||||||
luckyclient.publicclass.LogUtil.APP.info("******************************分割线*************************************");
|
luckyclient.publicclass.LogUtil.APP.info("******************************分割线*************************************");
|
||||||
}
|
}
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
luckyclient.publicclass.LogUtil.ERROR.error("用例:"+testcaseob.getFullExternalId()+"设置执行结果过程出错......");
|
luckyclient.publicclass.LogUtil.ERROR.error("用例:"+testcaseob.getFullExternalId()+"设置执行结果过程出错......");
|
||||||
caselog.CaseLogDetail(tastid, caseid,"设置执行结果过程出错......","error","ending","");
|
caselog.caseLogDetail(tastid, caseid,"设置执行结果过程出错......","error","ending","");
|
||||||
luckyclient.publicclass.LogUtil.ERROR.error(e,e);
|
luckyclient.publicclass.LogUtil.ERROR.error(e,e);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}finally{
|
}finally{
|
||||||
|
|
|
@ -9,6 +9,17 @@ import org.openqa.selenium.TakesScreenshot;
|
||||||
import org.openqa.selenium.WebDriver;
|
import org.openqa.selenium.WebDriver;
|
||||||
import org.openqa.selenium.remote.Augmenter;
|
import org.openqa.selenium.remote.Augmenter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class BaseWebDrive {
|
public class BaseWebDrive {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,7 +27,7 @@ public class BaseWebDrive {
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public static Boolean WebScreenShot(WebDriver driver,String imgname) {
|
public static Boolean webScreenShot(WebDriver driver,String imgname) {
|
||||||
Boolean result = false;
|
Boolean result = false;
|
||||||
String relativelyPath = System.getProperty("user.dir");
|
String relativelyPath = System.getProperty("user.dir");
|
||||||
|
|
||||||
|
|
|
@ -12,18 +12,31 @@ import luckyclient.dblog.LogOperation;
|
||||||
import luckyclient.planapi.api.GetServerAPI;
|
import luckyclient.planapi.api.GetServerAPI;
|
||||||
import luckyclient.planapi.entity.ProjectCase;
|
import luckyclient.planapi.entity.ProjectCase;
|
||||||
import luckyclient.planapi.entity.ProjectCasesteps;
|
import luckyclient.planapi.entity.ProjectCasesteps;
|
||||||
|
import luckyclient.planapi.entity.PublicCaseParams;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class CaseLocalDebug{
|
public class CaseLocalDebug{
|
||||||
|
|
||||||
|
|
||||||
public static void OneCasedebug(WebDriver wd,String testCaseExternalId){
|
public static void oneCasedebug(WebDriver wd,String testCaseExternalId){
|
||||||
DbLink.exetype = 1; //不记录日志到数据库
|
DbLink.exetype = 1; //不记录日志到数据库
|
||||||
LogOperation caselog = new LogOperation(); // 初始化写用例结果以及日志模块
|
LogOperation caselog = new LogOperation(); // 初始化写用例结果以及日志模块
|
||||||
try {
|
try {
|
||||||
ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId);
|
ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId);
|
||||||
|
List<PublicCaseParams> pcplist=GetServerAPI.cgetParamsByProjectid(String.valueOf(testcase.getProjectid()));
|
||||||
luckyclient.publicclass.LogUtil.APP.info("开始执行用例:【"+testCaseExternalId+"】......");
|
luckyclient.publicclass.LogUtil.APP.info("开始执行用例:【"+testCaseExternalId+"】......");
|
||||||
List<ProjectCasesteps> steps=GetServerAPI.getStepsbycaseid(testcase.getId());
|
List<ProjectCasesteps> steps=GetServerAPI.getStepsbycaseid(testcase.getId());
|
||||||
WebCaseExecution.CaseExcution(testcase,steps, "888888",wd,caselog);
|
WebCaseExecution.caseExcution(testcase,steps, "888888",wd,caselog,pcplist);
|
||||||
luckyclient.publicclass.LogUtil.APP.info("当前用例:【"+testcase.getSign()+"】执行完成......进入下一条");
|
luckyclient.publicclass.LogUtil.APP.info("当前用例:【"+testcase.getSign()+"】执行完成......进入下一条");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||||
|
@ -39,7 +52,7 @@ public class CaseLocalDebug{
|
||||||
* @param 用例版本号
|
* @param 用例版本号
|
||||||
* 用于在testlink上配置好用例参数后,做多条用例串行调试
|
* 用于在testlink上配置好用例参数后,做多条用例串行调试
|
||||||
*/
|
*/
|
||||||
public static void MoreCaseDebug(WebDriver wd,String projectname,Map<String,Integer> addtestcase){
|
public static void moreCaseDebug(WebDriver wd,String projectname,Map<String,Integer> addtestcase){
|
||||||
System.out.println(addtestcase.size());
|
System.out.println(addtestcase.size());
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
Iterator it=addtestcase.entrySet().iterator();
|
Iterator it=addtestcase.entrySet().iterator();
|
||||||
|
@ -50,7 +63,7 @@ public class CaseLocalDebug{
|
||||||
Integer version = (Integer)entry.getValue();
|
Integer version = (Integer)entry.getValue();
|
||||||
try{
|
try{
|
||||||
luckyclient.publicclass.LogUtil.APP.info("开始调用方法,项目名:"+projectname+",用例编号:"+testCaseExternalId+",用例版本:"+version);
|
luckyclient.publicclass.LogUtil.APP.info("开始调用方法,项目名:"+projectname+",用例编号:"+testCaseExternalId+",用例版本:"+version);
|
||||||
OneCasedebug(wd,testCaseExternalId);
|
oneCasedebug(wd,testCaseExternalId);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,20 @@ import org.openqa.selenium.support.ui.Select;
|
||||||
|
|
||||||
import luckyclient.caserun.exwebdriver.ocr.Ocr;
|
import luckyclient.caserun.exwebdriver.ocr.Ocr;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class EncapsulateOperation {
|
public class EncapsulateOperation {
|
||||||
|
|
||||||
public static String SelectOperation(WebElement we,String operation,String operation_value) throws Exception{
|
public static String selectOperation(WebElement we,String operation,String operationValue) throws Exception{
|
||||||
String result = "";
|
String result = "";
|
||||||
// 下拉框对象处理
|
// 下拉框对象处理
|
||||||
Select select = new Select(we);
|
Select select = new Select(we);
|
||||||
|
@ -21,16 +31,16 @@ public class EncapsulateOperation {
|
||||||
// 处理下拉框事件
|
// 处理下拉框事件
|
||||||
switch (operation) {
|
switch (operation) {
|
||||||
case "selectbyvisibletext":
|
case "selectbyvisibletext":
|
||||||
select.selectByVisibleText(operation_value);
|
select.selectByVisibleText(operationValue);
|
||||||
luckyclient.publicclass.LogUtil.APP.info("下拉框对象通过VisibleText属性选择...【VisibleText属性值:" + operation_value + "】");
|
luckyclient.publicclass.LogUtil.APP.info("下拉框对象通过VisibleText属性选择...【VisibleText属性值:" + operationValue + "】");
|
||||||
break;
|
break;
|
||||||
case "selectbyvalue":
|
case "selectbyvalue":
|
||||||
select.selectByValue(operation_value);
|
select.selectByValue(operationValue);
|
||||||
luckyclient.publicclass.LogUtil.APP.info("下拉框对象通过Value属性选择...【Value属性值:" + operation_value + "】");
|
luckyclient.publicclass.LogUtil.APP.info("下拉框对象通过Value属性选择...【Value属性值:" + operationValue + "】");
|
||||||
break;
|
break;
|
||||||
case "selectbyindex":
|
case "selectbyindex":
|
||||||
select.selectByIndex(Integer.valueOf(operation_value));
|
select.selectByIndex(Integer.valueOf(operationValue));
|
||||||
luckyclient.publicclass.LogUtil.APP.info("下拉框对象通过Index属性选择...【Index属性值:" + operation_value + "】");
|
luckyclient.publicclass.LogUtil.APP.info("下拉框对象通过Index属性选择...【Index属性值:" + operationValue + "】");
|
||||||
break;
|
break;
|
||||||
case "isselect":
|
case "isselect":
|
||||||
result = "获取到的值是【"+we.isSelected()+"】";
|
result = "获取到的值是【"+we.isSelected()+"】";
|
||||||
|
@ -42,7 +52,7 @@ public class EncapsulateOperation {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String GetOperation(WebDriver wd,WebElement we,String operation) throws Exception{
|
public static String getOperation(WebDriver wd,WebElement we,String operation) throws Exception{
|
||||||
String result = "";
|
String result = "";
|
||||||
// 获取对象处理
|
// 获取对象处理
|
||||||
switch (operation) {
|
switch (operation) {
|
||||||
|
@ -64,45 +74,45 @@ public class EncapsulateOperation {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String ActionWeOperation(WebDriver wd,WebElement we,String operation,String operation_value,String property,String property_value) throws Exception{
|
public static String actionWeOperation(WebDriver wd,WebElement we,String operation,String operationValue,String property,String propertyValue) throws Exception{
|
||||||
String result = "";
|
String result = "";
|
||||||
Actions action = new Actions(wd);
|
Actions action = new Actions(wd);
|
||||||
// action处理
|
// action处理
|
||||||
switch (operation) {
|
switch (operation) {
|
||||||
case "mouselkclick": //鼠标左键点击
|
case "mouselkclick": //鼠标左键点击
|
||||||
action.click(we).perform();
|
action.click(we).perform();
|
||||||
result = "mouselkclick鼠标左键点击对象...【对象定位属性:"+property+"; 定位属性值:"+property_value+"】";
|
result = "mouselkclick鼠标左键点击对象...【对象定位属性:"+property+"; 定位属性值:"+propertyValue+"】";
|
||||||
luckyclient.publicclass.LogUtil.APP.info("mouselkclick鼠标左键点击对象...【对象定位属性:"+property+"; 定位属性值:"+property_value+"】");
|
luckyclient.publicclass.LogUtil.APP.info("mouselkclick鼠标左键点击对象...【对象定位属性:"+property+"; 定位属性值:"+propertyValue+"】");
|
||||||
break;
|
break;
|
||||||
case "mouserkclick":
|
case "mouserkclick":
|
||||||
action.contextClick(we).perform();
|
action.contextClick(we).perform();
|
||||||
result = "mouserkclick鼠标右键点击对象...【对象定位属性:"+property+"; 定位属性值:"+property_value+"】";
|
result = "mouserkclick鼠标右键点击对象...【对象定位属性:"+property+"; 定位属性值:"+propertyValue+"】";
|
||||||
luckyclient.publicclass.LogUtil.APP.info("mouserkclick鼠标右键点击对象...【对象定位属性:"+property+"; 定位属性值:"+property_value+"】");
|
luckyclient.publicclass.LogUtil.APP.info("mouserkclick鼠标右键点击对象...【对象定位属性:"+property+"; 定位属性值:"+propertyValue+"】");
|
||||||
break;
|
break;
|
||||||
case "mousedclick":
|
case "mousedclick":
|
||||||
action.doubleClick(we).perform();
|
action.doubleClick(we).perform();
|
||||||
result = "mousedclick鼠标双击对象...【对象定位属性:"+property+"; 定位属性值:"+property_value+"】";
|
result = "mousedclick鼠标双击对象...【对象定位属性:"+property+"; 定位属性值:"+propertyValue+"】";
|
||||||
luckyclient.publicclass.LogUtil.APP.info("mousedclick鼠标双击对象...【对象定位属性:"+property+"; 定位属性值:"+property_value+"】");
|
luckyclient.publicclass.LogUtil.APP.info("mousedclick鼠标双击对象...【对象定位属性:"+property+"; 定位属性值:"+propertyValue+"】");
|
||||||
break;
|
break;
|
||||||
case "mouseclickhold":
|
case "mouseclickhold":
|
||||||
action.clickAndHold(we).perform();
|
action.clickAndHold(we).perform();
|
||||||
result = "mouseclickhold鼠标点击对象后不释放...【对象定位属性:"+property+"; 定位属性值:"+property_value+"】";
|
result = "mouseclickhold鼠标点击对象后不释放...【对象定位属性:"+property+"; 定位属性值:"+propertyValue+"】";
|
||||||
luckyclient.publicclass.LogUtil.APP.info("mouseclickhold鼠标点击对象后不释放...【对象定位属性:"+property+"; 定位属性值:"+property_value+"】");
|
luckyclient.publicclass.LogUtil.APP.info("mouseclickhold鼠标点击对象后不释放...【对象定位属性:"+property+"; 定位属性值:"+propertyValue+"】");
|
||||||
break;
|
break;
|
||||||
case "mousedrag":
|
case "mousedrag":
|
||||||
String temp[]=operation_value.split(",",-1);
|
String[] temp=operationValue.split(",",-1);
|
||||||
action.dragAndDropBy(we, Integer.valueOf(temp[0]), Integer.valueOf(temp[1])).perform();
|
action.dragAndDropBy(we, Integer.valueOf(temp[0]), Integer.valueOf(temp[1])).perform();
|
||||||
result = "mousedrag鼠标移动至对象相对坐标...【对象定位属性:"+property+"; 定位属性值:"+property_value+"】 坐标x:"+Integer.valueOf(temp[0])
|
result = "mousedrag鼠标移动至对象相对坐标...【对象定位属性:"+property+"; 定位属性值:"+propertyValue+"】 坐标x:"+Integer.valueOf(temp[0])
|
||||||
+" 坐标y:"+Integer.valueOf(temp[1]);
|
+" 坐标y:"+Integer.valueOf(temp[1]);
|
||||||
luckyclient.publicclass.LogUtil.APP.info("mousedrag鼠标移动至对象相对坐标...【对象定位属性:"+property+"; 定位属性值:"+property_value+"】 坐标x:"+Integer.valueOf(temp[0])
|
luckyclient.publicclass.LogUtil.APP.info("mousedrag鼠标移动至对象相对坐标...【对象定位属性:"+property+"; 定位属性值:"+propertyValue+"】 坐标x:"+Integer.valueOf(temp[0])
|
||||||
+" 坐标y:"+Integer.valueOf(temp[1]));
|
+" 坐标y:"+Integer.valueOf(temp[1]));
|
||||||
break;
|
break;
|
||||||
case "mouseto":
|
case "mouseto":
|
||||||
String temp1[]=operation_value.split(",",-1);
|
String[] temp1=operationValue.split(",",-1);
|
||||||
action.moveToElement(we, Integer.valueOf(temp1[0]), Integer.valueOf(temp1[1])).perform();
|
action.moveToElement(we, Integer.valueOf(temp1[0]), Integer.valueOf(temp1[1])).perform();
|
||||||
result = "mouseto鼠标移动至对象相对坐标...【对象定位属性:"+property+"; 定位属性值:"+property_value+"】 坐标x:"+Integer.valueOf(temp1[0])
|
result = "mouseto鼠标移动至对象相对坐标...【对象定位属性:"+property+"; 定位属性值:"+propertyValue+"】 坐标x:"+Integer.valueOf(temp1[0])
|
||||||
+" 坐标y:"+Integer.valueOf(temp1[1]);
|
+" 坐标y:"+Integer.valueOf(temp1[1]);
|
||||||
luckyclient.publicclass.LogUtil.APP.info("mouseto鼠标移动至对象相对坐标...【对象定位属性:"+property+"; 定位属性值:"+property_value+"】 坐标x:"+Integer.valueOf(temp1[0])
|
luckyclient.publicclass.LogUtil.APP.info("mouseto鼠标移动至对象相对坐标...【对象定位属性:"+property+"; 定位属性值:"+propertyValue+"】 坐标x:"+Integer.valueOf(temp1[0])
|
||||||
+" 坐标y:"+Integer.valueOf(temp1[1]));
|
+" 坐标y:"+Integer.valueOf(temp1[1]));
|
||||||
break;
|
break;
|
||||||
case "mouserelease":
|
case "mouserelease":
|
||||||
|
@ -116,7 +126,7 @@ public class EncapsulateOperation {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String ActionOperation(WebDriver wd,String operation,String operation_value) throws Exception{
|
public static String actionOperation(WebDriver wd,String operation,String operationValue) throws Exception{
|
||||||
String result = "";
|
String result = "";
|
||||||
Actions action = new Actions(wd);
|
Actions action = new Actions(wd);
|
||||||
// action处理
|
// action处理
|
||||||
|
@ -142,7 +152,7 @@ public class EncapsulateOperation {
|
||||||
luckyclient.publicclass.LogUtil.APP.info("mouseclickhold鼠标点击当前位置后不释放...");
|
luckyclient.publicclass.LogUtil.APP.info("mouseclickhold鼠标点击当前位置后不释放...");
|
||||||
break;
|
break;
|
||||||
case "mouseto":
|
case "mouseto":
|
||||||
String temp1[]=operation_value.split(",",-1);
|
String[] temp1=operationValue.split(",",-1);
|
||||||
action.moveByOffset(Integer.valueOf(temp1[0]), Integer.valueOf(temp1[1])).perform();
|
action.moveByOffset(Integer.valueOf(temp1[0]), Integer.valueOf(temp1[1])).perform();
|
||||||
result = "mouseto鼠标移动至对象相对坐标...坐标x:"+Integer.valueOf(temp1[0])
|
result = "mouseto鼠标移动至对象相对坐标...坐标x:"+Integer.valueOf(temp1[0])
|
||||||
+" 坐标y:"+Integer.valueOf(temp1[1]);
|
+" 坐标y:"+Integer.valueOf(temp1[1]);
|
||||||
|
@ -155,7 +165,7 @@ public class EncapsulateOperation {
|
||||||
luckyclient.publicclass.LogUtil.APP.info("mouserelease鼠标释放...");
|
luckyclient.publicclass.LogUtil.APP.info("mouserelease鼠标释放...");
|
||||||
break;
|
break;
|
||||||
case "mousekey":
|
case "mousekey":
|
||||||
switch (operation_value) {
|
switch (operationValue) {
|
||||||
case "tab":
|
case "tab":
|
||||||
action.sendKeys(Keys.TAB).perform();
|
action.sendKeys(Keys.TAB).perform();
|
||||||
result = "键盘操作TAB键...";
|
result = "键盘操作TAB键...";
|
||||||
|
@ -191,28 +201,28 @@ public class EncapsulateOperation {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String ObjectOperation(WebDriver wd,WebElement we,String operation,String operation_value,String property,String property_value) throws Exception{
|
public static String objectOperation(WebDriver wd,WebElement we,String operation,String operationValue,String property,String propertyValue) throws Exception{
|
||||||
String result = "";
|
String result = "";
|
||||||
// 处理WebElement对象操作
|
// 处理WebElement对象操作
|
||||||
switch (operation) {
|
switch (operation) {
|
||||||
case "click":
|
case "click":
|
||||||
we.click();
|
we.click();
|
||||||
result = "click点击对象...【对象定位属性:"+property+"; 定位属性值:"+property_value+"】";
|
result = "click点击对象...【对象定位属性:"+property+"; 定位属性值:"+propertyValue+"】";
|
||||||
luckyclient.publicclass.LogUtil.APP.info("click点击对象...【对象定位属性:"+property+"; 定位属性值:"+property_value+"】");
|
luckyclient.publicclass.LogUtil.APP.info("click点击对象...【对象定位属性:"+property+"; 定位属性值:"+propertyValue+"】");
|
||||||
break;
|
break;
|
||||||
case "sendkeys":
|
case "sendkeys":
|
||||||
we.sendKeys(operation_value);
|
we.sendKeys(operationValue);
|
||||||
result = "sendKeys对象输入...【对象定位属性:"+property+"; 定位属性值:"+property_value+"; 操作值:"+operation_value+"】";
|
result = "sendKeys对象输入...【对象定位属性:"+property+"; 定位属性值:"+propertyValue+"; 操作值:"+operationValue+"】";
|
||||||
luckyclient.publicclass.LogUtil.APP.info("sendkeys对象输入...【对象定位属性:"+property+"; 定位属性值:"+property_value+"; 操作值:"+operation_value+"】");
|
luckyclient.publicclass.LogUtil.APP.info("sendkeys对象输入...【对象定位属性:"+property+"; 定位属性值:"+propertyValue+"; 操作值:"+operationValue+"】");
|
||||||
break;
|
break;
|
||||||
case "clear":
|
case "clear":
|
||||||
we.clear();
|
we.clear();
|
||||||
result = "clear清空输入框...【对象定位属性:"+property+"; 定位属性值:"+property_value+"】";
|
result = "clear清空输入框...【对象定位属性:"+property+"; 定位属性值:"+propertyValue+"】";
|
||||||
luckyclient.publicclass.LogUtil.APP.info("clear清空输入框...【对象定位属性:"+property+"; 定位属性值:"+property_value+"】");
|
luckyclient.publicclass.LogUtil.APP.info("clear清空输入框...【对象定位属性:"+property+"; 定位属性值:"+propertyValue+"】");
|
||||||
break; // 清空输入框
|
break; // 清空输入框
|
||||||
case "gotoframe":
|
case "gotoframe":
|
||||||
wd.switchTo().frame(we);
|
wd.switchTo().frame(we);
|
||||||
luckyclient.publicclass.LogUtil.APP.info("gotoframe切换Frame...【对象定位属性:"+property+"; 定位属性值:"+property_value+"】");
|
luckyclient.publicclass.LogUtil.APP.info("gotoframe切换Frame...【对象定位属性:"+property+"; 定位属性值:"+propertyValue+"】");
|
||||||
break;
|
break;
|
||||||
case "isenabled":
|
case "isenabled":
|
||||||
result = "获取到的值是【"+we.isEnabled()+"】";
|
result = "获取到的值是【"+we.isEnabled()+"】";
|
||||||
|
@ -224,9 +234,9 @@ public class EncapsulateOperation {
|
||||||
break;
|
break;
|
||||||
case "exjsob":
|
case "exjsob":
|
||||||
JavascriptExecutor jse = (JavascriptExecutor)wd;
|
JavascriptExecutor jse = (JavascriptExecutor)wd;
|
||||||
jse.executeScript(operation_value,we);
|
jse.executeScript(operationValue,we);
|
||||||
result = "执行JS...【"+operation_value+"】";
|
result = "执行JS...【"+operationValue+"】";
|
||||||
luckyclient.publicclass.LogUtil.APP.info("执行JS...【"+operation_value+"】");
|
luckyclient.publicclass.LogUtil.APP.info("执行JS...【"+operationValue+"】");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -234,7 +244,7 @@ public class EncapsulateOperation {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String AlertOperation(WebDriver wd,String operation) throws Exception{
|
public static String alertOperation(WebDriver wd,String operation) throws Exception{
|
||||||
String result = "";
|
String result = "";
|
||||||
Alert alert = wd.switchTo().alert();
|
Alert alert = wd.switchTo().alert();
|
||||||
switch (operation) {
|
switch (operation) {
|
||||||
|
@ -256,21 +266,21 @@ public class EncapsulateOperation {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String DriverOperation(WebDriver wd,String operation,String operation_value) throws Exception{
|
public static String driverOperation(WebDriver wd,String operation,String operationValue) throws Exception{
|
||||||
String result = "";
|
String result = "";
|
||||||
// 处理页面对象操作
|
// 处理页面对象操作
|
||||||
switch (operation) {
|
switch (operation) {
|
||||||
case "open":
|
case "open":
|
||||||
operation_value = "http://"+operation_value;
|
operationValue = "http://"+operationValue;
|
||||||
wd.get(operation_value);
|
wd.get(operationValue);
|
||||||
result = "Open页面...【"+operation_value+"】";
|
result = "Open页面...【"+operationValue+"】";
|
||||||
luckyclient.publicclass.LogUtil.APP.info("Open页面...【"+operation_value+"】");
|
luckyclient.publicclass.LogUtil.APP.info("Open页面...【"+operationValue+"】");
|
||||||
break;
|
break;
|
||||||
case "exjs":
|
case "exjs":
|
||||||
JavascriptExecutor jse = (JavascriptExecutor)wd;
|
JavascriptExecutor jse = (JavascriptExecutor)wd;
|
||||||
jse.executeScript(operation_value);
|
jse.executeScript(operationValue);
|
||||||
result = "执行JS...【"+operation_value+"】";
|
result = "执行JS...【"+operationValue+"】";
|
||||||
luckyclient.publicclass.LogUtil.APP.info("执行JS...【"+operation_value+"】");
|
luckyclient.publicclass.LogUtil.APP.info("执行JS...【"+operationValue+"】");
|
||||||
break;
|
break;
|
||||||
case "gotodefaultcontent":
|
case "gotodefaultcontent":
|
||||||
wd.switchTo().defaultContent();
|
wd.switchTo().defaultContent();
|
||||||
|
@ -285,14 +295,14 @@ public class EncapsulateOperation {
|
||||||
luckyclient.publicclass.LogUtil.APP.info("getWindowHandle获取窗口句柄...【句柄值:" + result + "】");
|
luckyclient.publicclass.LogUtil.APP.info("getWindowHandle获取窗口句柄...【句柄值:" + result + "】");
|
||||||
break;
|
break;
|
||||||
case "gotowindow":
|
case "gotowindow":
|
||||||
wd.switchTo().window(operation_value);
|
wd.switchTo().window(operationValue);
|
||||||
luckyclient.publicclass.LogUtil.APP.info("gotowindow切换句柄指定窗口...");
|
luckyclient.publicclass.LogUtil.APP.info("gotowindow切换句柄指定窗口...");
|
||||||
break;
|
break;
|
||||||
case "wait":
|
case "wait":
|
||||||
try {
|
try {
|
||||||
wd.wait(Integer.valueOf(operation_value) * 1000);
|
wd.wait(Integer.valueOf(operationValue) * 1000);
|
||||||
result = "当前任务操作等待【"+operation_value+"】秒...";
|
result = "当前任务操作等待【"+operationValue+"】秒...";
|
||||||
luckyclient.publicclass.LogUtil.APP.info("当前任务操作等待【"+operation_value+"】秒...");
|
luckyclient.publicclass.LogUtil.APP.info("当前任务操作等待【"+operationValue+"】秒...");
|
||||||
break;
|
break;
|
||||||
} catch (NumberFormatException | InterruptedException e) {
|
} catch (NumberFormatException | InterruptedException e) {
|
||||||
luckyclient.publicclass.LogUtil.APP.error("等待时间转换出错 !");
|
luckyclient.publicclass.LogUtil.APP.error("等待时间转换出错 !");
|
||||||
|
|
|
@ -12,7 +12,17 @@ import org.openqa.selenium.firefox.FirefoxDriver;
|
||||||
import org.openqa.selenium.ie.InternetExplorerDriver;
|
import org.openqa.selenium.ie.InternetExplorerDriver;
|
||||||
import org.openqa.selenium.remote.DesiredCapabilities;
|
import org.openqa.selenium.remote.DesiredCapabilities;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class WebDriverInitialization{
|
public class WebDriverInitialization{
|
||||||
/**
|
/**
|
||||||
* @param args
|
* @param args
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package luckyclient.caserun.exwebdriver;
|
package luckyclient.caserun.exwebdriver;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.log4j.PropertyConfigurator;
|
import org.apache.log4j.PropertyConfigurator;
|
||||||
|
@ -20,10 +21,22 @@ import luckyclient.mail.MailSendInitialization;
|
||||||
import luckyclient.planapi.api.GetServerAPI;
|
import luckyclient.planapi.api.GetServerAPI;
|
||||||
import luckyclient.planapi.entity.ProjectCase;
|
import luckyclient.planapi.entity.ProjectCase;
|
||||||
import luckyclient.planapi.entity.ProjectCasesteps;
|
import luckyclient.planapi.entity.ProjectCasesteps;
|
||||||
|
import luckyclient.planapi.entity.PublicCaseParams;
|
||||||
import luckyclient.planapi.entity.TestTaskexcute;
|
import luckyclient.planapi.entity.TestTaskexcute;
|
||||||
import luckyclient.testlinkapi.TestBuildApi;
|
import luckyclient.testlinkapi.TestBuildApi;
|
||||||
import luckyclient.testlinkapi.TestCaseApi;
|
import luckyclient.testlinkapi.TestCaseApi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class WebTestControl{
|
public class WebTestControl{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,7 +45,7 @@ public class WebTestControl{
|
||||||
* 控制台模式调度计划执行用例
|
* 控制台模式调度计划执行用例
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static void ManualExecutionPlan(String planname){
|
public static void manualExecutionPlan(String planname){
|
||||||
DbLink.exetype = 1; //不记日志到数据库
|
DbLink.exetype = 1; //不记日志到数据库
|
||||||
String taskid = "888888";
|
String taskid = "888888";
|
||||||
WebDriver wd = null;
|
WebDriver wd = null;
|
||||||
|
@ -44,6 +57,10 @@ public class WebTestControl{
|
||||||
}
|
}
|
||||||
LogOperation caselog = new LogOperation(); // 初始化写用例结果以及日志模块
|
LogOperation caselog = new LogOperation(); // 初始化写用例结果以及日志模块
|
||||||
List<ProjectCase> testCases=GetServerAPI.getCasesbyplanname(planname);
|
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()));
|
||||||
|
}
|
||||||
luckyclient.publicclass.LogUtil.APP.info("当前计划中读取到用例共 "+testCases.size()+" 个");
|
luckyclient.publicclass.LogUtil.APP.info("当前计划中读取到用例共 "+testCases.size()+" 个");
|
||||||
int i=0;
|
int i=0;
|
||||||
for(ProjectCase testcase:testCases){
|
for(ProjectCase testcase:testCases){
|
||||||
|
@ -54,7 +71,7 @@ public class WebTestControl{
|
||||||
i++;
|
i++;
|
||||||
luckyclient.publicclass.LogUtil.APP.info("开始执行第"+i+"条用例:【"+testcase.getSign()+"】......");
|
luckyclient.publicclass.LogUtil.APP.info("开始执行第"+i+"条用例:【"+testcase.getSign()+"】......");
|
||||||
try {
|
try {
|
||||||
WebCaseExecution.CaseExcution(testcase,steps,taskid,wd,caselog);
|
WebCaseExecution.caseExcution(testcase,steps,taskid,wd,caselog,pcplist);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||||
|
@ -67,15 +84,16 @@ public class WebTestControl{
|
||||||
wd.quit();
|
wd.quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void TaskExecutionPlan(String taskid,TestTaskexcute task) throws InterruptedException {
|
public static void taskExecutionPlan(String taskid,TestTaskexcute task) throws InterruptedException {
|
||||||
DbLink.exetype = 0; // 记录日志到数据库
|
DbLink.exetype = 0; // 记录日志到数据库
|
||||||
TestControl.TASKID = taskid;
|
TestControl.TASKID = taskid;
|
||||||
String restartstatus = RestartServerInitialization.RestartServerRun(taskid);
|
String restartstatus = RestartServerInitialization.restartServerRun(taskid);
|
||||||
String buildstatus = BuildingInitialization.BuildingRun(taskid);
|
String buildstatus = BuildingInitialization.buildingRun(taskid);
|
||||||
|
List<PublicCaseParams> pcplist=GetServerAPI.cgetParamsByProjectid(task.getTestJob().getProjectid().toString());
|
||||||
String projectname=task.getTestJob().getPlanproj();
|
String projectname=task.getTestJob().getPlanproj();
|
||||||
task=GetServerAPI.cgetTaskbyid(Integer.valueOf(taskid));
|
task=GetServerAPI.cgetTaskbyid(Integer.valueOf(taskid));
|
||||||
String jobname = task.getTestJob().getTaskName();
|
String jobname = task.getTestJob().getTaskName();
|
||||||
int drivertype = LogOperation.Querydrivertype(taskid);
|
int drivertype = LogOperation.querydrivertype(taskid);
|
||||||
// 判断是否要自动重启TOMCAT
|
// 判断是否要自动重启TOMCAT
|
||||||
if (restartstatus.indexOf("Status:true") > -1) {
|
if (restartstatus.indexOf("Status:true") > -1) {
|
||||||
// 判断是否构建是否成功
|
// 判断是否构建是否成功
|
||||||
|
@ -93,10 +111,10 @@ public class WebTestControl{
|
||||||
LogOperation caselog = new LogOperation(); // 初始化写用例结果以及日志模块
|
LogOperation caselog = new LogOperation(); // 初始化写用例结果以及日志模块
|
||||||
int[] tastcount=null;
|
int[] tastcount=null;
|
||||||
if(task.getTestJob().getProjecttype()==1){
|
if(task.getTestJob().getProjecttype()==1){
|
||||||
TestBuildApi.GetBuild(projectname);
|
TestBuildApi.getBuild(projectname);
|
||||||
TestCase[] testCases = TestCaseApi.getplantestcase(projectname, taskid,"");
|
TestCase[] testCases = TestCaseApi.getplantestcase(projectname, taskid,"");
|
||||||
luckyclient.publicclass.LogUtil.APP.info("当前计划中读取到用例共 " + testCases.length + " 个");
|
luckyclient.publicclass.LogUtil.APP.info("当前计划中读取到用例共 " + testCases.length + " 个");
|
||||||
LogOperation.UpdateTastStatus(taskid,testCases.length);
|
LogOperation.updateTastStatus(taskid,testCases.length);
|
||||||
|
|
||||||
for (TestCase testcase : testCases) {
|
for (TestCase testcase : testCases) {
|
||||||
if (testcase.getSteps().size() == 0) {
|
if (testcase.getSteps().size() == 0) {
|
||||||
|
@ -104,7 +122,7 @@ public class WebTestControl{
|
||||||
}
|
}
|
||||||
luckyclient.publicclass.LogUtil.APP.info("开始执行用例:【" + testcase.getFullExternalId() + "】......");
|
luckyclient.publicclass.LogUtil.APP.info("开始执行用例:【" + testcase.getFullExternalId() + "】......");
|
||||||
try {
|
try {
|
||||||
WebCaseExecutionTestLink.CaseExcution(projectname, testcase, taskid, wd, caselog);
|
WebCaseExecutionTestLink.caseExcution(projectname, testcase, taskid, wd, caselog);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||||
|
@ -112,11 +130,11 @@ public class WebTestControl{
|
||||||
}
|
}
|
||||||
luckyclient.publicclass.LogUtil.APP.info("当前用例:【" + testcase.getFullExternalId() + "】执行完成......进入下一条");
|
luckyclient.publicclass.LogUtil.APP.info("当前用例:【" + testcase.getFullExternalId() + "】执行完成......进入下一条");
|
||||||
}
|
}
|
||||||
tastcount = LogOperation.UpdateTastdetail(taskid, testCases.length);
|
tastcount = LogOperation.updateTastdetail(taskid, testCases.length);
|
||||||
}else if(task.getTestJob().getProjecttype()==0){
|
}else if(task.getTestJob().getProjecttype()==0){
|
||||||
List<ProjectCase> cases=GetServerAPI.getCasesbyplanid(task.getTestJob().getPlanid());
|
List<ProjectCase> cases=GetServerAPI.getCasesbyplanid(task.getTestJob().getPlanid());
|
||||||
luckyclient.publicclass.LogUtil.APP.info("当前计划中读取到用例共 " + cases.size() + " 个");
|
luckyclient.publicclass.LogUtil.APP.info("当前计划中读取到用例共 " + cases.size() + " 个");
|
||||||
LogOperation.UpdateTastStatus(taskid,cases.size());
|
LogOperation.updateTastStatus(taskid,cases.size());
|
||||||
|
|
||||||
for (ProjectCase testcase : cases) {
|
for (ProjectCase testcase : cases) {
|
||||||
List<ProjectCasesteps> steps=GetServerAPI.getStepsbycaseid(testcase.getId());
|
List<ProjectCasesteps> steps=GetServerAPI.getStepsbycaseid(testcase.getId());
|
||||||
|
@ -125,7 +143,7 @@ public class WebTestControl{
|
||||||
}
|
}
|
||||||
luckyclient.publicclass.LogUtil.APP.info("开始执行用例:【" + testcase.getSign() + "】......");
|
luckyclient.publicclass.LogUtil.APP.info("开始执行用例:【" + testcase.getSign() + "】......");
|
||||||
try {
|
try {
|
||||||
WebCaseExecution.CaseExcution(testcase, steps, taskid, wd, caselog);
|
WebCaseExecution.caseExcution(testcase, steps, taskid, wd, caselog,pcplist);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||||
|
@ -133,22 +151,22 @@ public class WebTestControl{
|
||||||
}
|
}
|
||||||
luckyclient.publicclass.LogUtil.APP.info("当前用例:【" + testcase.getSign() + "】执行完成......进入下一条");
|
luckyclient.publicclass.LogUtil.APP.info("当前用例:【" + testcase.getSign() + "】执行完成......进入下一条");
|
||||||
}
|
}
|
||||||
tastcount = LogOperation.UpdateTastdetail(taskid, cases.size());
|
tastcount = LogOperation.updateTastdetail(taskid, cases.size());
|
||||||
}
|
}
|
||||||
String testtime = LogOperation.GetTestTime(taskid);
|
String testtime = LogOperation.getTestTime(taskid);
|
||||||
luckyclient.publicclass.LogUtil.APP.info("当前项目【" + projectname + "】测试计划中的用例已经全部执行完成...");
|
luckyclient.publicclass.LogUtil.APP.info("当前项目【" + projectname + "】测试计划中的用例已经全部执行完成...");
|
||||||
MailSendInitialization.SendMailInitialization(HtmlMail.HtmlSubjectFormat(jobname),
|
MailSendInitialization.sendMailInitialization(HtmlMail.htmlSubjectFormat(jobname),
|
||||||
HtmlMail.HtmlContentFormat(tastcount, taskid, buildstatus, restartstatus, testtime,jobname), taskid);
|
HtmlMail.htmlContentFormat(tastcount, taskid, buildstatus, restartstatus, testtime,jobname), taskid);
|
||||||
// 关闭浏览器
|
// 关闭浏览器
|
||||||
wd.quit();
|
wd.quit();
|
||||||
} else {
|
} else {
|
||||||
luckyclient.publicclass.LogUtil.APP.error("项目构建失败,自动化测试自动退出!请前往JENKINS中检查项目构建情况。");
|
luckyclient.publicclass.LogUtil.APP.error("项目构建失败,自动化测试自动退出!请前往JENKINS中检查项目构建情况。");
|
||||||
MailSendInitialization.SendMailInitialization(jobname,
|
MailSendInitialization.sendMailInitialization(jobname,
|
||||||
"构建项目过程中失败,自动化测试自动退出!请前去JENKINS查看构建情况!", taskid);
|
"构建项目过程中失败,自动化测试自动退出!请前去JENKINS查看构建情况!", taskid);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
luckyclient.publicclass.LogUtil.APP.error("项目TOMCAT重启失败,自动化测试自动退出!请检查项目TOMCAT运行情况。");
|
luckyclient.publicclass.LogUtil.APP.error("项目TOMCAT重启失败,自动化测试自动退出!请检查项目TOMCAT运行情况。");
|
||||||
MailSendInitialization.SendMailInitialization(jobname,
|
MailSendInitialization.sendMailInitialization(jobname,
|
||||||
"项目TOMCAT重启失败,自动化测试自动退出!请检查项目TOMCAT运行情况!", taskid);
|
"项目TOMCAT重启失败,自动化测试自动退出!请检查项目TOMCAT运行情况!", taskid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,15 +13,28 @@ import luckyclient.dblog.LogOperation;
|
||||||
import luckyclient.planapi.api.GetServerAPI;
|
import luckyclient.planapi.api.GetServerAPI;
|
||||||
import luckyclient.planapi.entity.ProjectCase;
|
import luckyclient.planapi.entity.ProjectCase;
|
||||||
import luckyclient.planapi.entity.ProjectCasesteps;
|
import luckyclient.planapi.entity.ProjectCasesteps;
|
||||||
|
import luckyclient.planapi.entity.PublicCaseParams;
|
||||||
|
import luckyclient.planapi.entity.TestTaskexcute;
|
||||||
import luckyclient.testlinkapi.TestBuildApi;
|
import luckyclient.testlinkapi.TestBuildApi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class WebBatchExecute{
|
public class WebBatchExecute{
|
||||||
|
|
||||||
@SuppressWarnings("static-access")
|
@SuppressWarnings("static-access")
|
||||||
public static void BatchCaseExecuteForTast(String projectname,String taskid,String batchcase) throws IOException{
|
public static void batchCaseExecuteForTast(String projectname,String taskid,String batchcase) throws IOException{
|
||||||
DbLink.exetype = 0; //记录日志到数据库
|
DbLink.exetype = 0; //记录日志到数据库
|
||||||
TestControl.TASKID = taskid;
|
TestControl.TASKID = taskid;
|
||||||
int drivertype = LogOperation.Querydrivertype(taskid);
|
int drivertype = LogOperation.querydrivertype(taskid);
|
||||||
WebDriver wd = null;
|
WebDriver wd = null;
|
||||||
try {
|
try {
|
||||||
wd = WebDriverInitialization.setWebDriverForTask(taskid,drivertype);
|
wd = WebDriverInitialization.setWebDriverForTask(taskid,drivertype);
|
||||||
|
@ -30,19 +43,21 @@ public class WebBatchExecute{
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
LogOperation caselog = new LogOperation(); // 初始化写用例结果以及日志模块
|
LogOperation caselog = new LogOperation(); // 初始化写用例结果以及日志模块
|
||||||
TestBuildApi.GetBuild(projectname);
|
TestBuildApi.getBuild(projectname);
|
||||||
|
TestTaskexcute task=GetServerAPI.cgetTaskbyid(Integer.valueOf(taskid));
|
||||||
|
List<PublicCaseParams> pcplist=GetServerAPI.cgetParamsByProjectid(task.getTestJob().getProjectid().toString());
|
||||||
if(batchcase.indexOf("ALLFAIL")>-1){ //执行全部非成功状态用例
|
if(batchcase.indexOf("ALLFAIL")>-1){ //执行全部非成功状态用例
|
||||||
String casemore = caselog.UnSucCaseUpdate(taskid);
|
String casemore = caselog.unSucCaseUpdate(taskid);
|
||||||
String temp[]=casemore.split("\\#",-1);
|
String[] temp=casemore.split("\\#",-1);
|
||||||
for(int i=0;i<temp.length;i++){
|
for(int i=0;i<temp.length;i++){
|
||||||
String testCaseExternalId = temp[i].substring(0, temp[i].indexOf("%"));
|
String testCaseExternalId = temp[i].substring(0, temp[i].indexOf("%"));
|
||||||
//int version = Integer.parseInt(temp[i].substring(temp[i].indexOf("%")+1,temp[i].length()-1));
|
//int version = Integer.parseInt(temp[i].substring(temp[i].indexOf("%")+1,temp[i].length()-1));
|
||||||
ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId);
|
ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId);
|
||||||
List<ProjectCasesteps> steps=GetServerAPI.getStepsbycaseid(testcase.getId());
|
List<ProjectCasesteps> steps=GetServerAPI.getStepsbycaseid(testcase.getId());
|
||||||
caselog.DeleteCaseDetail(testCaseExternalId, taskid); //删除旧的用例
|
LogOperation.deleteCaseDetail(testCaseExternalId, taskid); //删除旧的用例
|
||||||
caselog.DeleteCaseLogDetail(testCaseExternalId, taskid); //删除旧的日志
|
LogOperation.deleteCaseLogDetail(testCaseExternalId, taskid); //删除旧的日志
|
||||||
try {
|
try {
|
||||||
WebCaseExecution.CaseExcution(testcase, steps, taskid,wd,caselog);
|
WebCaseExecution.caseExcution(testcase, steps, taskid,wd,caselog,pcplist);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||||
|
@ -50,14 +65,14 @@ public class WebBatchExecute{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{ //批量执行用例
|
}else{ //批量执行用例
|
||||||
String temp[]=batchcase.split("\\#",-1);
|
String[] temp=batchcase.split("\\#",-1);
|
||||||
for(int i=0;i<temp.length;i++){
|
for(int i=0;i<temp.length;i++){
|
||||||
String testCaseExternalId = temp[i].substring(0, temp[i].indexOf("%"));
|
String testCaseExternalId = temp[i].substring(0, temp[i].indexOf("%"));
|
||||||
//int version = Integer.parseInt(temp[i].substring(temp[i].indexOf("%")+1,temp[i].length()));
|
//int version = Integer.parseInt(temp[i].substring(temp[i].indexOf("%")+1,temp[i].length()));
|
||||||
ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId);
|
ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId);
|
||||||
List<ProjectCasesteps> steps=GetServerAPI.getStepsbycaseid(testcase.getId());
|
List<ProjectCasesteps> steps=GetServerAPI.getStepsbycaseid(testcase.getId());
|
||||||
try {
|
try {
|
||||||
WebCaseExecution.CaseExcution(testcase, steps,taskid,wd,caselog);
|
WebCaseExecution.caseExcution(testcase, steps,taskid,wd,caselog,pcplist);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||||
|
|
|
@ -2,7 +2,6 @@ package luckyclient.caserun.exwebdriver.ex;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -16,21 +15,37 @@ import luckyclient.caserun.exwebdriver.EncapsulateOperation;
|
||||||
import luckyclient.dblog.LogOperation;
|
import luckyclient.dblog.LogOperation;
|
||||||
import luckyclient.planapi.entity.ProjectCase;
|
import luckyclient.planapi.entity.ProjectCase;
|
||||||
import luckyclient.planapi.entity.ProjectCasesteps;
|
import luckyclient.planapi.entity.ProjectCasesteps;
|
||||||
import luckyclient.publicclass.DBOperation;
|
import luckyclient.planapi.entity.PublicCaseParams;
|
||||||
|
import luckyclient.publicclass.ChangString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class WebCaseExecution extends TestCaseExecution{
|
public class WebCaseExecution extends TestCaseExecution{
|
||||||
static Map<String, String> variable = new HashMap<String, String>();
|
static Map<String, String> variable = new HashMap<String, String>();
|
||||||
|
|
||||||
public static void CaseExcution(ProjectCase testcase, List<ProjectCasesteps> steps,String taskid, WebDriver wd,LogOperation caselog)
|
public static void caseExcution(ProjectCase testcase, List<ProjectCasesteps> steps,String taskid, WebDriver wd,LogOperation caselog,List<PublicCaseParams> pcplist)
|
||||||
throws InterruptedException {
|
throws InterruptedException {
|
||||||
int setresult = 0; // 0:成功 1:失败 2:锁定 其他:锁定
|
int setresult = 0; // 0:成功 1:失败 2:锁定 其他:锁定
|
||||||
String casenote = "备注初始化";
|
String casenote = "备注初始化";
|
||||||
String imagname = "";
|
String imagname = "";
|
||||||
|
// 把公共参数加入到MAP中
|
||||||
|
for (PublicCaseParams pcp : pcplist) {
|
||||||
|
variable.put(pcp.getParamsname(), pcp.getParamsvalue());
|
||||||
|
}
|
||||||
|
|
||||||
caselog.AddCaseDetail(taskid, testcase.getSign(), "1", testcase.getName(), 4); //插入开始执行的用例
|
caselog.addCaseDetail(taskid, testcase.getSign(), "1", testcase.getName(), 4); //插入开始执行的用例
|
||||||
|
|
||||||
for (ProjectCasesteps step : steps) {
|
for (ProjectCasesteps step : steps) {
|
||||||
Map<String, String> params = WebDriverAnalyticCase.AnalyticCaseStep(testcase, step, taskid,caselog);
|
Map<String, String> params = WebDriverAnalyticCase.analyticCaseStep(testcase, step, taskid,caselog);
|
||||||
|
|
||||||
if(params.get("exception")!=null&¶ms.get("exception").toString().indexOf("解析异常")>-1){
|
if(params.get("exception")!=null&¶ms.get("exception").toString().indexOf("解析异常")>-1){
|
||||||
setresult = 2;
|
setresult = 2;
|
||||||
|
@ -40,6 +55,7 @@ public class WebCaseExecution extends TestCaseExecution{
|
||||||
String result = WebCaseExecution.runStep(params, wd, taskid, testcase.getSign(), step.getStepnum(), caselog);
|
String result = WebCaseExecution.runStep(params, wd, taskid, testcase.getSign(), step.getStepnum(), caselog);
|
||||||
|
|
||||||
String expectedResults = params.get("ExpectedResults").toString();
|
String expectedResults = params.get("ExpectedResults").toString();
|
||||||
|
expectedResults=ChangString.changparams(expectedResults, variable,"预期结果");
|
||||||
|
|
||||||
if (result.indexOf("出错") < 0 && result.indexOf("失败") < 0) { // 运行结果正常
|
if (result.indexOf("出错") < 0 && result.indexOf("失败") < 0) { // 运行结果正常
|
||||||
int waitsec = Integer.parseInt(params.get("StepWait").toString()); // 获取步骤间等待时间
|
int waitsec = Integer.parseInt(params.get("StepWait").toString()); // 获取步骤间等待时间
|
||||||
|
@ -48,25 +64,25 @@ public class WebCaseExecution extends TestCaseExecution{
|
||||||
Thread.sleep(waitsec * 1000);
|
Thread.sleep(waitsec * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!expectedResults.equals("")) { // 有预期结果
|
if (!"".equals(expectedResults)) { // 有预期结果
|
||||||
// 判断传参
|
// 判断传参
|
||||||
luckyclient.publicclass.LogUtil.APP.info("expectedResults=【"+expectedResults+"】");
|
luckyclient.publicclass.LogUtil.APP.info("expectedResults=【"+expectedResults+"】");
|
||||||
if (expectedResults.length() > 2 && expectedResults.substring(0, 2).indexOf("$=") > -1) {
|
if (expectedResults.length() > 2 && expectedResults.substring(0, 2).indexOf("$=") > -1) {
|
||||||
String ExpectedResultVariable = expectedResults.substring(2);
|
String expectedResultVariable = expectedResults.substring(2);
|
||||||
variable.put(ExpectedResultVariable, result);
|
variable.put(expectedResultVariable, result);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 判断预期结果-检查模式
|
// 判断预期结果-检查模式
|
||||||
if (params.get("checkproperty") != null && params.get("checkproperty_value") != null) {
|
if (params.get("checkproperty") != null && params.get("checkproperty_value") != null) {
|
||||||
String checkproperty = params.get("checkproperty").toString();
|
String checkproperty = params.get("checkproperty").toString();
|
||||||
String checkproperty_value = params.get("checkproperty_value").toString();
|
String checkPropertyValue = params.get("checkproperty_value").toString();
|
||||||
|
|
||||||
WebElement we = isElementExist(wd, checkproperty, checkproperty_value);
|
WebElement we = isElementExist(wd, checkproperty, checkPropertyValue);
|
||||||
if (null != we) {
|
if (null != we) {
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + " 第" + step.getStepnum()
|
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + " 第" + step.getStepnum()
|
||||||
+ "步,在当前页面中找到预期结果中对象。当前步骤执行成功!");
|
+ "步,在当前页面中找到预期结果中对象。当前步骤执行成功!");
|
||||||
caselog.CaseLogDetail(taskid, testcase.getSign(), "在当前页面中找到预期结果中对象。当前步骤执行成功!",
|
caselog.caseLogDetail(taskid, testcase.getSign(), "在当前页面中找到预期结果中对象。当前步骤执行成功!",
|
||||||
"info", String.valueOf(step.getStepnum()),"");
|
"info", String.valueOf(step.getStepnum()),"");
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
|
@ -74,11 +90,11 @@ public class WebCaseExecution extends TestCaseExecution{
|
||||||
setresult = 1;
|
setresult = 1;
|
||||||
java.text.DateFormat timeformat = new java.text.SimpleDateFormat("MMdd-hhmmss");
|
java.text.DateFormat timeformat = new java.text.SimpleDateFormat("MMdd-hhmmss");
|
||||||
imagname = timeformat.format(new Date());
|
imagname = timeformat.format(new Date());
|
||||||
BaseWebDrive.WebScreenShot(wd,imagname);
|
BaseWebDrive.webScreenShot(wd,imagname);
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getSign() + " 第" + step.getStepnum()
|
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getSign() + " 第" + step.getStepnum()
|
||||||
+ "步,没有在当前页面中找到预期结果中对象。当前步骤执行失败!");
|
+ "步,没有在当前页面中找到预期结果中对象。当前步骤执行失败!");
|
||||||
caselog.CaseLogDetail(taskid, testcase.getSign(), "在当前页面中没有找到预期结果中对象。当前步骤执行失败!"
|
caselog.caseLogDetail(taskid, testcase.getSign(), "在当前页面中没有找到预期结果中对象。当前步骤执行失败!"
|
||||||
+ "checkproperty【"+checkproperty+"】 checkproperty_value【"+checkproperty_value+"】","error", String.valueOf(step.getStepnum()),imagname);
|
+ "checkproperty【"+checkproperty+"】 checkproperty_value【"+checkPropertyValue+"】","error", String.valueOf(step.getStepnum()),imagname);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +104,7 @@ public class WebCaseExecution extends TestCaseExecution{
|
||||||
if(result.indexOf(expectedResults.substring(2))>-1){
|
if(result.indexOf(expectedResults.substring(2))>-1){
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + " 第" + step.getStepnum()
|
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + " 第" + step.getStepnum()
|
||||||
+ "步,模糊匹配预期结果成功!执行结果:"+result);
|
+ "步,模糊匹配预期结果成功!执行结果:"+result);
|
||||||
caselog.CaseLogDetail(taskid, testcase.getSign(), "步骤模糊匹配预期结果成功!",
|
caselog.caseLogDetail(taskid, testcase.getSign(), "步骤模糊匹配预期结果成功!",
|
||||||
"info", String.valueOf(step.getStepnum()),"");
|
"info", String.valueOf(step.getStepnum()),"");
|
||||||
continue;
|
continue;
|
||||||
}else{
|
}else{
|
||||||
|
@ -96,17 +112,17 @@ public class WebCaseExecution extends TestCaseExecution{
|
||||||
setresult = 1;
|
setresult = 1;
|
||||||
java.text.DateFormat timeformat = new java.text.SimpleDateFormat("MMdd-hhmmss");
|
java.text.DateFormat timeformat = new java.text.SimpleDateFormat("MMdd-hhmmss");
|
||||||
imagname = timeformat.format(new Date());
|
imagname = timeformat.format(new Date());
|
||||||
BaseWebDrive.WebScreenShot(wd,imagname);
|
BaseWebDrive.webScreenShot(wd,imagname);
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getSign() + " 第" + step.getStepnum()
|
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getSign() + " 第" + step.getStepnum()
|
||||||
+ "步,模糊匹配预期结果失败!执行结果:"+result);
|
+ "步,模糊匹配预期结果失败!执行结果:"+result);
|
||||||
caselog.CaseLogDetail(taskid, testcase.getSign(), "步骤模糊匹配预期结果失败!执行结果:"+result,
|
caselog.caseLogDetail(taskid, testcase.getSign(), "步骤模糊匹配预期结果失败!执行结果:"+result,
|
||||||
"error", String.valueOf(step.getStepnum()),imagname);
|
"error", String.valueOf(step.getStepnum()),imagname);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}else if(expectedResults.equals(result)) { // 直接匹配预期结果模式
|
}else if(expectedResults.equals(result)) { // 直接匹配预期结果模式
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + " 第" + step.getStepnum()
|
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + " 第" + step.getStepnum()
|
||||||
+ "步,直接匹配预期结果成功!执行结果:"+result);
|
+ "步,直接匹配预期结果成功!执行结果:"+result);
|
||||||
caselog.CaseLogDetail(taskid, testcase.getSign(), "步骤直接匹配预期结果成功!",
|
caselog.caseLogDetail(taskid, testcase.getSign(), "步骤直接匹配预期结果成功!",
|
||||||
"info", String.valueOf(step.getStepnum()),"");
|
"info", String.valueOf(step.getStepnum()),"");
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
|
@ -114,10 +130,10 @@ public class WebCaseExecution extends TestCaseExecution{
|
||||||
setresult = 1;
|
setresult = 1;
|
||||||
java.text.DateFormat timeformat = new java.text.SimpleDateFormat("MMdd-hhmmss");
|
java.text.DateFormat timeformat = new java.text.SimpleDateFormat("MMdd-hhmmss");
|
||||||
imagname = timeformat.format(new Date());
|
imagname = timeformat.format(new Date());
|
||||||
BaseWebDrive.WebScreenShot(wd,imagname);
|
BaseWebDrive.webScreenShot(wd,imagname);
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getSign() + " 第" + step.getStepnum()
|
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getSign() + " 第" + step.getStepnum()
|
||||||
+ "步,直接匹配预期结果失败!执行结果:"+result);
|
+ "步,直接匹配预期结果失败!执行结果:"+result);
|
||||||
caselog.CaseLogDetail(taskid, testcase.getSign(), "步骤直接匹配预期结果失败!执行结果:"+result,
|
caselog.caseLogDetail(taskid, testcase.getSign(), "步骤直接匹配预期结果失败!执行结果:"+result,
|
||||||
"error", String.valueOf(step.getStepnum()),imagname);
|
"error", String.valueOf(step.getStepnum()),imagname);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -129,9 +145,9 @@ public class WebCaseExecution extends TestCaseExecution{
|
||||||
setresult = 2;
|
setresult = 2;
|
||||||
java.text.DateFormat timeformat = new java.text.SimpleDateFormat("MMdd-hhmmss");
|
java.text.DateFormat timeformat = new java.text.SimpleDateFormat("MMdd-hhmmss");
|
||||||
imagname = timeformat.format(new Date());
|
imagname = timeformat.format(new Date());
|
||||||
BaseWebDrive.WebScreenShot(wd,imagname);
|
BaseWebDrive.webScreenShot(wd,imagname);
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,"+result);
|
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,"+result);
|
||||||
caselog.CaseLogDetail(taskid, testcase.getSign(), "当前步骤在执行过程中解析|定位元素|操作对象失败!"+result,
|
caselog.caseLogDetail(taskid, testcase.getSign(), "当前步骤在执行过程中解析|定位元素|操作对象失败!"+result,
|
||||||
"error", String.valueOf(step.getStepnum()),imagname);
|
"error", String.valueOf(step.getStepnum()),imagname);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -139,13 +155,13 @@ public class WebCaseExecution extends TestCaseExecution{
|
||||||
}
|
}
|
||||||
|
|
||||||
variable.clear();
|
variable.clear();
|
||||||
caselog.UpdateCaseDetail(taskid, testcase.getSign(), setresult);
|
caselog.updateCaseDetail(taskid, testcase.getSign(), setresult);
|
||||||
if(setresult==0){
|
if(setresult==0){
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例【"+testcase.getSign()+"】全部步骤执行结果成功...");
|
luckyclient.publicclass.LogUtil.APP.info("用例【"+testcase.getSign()+"】全部步骤执行结果成功...");
|
||||||
caselog.CaseLogDetail(taskid, testcase.getSign(), "用例全部步骤执行结果成功","info", "ending","");
|
caselog.caseLogDetail(taskid, testcase.getSign(), "用例全部步骤执行结果成功","info", "ending","");
|
||||||
}else{
|
}else{
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcase.getSign()+"】步骤执行过程中失败或是锁定...请查看具体原因!"+casenote);
|
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcase.getSign()+"】步骤执行过程中失败或是锁定...请查看具体原因!"+casenote);
|
||||||
caselog.CaseLogDetail(taskid, testcase.getSign(), "用例执行过程中失败或是锁定"+casenote,"error", "ending","");
|
caselog.caseLogDetail(taskid, testcase.getSign(), "用例执行过程中失败或是锁定"+casenote,"error", "ending","");
|
||||||
}
|
}
|
||||||
//LogOperation.UpdateTastdetail(taskid, 0);
|
//LogOperation.UpdateTastdetail(taskid, 0);
|
||||||
}
|
}
|
||||||
|
@ -153,47 +169,24 @@ public class WebCaseExecution extends TestCaseExecution{
|
||||||
private static String runStep(Map<String, String> params, WebDriver wd,String taskid,String casenum,int stepno,LogOperation caselog) {
|
private static String runStep(Map<String, String> params, WebDriver wd,String taskid,String casenum,int stepno,LogOperation caselog) {
|
||||||
String result = "";
|
String result = "";
|
||||||
String property;
|
String property;
|
||||||
String property_value;
|
String propertyValue;
|
||||||
String operation;
|
String operation;
|
||||||
String operation_value;
|
String operationValue;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
property = params.get("property");
|
property = params.get("property");
|
||||||
property_value = params.get("property_value");
|
propertyValue = params.get("property_value");
|
||||||
operation = params.get("operation");
|
operation = params.get("operation");
|
||||||
operation_value = params.get("operation_value");
|
operationValue = params.get("operation_value");
|
||||||
|
|
||||||
// 处理值传递
|
// 处理值传递
|
||||||
if (property_value != null && property_value.indexOf("@") > -1 && property_value.indexOf("[@") < 0
|
property = ChangString.changparams(property, variable,"定位方式");
|
||||||
&& property_value.indexOf("@@") < 0) {
|
propertyValue=ChangString.changparams(propertyValue, variable,"定位路径");
|
||||||
property_value = SettingParameter(property_value);
|
operation=ChangString.changparams(operation, variable,"操作");
|
||||||
// 判断传参是否存在问题
|
operationValue=ChangString.changparams(operationValue, variable,"操作参数");
|
||||||
if (property_value.indexOf("Set parameter error") > -1) {
|
|
||||||
caselog.CaseLogDetail(taskid, casenum, "当前步骤解析出现异常或是对象为空!---"+property,
|
|
||||||
"error", String.valueOf(stepno),"");
|
|
||||||
return "处理传参过程出错:" + property_value;
|
|
||||||
}
|
|
||||||
}else if(property_value != null && (property_value.indexOf(""")>-1
|
|
||||||
|| property_value.indexOf("'")>-1 || property_value.indexOf("@@")>-1)){
|
|
||||||
property_value = property_value.replaceAll(""", "\"");
|
|
||||||
property_value = property_value.replaceAll("'", "\'");
|
|
||||||
property_value = property_value.replaceAll("@@", "@");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (operation_value != null && operation_value.indexOf("@") > -1 && operation_value.indexOf("@@") < 0) {
|
|
||||||
operation_value = SettingParameter(operation_value);
|
|
||||||
if (operation_value.indexOf("Set parameter error") > -1) {
|
|
||||||
return "处理传参过程出错:" + property_value;
|
|
||||||
}
|
|
||||||
}else if(operation_value != null && (operation_value.indexOf(""")>-1
|
|
||||||
|| operation_value.indexOf("'")>-1 || operation_value.indexOf("@@")>-1)){
|
|
||||||
operation_value = operation_value.replaceAll(""", "\"");
|
|
||||||
operation_value = operation_value.replaceAll("'", "\'");
|
|
||||||
operation_value = operation_value.replaceAll("@@", "@");
|
|
||||||
}
|
|
||||||
|
|
||||||
luckyclient.publicclass.LogUtil.APP.info("二次解析用例过程完成,等待进行对象操作......");
|
luckyclient.publicclass.LogUtil.APP.info("二次解析用例过程完成,等待进行对象操作......");
|
||||||
caselog.CaseLogDetail(taskid, casenum, "对象操作:"+operation+"; 操作值:"+operation_value,"info", String.valueOf(stepno),"");
|
caselog.caseLogDetail(taskid, casenum, "对象操作:"+operation+"; 操作值:"+operationValue,"info", String.valueOf(stepno),"");
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -203,9 +196,9 @@ public class WebCaseExecution extends TestCaseExecution{
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//调用接口用例
|
//调用接口用例
|
||||||
if(null != operation&&null != operation_value&&"runcase".equals(operation)){
|
if(null != operation&&null != operationValue&&"runcase".equals(operation)){
|
||||||
String temp[]=operation_value.split(",",-1);
|
String[] temp=operationValue.split(",",-1);
|
||||||
String ex = TestCaseExecution.OneCaseExecuteForWebDriver(temp[0],taskid,caselog);
|
String ex = TestCaseExecution.oneCaseExecuteForWebDriver(temp[0],taskid,caselog);
|
||||||
if(ex.indexOf("CallCase调用出错!")<=-1&&ex.indexOf("解析出错啦!")<=-1&&ex.indexOf("匹配失败")<=-1){
|
if(ex.indexOf("CallCase调用出错!")<=-1&&ex.indexOf("解析出错啦!")<=-1&&ex.indexOf("匹配失败")<=-1){
|
||||||
return ex;
|
return ex;
|
||||||
}else{
|
}else{
|
||||||
|
@ -215,8 +208,8 @@ public class WebCaseExecution extends TestCaseExecution{
|
||||||
|
|
||||||
WebElement we = null;
|
WebElement we = null;
|
||||||
|
|
||||||
if (null != property && null != property_value) { // 页面元素层
|
if (null != property && null != propertyValue) { // 页面元素层
|
||||||
we = isElementExist(wd, property, property_value);
|
we = isElementExist(wd, property, propertyValue);
|
||||||
// 判断此元素是否存在
|
// 判断此元素是否存在
|
||||||
if (null==we) {
|
if (null==we) {
|
||||||
luckyclient.publicclass.LogUtil.APP.error("定位对象失败,isElementExist为null!");
|
luckyclient.publicclass.LogUtil.APP.error("定位对象失败,isElementExist为null!");
|
||||||
|
@ -224,22 +217,22 @@ public class WebCaseExecution extends TestCaseExecution{
|
||||||
}
|
}
|
||||||
|
|
||||||
if (operation.indexOf("select") > -1) {
|
if (operation.indexOf("select") > -1) {
|
||||||
result = EncapsulateOperation.SelectOperation(we, operation, operation_value);
|
result = EncapsulateOperation.selectOperation(we, operation, operationValue);
|
||||||
} else if (operation.indexOf("get") > -1){
|
} else if (operation.indexOf("get") > -1){
|
||||||
result = EncapsulateOperation.GetOperation(wd, we, operation);
|
result = EncapsulateOperation.getOperation(wd, we, operation);
|
||||||
} else if (operation.indexOf("mouse") > -1){
|
} else if (operation.indexOf("mouse") > -1){
|
||||||
result = EncapsulateOperation.ActionWeOperation(wd, we, operation, operation_value, property, property_value);
|
result = EncapsulateOperation.actionWeOperation(wd, we, operation, operationValue, property, propertyValue);
|
||||||
} else {
|
} else {
|
||||||
result = EncapsulateOperation.ObjectOperation(wd, we, operation, operation_value, property, property_value);
|
result = EncapsulateOperation.objectOperation(wd, we, operation, operationValue, property, propertyValue);
|
||||||
}
|
}
|
||||||
} else if (null==property && null != operation) { // Driver层操作
|
} else if (null==property && null != operation) { // Driver层操作
|
||||||
// 处理弹出框事件
|
// 处理弹出框事件
|
||||||
if (operation.indexOf("alert") > -1){
|
if (operation.indexOf("alert") > -1){
|
||||||
result = EncapsulateOperation.AlertOperation(wd, operation);
|
result = EncapsulateOperation.alertOperation(wd, operation);
|
||||||
}else if(operation.indexOf("mouse") > -1){
|
}else if(operation.indexOf("mouse") > -1){
|
||||||
result = EncapsulateOperation.ActionOperation(wd, operation, operation_value);
|
result = EncapsulateOperation.actionOperation(wd, operation, operationValue);
|
||||||
}else{
|
}else{
|
||||||
result = EncapsulateOperation.DriverOperation(wd, operation, operation_value);
|
result = EncapsulateOperation.driverOperation(wd, operation, operationValue);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
luckyclient.publicclass.LogUtil.APP.error("元素操作过程失败!");
|
luckyclient.publicclass.LogUtil.APP.error("元素操作过程失败!");
|
||||||
|
@ -249,7 +242,7 @@ public class WebCaseExecution extends TestCaseExecution{
|
||||||
luckyclient.publicclass.LogUtil.APP.error("元素定位过程或是操作过程失败或异常!"+e.getMessage());
|
luckyclient.publicclass.LogUtil.APP.error("元素定位过程或是操作过程失败或异常!"+e.getMessage());
|
||||||
return "元素定位过程或是操作过程失败或异常!" + e.getMessage();
|
return "元素定位过程或是操作过程失败或异常!" + e.getMessage();
|
||||||
}
|
}
|
||||||
caselog.CaseLogDetail(taskid, casenum, result,"info", String.valueOf(stepno),"");
|
caselog.caseLogDetail(taskid, casenum, result,"info", String.valueOf(stepno),"");
|
||||||
|
|
||||||
if(result.indexOf("获取到的值是【")>-1&&result.indexOf("】")>-1){
|
if(result.indexOf("获取到的值是【")>-1&&result.indexOf("】")>-1){
|
||||||
result = result.substring(7, result.length()-1);
|
result = result.substring(7, result.length()-1);
|
||||||
|
@ -258,119 +251,29 @@ public class WebCaseExecution extends TestCaseExecution{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String SettingParameter(String parameter) {
|
public static WebElement isElementExist(WebDriver wd, String property, String propertyValue) {
|
||||||
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 property_value) {
|
|
||||||
try {
|
try {
|
||||||
WebElement we = null;
|
WebElement we = null;
|
||||||
|
|
||||||
// 处理WebElement对象定位
|
// 处理WebElement对象定位
|
||||||
switch (property) {
|
switch (property) {
|
||||||
case "id":
|
case "id":
|
||||||
we = wd.findElement(By.id(property_value));
|
we = wd.findElement(By.id(propertyValue));
|
||||||
break;
|
break;
|
||||||
case "name":
|
case "name":
|
||||||
we = wd.findElement(By.name(property_value));
|
we = wd.findElement(By.name(propertyValue));
|
||||||
break;
|
break;
|
||||||
case "xpath":
|
case "xpath":
|
||||||
we = wd.findElement(By.xpath(property_value));
|
we = wd.findElement(By.xpath(propertyValue));
|
||||||
break;
|
break;
|
||||||
case "linktext":
|
case "linktext":
|
||||||
we = wd.findElement(By.linkText(property_value));
|
we = wd.findElement(By.linkText(propertyValue));
|
||||||
break;
|
break;
|
||||||
case "tagname":
|
case "tagname":
|
||||||
we = wd.findElement(By.tagName(property_value));
|
we = wd.findElement(By.tagName(propertyValue));
|
||||||
break;
|
break;
|
||||||
case "cssselector":
|
case "cssselector":
|
||||||
we = wd.findElement(By.cssSelector(property_value));
|
we = wd.findElement(By.cssSelector(propertyValue));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -11,8 +11,8 @@ import luckyclient.planapi.entity.ProjectCasesteps;
|
||||||
/**
|
/**
|
||||||
* =================================================================
|
* =================================================================
|
||||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
* 此测试框架主要采用testlink做分层框架,负责数据驱动以及用例管理部分,有任何疑问欢迎联系作者讨论。
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
* QQ:24163551 seagull1985
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
* =================================================================
|
* =================================================================
|
||||||
* @ClassName: AnalyticCase
|
* @ClassName: AnalyticCase
|
||||||
* @Description: 解析单个用例中描述部分的脚本
|
* @Description: 解析单个用例中描述部分的脚本
|
||||||
|
@ -27,7 +27,7 @@ public class WebDriverAnalyticCase {
|
||||||
* @param args
|
* @param args
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("finally")
|
@SuppressWarnings("finally")
|
||||||
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){
|
||||||
String time = "0";
|
String time = "0";
|
||||||
Map<String,String> params = new HashMap<String,String>();
|
Map<String,String> params = new HashMap<String,String>();
|
||||||
|
|
||||||
|
@ -35,11 +35,11 @@ public class WebDriverAnalyticCase {
|
||||||
try {
|
try {
|
||||||
if(null!=step.getPath()&&step.getPath().indexOf("=")>-1){
|
if(null!=step.getPath()&&step.getPath().indexOf("=")>-1){
|
||||||
String property = step.getPath().substring(0, step.getPath().indexOf("="));
|
String property = step.getPath().substring(0, step.getPath().indexOf("="));
|
||||||
String property_value = step.getPath().substring(step.getPath().indexOf("=")+1, step.getPath().length());
|
String propertyValue = step.getPath().substring(step.getPath().indexOf("=")+1, step.getPath().length());
|
||||||
|
|
||||||
params.put("property", property.trim().toLowerCase()); //set属性
|
params.put("property", property.trim().toLowerCase()); //set属性
|
||||||
params.put("property_value", property_value.trim()); //set属性值
|
params.put("property_value", propertyValue.trim()); //set属性值
|
||||||
luckyclient.publicclass.LogUtil.APP.info("对象属性解析结果:property:"+property.trim()+"; property_value:"+property_value.trim());
|
luckyclient.publicclass.LogUtil.APP.info("对象属性解析结果:property:"+property.trim()+"; property_value:"+propertyValue.trim());
|
||||||
}
|
}
|
||||||
params.put("operation", step.getOperation().toLowerCase()); //set操作方法
|
params.put("operation", step.getOperation().toLowerCase()); //set操作方法
|
||||||
if(null!=step.getParameters()&&!"".equals(step.getParameters())){
|
if(null!=step.getParameters()&&!"".equals(step.getParameters())){
|
||||||
|
@ -52,15 +52,15 @@ public class WebDriverAnalyticCase {
|
||||||
if(null!=resultstr&&"".equals(resultstr)){
|
if(null!=resultstr&&"".equals(resultstr)){
|
||||||
params.put("ExpectedResults", "");
|
params.put("ExpectedResults", "");
|
||||||
}else if(null!=resultstr){
|
}else if(null!=resultstr){
|
||||||
String ExpectedResults = SubComment(resultstr);
|
String expectedResults = subComment(resultstr);
|
||||||
|
|
||||||
//处理check字段
|
//处理check字段
|
||||||
if(ExpectedResults.indexOf("check(")>-1){
|
if(expectedResults.indexOf("check(")>-1){
|
||||||
params.put("checkproperty", ExpectedResults.substring(ExpectedResults.indexOf("check(")+6, ExpectedResults.indexOf("=")));
|
params.put("checkproperty", expectedResults.substring(expectedResults.indexOf("check(")+6, expectedResults.indexOf("=")));
|
||||||
params.put("checkproperty_value", ExpectedResults.substring(ExpectedResults.indexOf("=")+1, ExpectedResults.lastIndexOf(")")));
|
params.put("checkproperty_value", expectedResults.substring(expectedResults.indexOf("=")+1, expectedResults.lastIndexOf(")")));
|
||||||
}
|
}
|
||||||
params.put("ExpectedResults", ExpectedResults);
|
params.put("ExpectedResults", expectedResults);
|
||||||
luckyclient.publicclass.LogUtil.APP.info("预期结果解析:ExpectedResults:"+ExpectedResults);
|
luckyclient.publicclass.LogUtil.APP.info("预期结果解析:ExpectedResults:"+expectedResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
//set wait时间
|
//set wait时间
|
||||||
|
@ -72,43 +72,43 @@ public class WebDriverAnalyticCase {
|
||||||
params.put("StepWait", time);
|
params.put("StepWait", time);
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例编号:"+projectcase.getSign()+" 步骤编号:"+step.getStepnum()+" 解析自动化用例步骤脚本完成!");
|
luckyclient.publicclass.LogUtil.APP.info("用例编号:"+projectcase.getSign()+" 步骤编号:"+step.getStepnum()+" 解析自动化用例步骤脚本完成!");
|
||||||
if(null!=caselog){
|
if(null!=caselog){
|
||||||
caselog.CaseLogDetail(taskid, projectcase.getSign(),"步骤编号:"+step.getStepnum()+" 解析自动化用例步骤脚本完成!","info",String.valueOf(step.getStepnum()),"");
|
caselog.caseLogDetail(taskid, projectcase.getSign(),"步骤编号:"+step.getStepnum()+" 解析自动化用例步骤脚本完成!","info",String.valueOf(step.getStepnum()),"");
|
||||||
}
|
}
|
||||||
}catch(Exception e) {
|
}catch(Exception e) {
|
||||||
luckyclient.publicclass.LogUtil.ERROR.error("用例编号:"+projectcase.getSign()+" 步骤编号:"+step.getStepnum()+" 解析自动化用例步骤脚本出错!");
|
luckyclient.publicclass.LogUtil.ERROR.error("用例编号:"+projectcase.getSign()+" 步骤编号:"+step.getStepnum()+" 解析自动化用例步骤脚本出错!");
|
||||||
if(null!=caselog){
|
if(null!=caselog){
|
||||||
caselog.CaseLogDetail(taskid, projectcase.getSign(),"步骤编号:"+step.getStepnum()+" 解析自动化用例步骤脚本出错!","error",String.valueOf(step.getStepnum()),"");
|
caselog.caseLogDetail(taskid, projectcase.getSign(),"步骤编号:"+step.getStepnum()+" 解析自动化用例步骤脚本出错!","error",String.valueOf(step.getStepnum()),"");
|
||||||
}
|
}
|
||||||
luckyclient.publicclass.LogUtil.ERROR.error(e,e);
|
luckyclient.publicclass.LogUtil.ERROR.error(e,e);
|
||||||
params.put("exception","用例编号:"+projectcase.getSign()+"|解析异常,用例步骤为空或是用例脚本错误!");
|
params.put("exception","用例编号:"+projectcase.getSign()+"|解析异常,用例步骤为空或是用例脚本错误!");
|
||||||
}finally{
|
return params;
|
||||||
return params;
|
|
||||||
}
|
}
|
||||||
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String SubComment(String htmlStr) throws InterruptedException{
|
private static String subComment(String htmlStr) throws InterruptedException{
|
||||||
String regEx_script = "<script[^>]*?>[\\s\\S]*?<\\/script>"; // 定义script的正则表达式
|
String regExScript = "<script[^>]*?>[\\s\\S]*?<\\/script>"; // 定义script的正则表达式
|
||||||
String regEx_style = "<style[^>]*?>[\\s\\S]*?<\\/style>"; // 定义style的正则表达式
|
String regExStyle = "<style[^>]*?>[\\s\\S]*?<\\/style>"; // 定义style的正则表达式
|
||||||
String regEx_html = "<[^>]+>"; // 定义HTML标签的正则表达式
|
String regExHtml = "<[^>]+>"; // 定义HTML标签的正则表达式
|
||||||
String regEx_space = "\t|\r|\n";//定义空格回车换行符
|
String regExSpace = "\t|\r|\n";//定义空格回车换行符
|
||||||
|
|
||||||
String scriptstr = null;
|
String scriptstr = null;
|
||||||
if (htmlStr!=null) {
|
if (htmlStr!=null) {
|
||||||
Pattern p_script = Pattern.compile(regEx_script, Pattern.CASE_INSENSITIVE);
|
Pattern pScript = Pattern.compile(regExScript, Pattern.CASE_INSENSITIVE);
|
||||||
Matcher m_script = p_script.matcher(htmlStr);
|
Matcher mScript = pScript.matcher(htmlStr);
|
||||||
htmlStr = m_script.replaceAll(""); // 过滤script标签
|
htmlStr = mScript.replaceAll(""); // 过滤script标签
|
||||||
|
|
||||||
Pattern p_style = Pattern.compile(regEx_style, Pattern.CASE_INSENSITIVE);
|
Pattern pStyle = Pattern.compile(regExStyle, Pattern.CASE_INSENSITIVE);
|
||||||
Matcher m_style = p_style.matcher(htmlStr);
|
Matcher mStyle = pStyle.matcher(htmlStr);
|
||||||
htmlStr = m_style.replaceAll(""); // 过滤style标签
|
htmlStr = mStyle.replaceAll(""); // 过滤style标签
|
||||||
|
|
||||||
Pattern p_html = Pattern.compile(regEx_html, Pattern.CASE_INSENSITIVE);
|
Pattern pHtml = Pattern.compile(regExHtml, Pattern.CASE_INSENSITIVE);
|
||||||
Matcher m_html = p_html.matcher(htmlStr);
|
Matcher mHtml = pHtml.matcher(htmlStr);
|
||||||
htmlStr = m_html.replaceAll(""); // 过滤html标签
|
htmlStr = mHtml.replaceAll(""); // 过滤html标签
|
||||||
|
|
||||||
Pattern p_space = Pattern.compile(regEx_space, Pattern.CASE_INSENSITIVE);
|
Pattern pSpace = Pattern.compile(regExSpace, Pattern.CASE_INSENSITIVE);
|
||||||
Matcher m_space = p_space.matcher(htmlStr);
|
Matcher mSpace = pSpace.matcher(htmlStr);
|
||||||
htmlStr = m_space.replaceAll(""); // 过滤空格回车标签
|
htmlStr = mSpace.replaceAll(""); // 过滤空格回车标签
|
||||||
|
|
||||||
}
|
}
|
||||||
if(htmlStr.indexOf("/*")>-1&&htmlStr.indexOf("*/")>-1){
|
if(htmlStr.indexOf("/*")>-1&&htmlStr.indexOf("*/")>-1){
|
||||||
|
|
|
@ -12,14 +12,26 @@ import luckyclient.dblog.LogOperation;
|
||||||
import luckyclient.planapi.api.GetServerAPI;
|
import luckyclient.planapi.api.GetServerAPI;
|
||||||
import luckyclient.planapi.entity.ProjectCase;
|
import luckyclient.planapi.entity.ProjectCase;
|
||||||
import luckyclient.planapi.entity.ProjectCasesteps;
|
import luckyclient.planapi.entity.ProjectCasesteps;
|
||||||
|
import luckyclient.planapi.entity.PublicCaseParams;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class WebOneCaseExecute{
|
public class WebOneCaseExecute{
|
||||||
|
|
||||||
@SuppressWarnings("static-access")
|
@SuppressWarnings("static-access")
|
||||||
public static void OneCaseExecuteForTast(String projectname,String testCaseExternalId,int version,String taskid){
|
public static void oneCaseExecuteForTast(String projectname,String testCaseExternalId,int version,String taskid){
|
||||||
DbLink.exetype = 0; //记录日志到数据库
|
DbLink.exetype = 0; //记录日志到数据库
|
||||||
TestControl.TASKID = taskid;
|
TestControl.TASKID = taskid;
|
||||||
int drivertype = LogOperation.Querydrivertype(taskid);
|
int drivertype = LogOperation.querydrivertype(taskid);
|
||||||
WebDriver wd = null;
|
WebDriver wd = null;
|
||||||
try {
|
try {
|
||||||
wd = WebDriverInitialization.setWebDriverForTask(taskid,drivertype);
|
wd = WebDriverInitialization.setWebDriverForTask(taskid,drivertype);
|
||||||
|
@ -28,13 +40,14 @@ public class WebOneCaseExecute{
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
LogOperation caselog = new LogOperation(); // 初始化写用例结果以及日志模块
|
LogOperation caselog = new LogOperation(); // 初始化写用例结果以及日志模块
|
||||||
caselog.DeleteCaseDetail(testCaseExternalId, taskid); //删除旧的用例
|
LogOperation.deleteCaseDetail(testCaseExternalId, taskid); //删除旧的用例
|
||||||
caselog.DeleteCaseLogDetail(testCaseExternalId, taskid); //删除旧的日志
|
LogOperation.deleteCaseLogDetail(testCaseExternalId, taskid); //删除旧的日志
|
||||||
ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId);
|
ProjectCase testcase = GetServerAPI.cgetCaseBysign(testCaseExternalId);
|
||||||
|
List<PublicCaseParams> pcplist=GetServerAPI.cgetParamsByProjectid(String.valueOf(testcase.getProjectid()));
|
||||||
luckyclient.publicclass.LogUtil.APP.info("开始执行用例:【"+testCaseExternalId+"】......");
|
luckyclient.publicclass.LogUtil.APP.info("开始执行用例:【"+testCaseExternalId+"】......");
|
||||||
try {
|
try {
|
||||||
List<ProjectCasesteps> steps=GetServerAPI.getStepsbycaseid(testcase.getId());
|
List<ProjectCasesteps> steps=GetServerAPI.getStepsbycaseid(testcase.getId());
|
||||||
WebCaseExecution.CaseExcution(testcase, steps, taskid,wd,caselog);
|
WebCaseExecution.caseExcution(testcase, steps, taskid,wd,caselog,pcplist);
|
||||||
luckyclient.publicclass.LogUtil.APP.info("当前用例:【"+testcase.getSign()+"】执行完成......进入下一条");
|
luckyclient.publicclass.LogUtil.APP.info("当前用例:【"+testcase.getSign()+"】执行完成......进入下一条");
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||||
|
|
|
@ -13,13 +13,24 @@ import luckyclient.dblog.LogOperation;
|
||||||
import luckyclient.testlinkapi.TestBuildApi;
|
import luckyclient.testlinkapi.TestBuildApi;
|
||||||
import luckyclient.testlinkapi.TestCaseApi;
|
import luckyclient.testlinkapi.TestCaseApi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class WebBatchExecuteTestLink{
|
public class WebBatchExecuteTestLink{
|
||||||
|
|
||||||
@SuppressWarnings("static-access")
|
@SuppressWarnings("static-access")
|
||||||
public static void BatchCaseExecuteForTast(String projectname,String taskid,String batchcase) throws IOException{
|
public static void batchCaseExecuteForTast(String projectname,String taskid,String batchcase) throws IOException{
|
||||||
DbLink.exetype = 0; //记录日志到数据库
|
DbLink.exetype = 0; //记录日志到数据库
|
||||||
TestControl.TASKID = taskid;
|
TestControl.TASKID = taskid;
|
||||||
int drivertype = LogOperation.Querydrivertype(taskid);
|
int drivertype = LogOperation.querydrivertype(taskid);
|
||||||
WebDriver wd = null;
|
WebDriver wd = null;
|
||||||
try {
|
try {
|
||||||
wd = WebDriverInitialization.setWebDriverForTask(taskid,drivertype);
|
wd = WebDriverInitialization.setWebDriverForTask(taskid,drivertype);
|
||||||
|
@ -28,18 +39,18 @@ public class WebBatchExecuteTestLink{
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
LogOperation caselog = new LogOperation(); // 初始化写用例结果以及日志模块
|
LogOperation caselog = new LogOperation(); // 初始化写用例结果以及日志模块
|
||||||
TestBuildApi.GetBuild(projectname);
|
TestBuildApi.getBuild(projectname);
|
||||||
if(batchcase.indexOf("ALLFAIL")>-1){ //执行全部非成功状态用例
|
if(batchcase.indexOf("ALLFAIL")>-1){ //执行全部非成功状态用例
|
||||||
String casemore = caselog.UnSucCaseUpdate(taskid);
|
String casemore = caselog.unSucCaseUpdate(taskid);
|
||||||
String temp[]=casemore.split("\\#",-1);
|
String[] temp=casemore.split("\\#",-1);
|
||||||
for(int i=0;i<temp.length;i++){
|
for(int i=0;i<temp.length;i++){
|
||||||
String testCaseExternalId = temp[i].substring(0, temp[i].indexOf("%"));
|
String testCaseExternalId = temp[i].substring(0, temp[i].indexOf("%"));
|
||||||
int version = Integer.parseInt(temp[i].substring(temp[i].indexOf("%")+1,temp[i].length()-1));
|
int version = Integer.parseInt(temp[i].substring(temp[i].indexOf("%")+1,temp[i].length()-1));
|
||||||
TestCase testcase = TestCaseApi.getTestCaseByExternalId(testCaseExternalId, version);
|
TestCase testcase = TestCaseApi.getTestCaseByExternalId(testCaseExternalId, version);
|
||||||
caselog.DeleteCaseDetail(testCaseExternalId, taskid); //删除旧的用例
|
LogOperation.deleteCaseDetail(testCaseExternalId, taskid); //删除旧的用例
|
||||||
caselog.DeleteCaseLogDetail(testCaseExternalId, taskid); //删除旧的日志
|
LogOperation.deleteCaseLogDetail(testCaseExternalId, taskid); //删除旧的日志
|
||||||
try {
|
try {
|
||||||
WebCaseExecutionTestLink.CaseExcution(projectname,testcase, taskid,wd,caselog);
|
WebCaseExecutionTestLink.caseExcution(projectname,testcase, taskid,wd,caselog);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||||
|
@ -47,13 +58,13 @@ public class WebBatchExecuteTestLink{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{ //批量执行用例
|
}else{ //批量执行用例
|
||||||
String temp[]=batchcase.split("\\#",-1);
|
String[] temp=batchcase.split("\\#",-1);
|
||||||
for(int i=0;i<temp.length;i++){
|
for(int i=0;i<temp.length;i++){
|
||||||
String testCaseExternalId = temp[i].substring(0, temp[i].indexOf("%"));
|
String testCaseExternalId = temp[i].substring(0, temp[i].indexOf("%"));
|
||||||
int version = Integer.parseInt(temp[i].substring(temp[i].indexOf("%")+1,temp[i].length()));
|
int version = Integer.parseInt(temp[i].substring(temp[i].indexOf("%")+1,temp[i].length()));
|
||||||
TestCase testcase = TestCaseApi.getTestCaseByExternalId(testCaseExternalId, version);
|
TestCase testcase = TestCaseApi.getTestCaseByExternalId(testCaseExternalId, version);
|
||||||
try {
|
try {
|
||||||
WebCaseExecutionTestLink.CaseExcution(projectname,testcase, taskid,wd,caselog);
|
WebCaseExecutionTestLink.caseExcution(projectname,testcase, taskid,wd,caselog);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||||
|
|
|
@ -18,19 +18,30 @@ import luckyclient.dblog.LogOperation;
|
||||||
import luckyclient.publicclass.DBOperation;
|
import luckyclient.publicclass.DBOperation;
|
||||||
import luckyclient.testlinkapi.WebDriverAnalyticTestLinkCase;
|
import luckyclient.testlinkapi.WebDriverAnalyticTestLinkCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class WebCaseExecutionTestLink extends TestLinkCaseExecution{
|
public class WebCaseExecutionTestLink extends TestLinkCaseExecution{
|
||||||
static Map<String, String> variable = new HashMap<String, String>();
|
static Map<String, String> variable = new HashMap<String, String>();
|
||||||
|
|
||||||
public static void CaseExcution(String projectname, TestCase testcase, String taskid, WebDriver wd,LogOperation caselog)
|
public static void caseExcution(String projectname, TestCase testcase, String taskid, WebDriver wd,LogOperation caselog)
|
||||||
throws InterruptedException {
|
throws InterruptedException {
|
||||||
int setresult = 0; // 0:成功 1:失败 2:锁定 其他:锁定
|
int setresult = 0; // 0:成功 1:失败 2:锁定 其他:锁定
|
||||||
String casenote = "备注初始化";
|
String casenote = "备注初始化";
|
||||||
String imagname = "";
|
String imagname = "";
|
||||||
|
|
||||||
caselog.AddCaseDetail(taskid, testcase.getFullExternalId(), testcase.getVersion().toString(), testcase.getName(), 4); //插入开始执行的用例
|
caselog.addCaseDetail(taskid, testcase.getFullExternalId(), testcase.getVersion().toString(), testcase.getName(), 4); //插入开始执行的用例
|
||||||
|
|
||||||
for (TestCaseStep step : testcase.getSteps()) {
|
for (TestCaseStep step : testcase.getSteps()) {
|
||||||
Map<String, String> params = WebDriverAnalyticTestLinkCase.AnalyticCaseStep(testcase, step.getNumber(), taskid,caselog);
|
Map<String, String> params = WebDriverAnalyticTestLinkCase.analyticCaseStep(testcase, step.getNumber(), taskid,caselog);
|
||||||
|
|
||||||
if(params.get("exception")!=null&¶ms.get("exception").toString().indexOf("解析异常")>-1){
|
if(params.get("exception")!=null&¶ms.get("exception").toString().indexOf("解析异常")>-1){
|
||||||
setresult = 2;
|
setresult = 2;
|
||||||
|
@ -48,25 +59,25 @@ public class WebCaseExecutionTestLink extends TestLinkCaseExecution{
|
||||||
Thread.sleep(waitsec * 1000);
|
Thread.sleep(waitsec * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!expectedResults.equals("")) { // 有预期结果
|
if (!"".equals(expectedResults)) { // 有预期结果
|
||||||
// 判断传参
|
// 判断传参
|
||||||
luckyclient.publicclass.LogUtil.APP.info("expectedResults=【"+expectedResults+"】");
|
luckyclient.publicclass.LogUtil.APP.info("expectedResults=【"+expectedResults+"】");
|
||||||
if (expectedResults.length() > 2 && expectedResults.substring(0, 2).indexOf("$=") > -1) {
|
if (expectedResults.length() > 2 && expectedResults.substring(0, 2).indexOf("$=") > -1) {
|
||||||
String ExpectedResultVariable = expectedResults.substring(2);
|
String expectedResultVariable = expectedResults.substring(2);
|
||||||
variable.put(ExpectedResultVariable, result);
|
variable.put(expectedResultVariable, result);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 判断预期结果-检查模式
|
// 判断预期结果-检查模式
|
||||||
if (params.get("checkproperty") != null && params.get("checkproperty_value") != null) {
|
if (params.get("checkproperty") != null && params.get("checkproperty_value") != null) {
|
||||||
String checkproperty = params.get("checkproperty").toString();
|
String checkproperty = params.get("checkproperty").toString();
|
||||||
String checkproperty_value = params.get("checkproperty_value").toString();
|
String checkPropertyValue = params.get("checkproperty_value").toString();
|
||||||
|
|
||||||
WebElement we = isElementExist(wd, checkproperty, checkproperty_value);
|
WebElement we = isElementExist(wd, checkproperty, checkPropertyValue);
|
||||||
if (we != null) {
|
if (we != null) {
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getFullExternalId() + " 第" + step.getNumber()
|
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getFullExternalId() + " 第" + step.getNumber()
|
||||||
+ "步,在当前页面中找到预期结果中对象。当前步骤执行成功!");
|
+ "步,在当前页面中找到预期结果中对象。当前步骤执行成功!");
|
||||||
caselog.CaseLogDetail(taskid, testcase.getFullExternalId(), "在当前页面中找到预期结果中对象。当前步骤执行成功!",
|
caselog.caseLogDetail(taskid, testcase.getFullExternalId(), "在当前页面中找到预期结果中对象。当前步骤执行成功!",
|
||||||
"info", String.valueOf(step.getNumber()),"");
|
"info", String.valueOf(step.getNumber()),"");
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
|
@ -74,11 +85,11 @@ public class WebCaseExecutionTestLink extends TestLinkCaseExecution{
|
||||||
setresult = 1;
|
setresult = 1;
|
||||||
java.text.DateFormat timeformat = new java.text.SimpleDateFormat("MMdd-hhmmss");
|
java.text.DateFormat timeformat = new java.text.SimpleDateFormat("MMdd-hhmmss");
|
||||||
imagname = timeformat.format(new Date());
|
imagname = timeformat.format(new Date());
|
||||||
BaseWebDrive.WebScreenShot(wd,imagname);
|
BaseWebDrive.webScreenShot(wd,imagname);
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getFullExternalId() + " 第" + step.getNumber()
|
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getFullExternalId() + " 第" + step.getNumber()
|
||||||
+ "步,没有在当前页面中找到预期结果中对象。当前步骤执行失败!");
|
+ "步,没有在当前页面中找到预期结果中对象。当前步骤执行失败!");
|
||||||
caselog.CaseLogDetail(taskid, testcase.getFullExternalId(), "在当前页面中没有找到预期结果中对象。当前步骤执行失败!"
|
caselog.caseLogDetail(taskid, testcase.getFullExternalId(), "在当前页面中没有找到预期结果中对象。当前步骤执行失败!"
|
||||||
+ "checkproperty【"+checkproperty+"】 checkproperty_value【"+checkproperty_value+"】","error", String.valueOf(step.getNumber()),imagname);
|
+ "checkproperty【"+checkproperty+"】 checkproperty_value【"+checkPropertyValue+"】","error", String.valueOf(step.getNumber()),imagname);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +99,7 @@ public class WebCaseExecutionTestLink extends TestLinkCaseExecution{
|
||||||
if(result.indexOf(expectedResults.substring(2))>-1){
|
if(result.indexOf(expectedResults.substring(2))>-1){
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getFullExternalId() + " 第" + step.getNumber()
|
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getFullExternalId() + " 第" + step.getNumber()
|
||||||
+ "步,模糊匹配预期结果成功!执行结果:"+result);
|
+ "步,模糊匹配预期结果成功!执行结果:"+result);
|
||||||
caselog.CaseLogDetail(taskid, testcase.getFullExternalId(), "步骤模糊匹配预期结果成功!",
|
caselog.caseLogDetail(taskid, testcase.getFullExternalId(), "步骤模糊匹配预期结果成功!",
|
||||||
"info", String.valueOf(step.getNumber()),"");
|
"info", String.valueOf(step.getNumber()),"");
|
||||||
continue;
|
continue;
|
||||||
}else{
|
}else{
|
||||||
|
@ -96,17 +107,17 @@ public class WebCaseExecutionTestLink extends TestLinkCaseExecution{
|
||||||
setresult = 1;
|
setresult = 1;
|
||||||
java.text.DateFormat timeformat = new java.text.SimpleDateFormat("MMdd-hhmmss");
|
java.text.DateFormat timeformat = new java.text.SimpleDateFormat("MMdd-hhmmss");
|
||||||
imagname = timeformat.format(new Date());
|
imagname = timeformat.format(new Date());
|
||||||
BaseWebDrive.WebScreenShot(wd,imagname);
|
BaseWebDrive.webScreenShot(wd,imagname);
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getFullExternalId() + " 第" + step.getNumber()
|
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getFullExternalId() + " 第" + step.getNumber()
|
||||||
+ "步,模糊匹配预期结果失败!执行结果:"+result);
|
+ "步,模糊匹配预期结果失败!执行结果:"+result);
|
||||||
caselog.CaseLogDetail(taskid, testcase.getFullExternalId(), "步骤模糊匹配预期结果失败!执行结果:"+result,
|
caselog.caseLogDetail(taskid, testcase.getFullExternalId(), "步骤模糊匹配预期结果失败!执行结果:"+result,
|
||||||
"error", String.valueOf(step.getNumber()),imagname);
|
"error", String.valueOf(step.getNumber()),imagname);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}else if(expectedResults.equals(result)) { // 直接匹配预期结果模式
|
}else if(expectedResults.equals(result)) { // 直接匹配预期结果模式
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getFullExternalId() + " 第" + step.getNumber()
|
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getFullExternalId() + " 第" + step.getNumber()
|
||||||
+ "步,直接匹配预期结果成功!执行结果:"+result);
|
+ "步,直接匹配预期结果成功!执行结果:"+result);
|
||||||
caselog.CaseLogDetail(taskid, testcase.getFullExternalId(), "步骤直接匹配预期结果成功!",
|
caselog.caseLogDetail(taskid, testcase.getFullExternalId(), "步骤直接匹配预期结果成功!",
|
||||||
"info", String.valueOf(step.getNumber()),"");
|
"info", String.valueOf(step.getNumber()),"");
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
|
@ -114,10 +125,10 @@ public class WebCaseExecutionTestLink extends TestLinkCaseExecution{
|
||||||
setresult = 1;
|
setresult = 1;
|
||||||
java.text.DateFormat timeformat = new java.text.SimpleDateFormat("MMdd-hhmmss");
|
java.text.DateFormat timeformat = new java.text.SimpleDateFormat("MMdd-hhmmss");
|
||||||
imagname = timeformat.format(new Date());
|
imagname = timeformat.format(new Date());
|
||||||
BaseWebDrive.WebScreenShot(wd,imagname);
|
BaseWebDrive.webScreenShot(wd,imagname);
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getFullExternalId() + " 第" + step.getNumber()
|
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getFullExternalId() + " 第" + step.getNumber()
|
||||||
+ "步,直接匹配预期结果失败!执行结果:"+result);
|
+ "步,直接匹配预期结果失败!执行结果:"+result);
|
||||||
caselog.CaseLogDetail(taskid, testcase.getFullExternalId(), "步骤直接匹配预期结果失败!执行结果:"+result,
|
caselog.caseLogDetail(taskid, testcase.getFullExternalId(), "步骤直接匹配预期结果失败!执行结果:"+result,
|
||||||
"error", String.valueOf(step.getNumber()),imagname);
|
"error", String.valueOf(step.getNumber()),imagname);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -129,9 +140,9 @@ public class WebCaseExecutionTestLink extends TestLinkCaseExecution{
|
||||||
setresult = 2;
|
setresult = 2;
|
||||||
java.text.DateFormat timeformat = new java.text.SimpleDateFormat("MMdd-hhmmss");
|
java.text.DateFormat timeformat = new java.text.SimpleDateFormat("MMdd-hhmmss");
|
||||||
imagname = timeformat.format(new Date());
|
imagname = timeformat.format(new Date());
|
||||||
BaseWebDrive.WebScreenShot(wd,imagname);
|
BaseWebDrive.webScreenShot(wd,imagname);
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getFullExternalId() + " 第" + step.getNumber() + "步,"+result);
|
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getFullExternalId() + " 第" + step.getNumber() + "步,"+result);
|
||||||
caselog.CaseLogDetail(taskid, testcase.getFullExternalId(), "当前步骤在执行过程中解析|定位元素|操作对象失败!"+result,
|
caselog.caseLogDetail(taskid, testcase.getFullExternalId(), "当前步骤在执行过程中解析|定位元素|操作对象失败!"+result,
|
||||||
"error", String.valueOf(step.getNumber()),imagname);
|
"error", String.valueOf(step.getNumber()),imagname);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -139,13 +150,13 @@ public class WebCaseExecutionTestLink extends TestLinkCaseExecution{
|
||||||
}
|
}
|
||||||
|
|
||||||
variable.clear();
|
variable.clear();
|
||||||
caselog.UpdateCaseDetail(taskid, testcase.getFullExternalId(), setresult);
|
caselog.updateCaseDetail(taskid, testcase.getFullExternalId(), setresult);
|
||||||
if(setresult==0){
|
if(setresult==0){
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例【"+testcase.getFullExternalId()+"】全部步骤执行结果成功...");
|
luckyclient.publicclass.LogUtil.APP.info("用例【"+testcase.getFullExternalId()+"】全部步骤执行结果成功...");
|
||||||
caselog.CaseLogDetail(taskid, testcase.getFullExternalId(), "用例全部步骤执行结果成功","info", "ending","");
|
caselog.caseLogDetail(taskid, testcase.getFullExternalId(), "用例全部步骤执行结果成功","info", "ending","");
|
||||||
}else{
|
}else{
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcase.getFullExternalId()+"】步骤执行过程中失败或是锁定...请查看具体原因!"+casenote);
|
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcase.getFullExternalId()+"】步骤执行过程中失败或是锁定...请查看具体原因!"+casenote);
|
||||||
caselog.CaseLogDetail(taskid, testcase.getFullExternalId(), "用例执行过程中失败或是锁定"+casenote,"error", "ending","");
|
caselog.caseLogDetail(taskid, testcase.getFullExternalId(), "用例执行过程中失败或是锁定"+casenote,"error", "ending","");
|
||||||
}
|
}
|
||||||
//LogOperation.UpdateTastdetail(taskid, 0);
|
//LogOperation.UpdateTastdetail(taskid, 0);
|
||||||
}
|
}
|
||||||
|
@ -153,53 +164,53 @@ public class WebCaseExecutionTestLink extends TestLinkCaseExecution{
|
||||||
private static String runStep(Map<String, String> params, WebDriver wd,String taskid,String casenum,int stepno,LogOperation caselog) {
|
private static String runStep(Map<String, String> params, WebDriver wd,String taskid,String casenum,int stepno,LogOperation caselog) {
|
||||||
String result = "";
|
String result = "";
|
||||||
String property;
|
String property;
|
||||||
String property_value;
|
String propertyValue;
|
||||||
String operation;
|
String operation;
|
||||||
String operation_value;
|
String operationValue;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
property = params.get("property");
|
property = params.get("property");
|
||||||
property_value = params.get("property_value");
|
propertyValue = params.get("property_value");
|
||||||
operation = params.get("operation");
|
operation = params.get("operation");
|
||||||
operation_value = params.get("operation_value");
|
operationValue = params.get("operation_value");
|
||||||
|
|
||||||
// 用例名称解析出现异常或是单个步骤参数解析异常
|
// 用例名称解析出现异常或是单个步骤参数解析异常
|
||||||
if (property_value != null && property.indexOf("解析异常") > -1) {
|
if (propertyValue != null && property.indexOf("解析异常") > -1) {
|
||||||
luckyclient.publicclass.LogUtil.APP.error("当前步骤解析出现异常或是对象为空!---"+property);
|
luckyclient.publicclass.LogUtil.APP.error("当前步骤解析出现异常或是对象为空!---"+property);
|
||||||
return "用例解析出错啦!";
|
return "用例解析出错啦!";
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理值传递
|
// 处理值传递
|
||||||
if (property_value != null && property_value.indexOf("@") > -1 && property_value.indexOf("[@") < 0
|
if (propertyValue != null && propertyValue.indexOf("@") > -1 && propertyValue.indexOf("[@") < 0
|
||||||
&& property_value.indexOf("@@") < 0) {
|
&& propertyValue.indexOf("@@") < 0) {
|
||||||
property_value = SettingParameter(property_value);
|
propertyValue = settingParameter(propertyValue);
|
||||||
// 判断传参是否存在问题
|
// 判断传参是否存在问题
|
||||||
if (property_value.indexOf("Set parameter error") > -1) {
|
if (propertyValue.indexOf("Set parameter error") > -1) {
|
||||||
caselog.CaseLogDetail(taskid, casenum, "当前步骤解析出现异常或是对象为空!---"+property,
|
caselog.caseLogDetail(taskid, casenum, "当前步骤解析出现异常或是对象为空!---"+property,
|
||||||
"error", String.valueOf(stepno),"");
|
"error", String.valueOf(stepno),"");
|
||||||
return "处理传参过程出错:" + property_value;
|
return "处理传参过程出错:" + propertyValue;
|
||||||
}
|
}
|
||||||
}else if(property_value != null && (property_value.indexOf(""")>-1
|
}else if(propertyValue != null && (propertyValue.indexOf(""")>-1
|
||||||
|| property_value.indexOf("'")>-1 || property_value.indexOf("@@")>-1)){
|
|| propertyValue.indexOf("'")>-1 || propertyValue.indexOf("@@")>-1)){
|
||||||
property_value = property_value.replaceAll(""", "\"");
|
propertyValue = propertyValue.replaceAll(""", "\"");
|
||||||
property_value = property_value.replaceAll("'", "\'");
|
propertyValue = propertyValue.replaceAll("'", "\'");
|
||||||
property_value = property_value.replaceAll("@@", "@");
|
propertyValue = propertyValue.replaceAll("@@", "@");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (operation_value != null && operation_value.indexOf("@") > -1 && operation_value.indexOf("@@") < 0) {
|
if (operationValue != null && operationValue.indexOf("@") > -1 && operationValue.indexOf("@@") < 0) {
|
||||||
operation_value = SettingParameter(operation_value);
|
operationValue = settingParameter(operationValue);
|
||||||
if (operation_value.indexOf("Set parameter error") > -1) {
|
if (operationValue.indexOf("Set parameter error") > -1) {
|
||||||
return "处理传参过程出错:" + property_value;
|
return "处理传参过程出错:" + propertyValue;
|
||||||
}
|
}
|
||||||
}else if(operation_value != null && (operation_value.indexOf(""")>-1
|
}else if(operationValue != null && (operationValue.indexOf(""")>-1
|
||||||
|| operation_value.indexOf("'")>-1 || operation_value.indexOf("@@")>-1)){
|
|| operationValue.indexOf("'")>-1 || operationValue.indexOf("@@")>-1)){
|
||||||
operation_value = operation_value.replaceAll(""", "\"");
|
operationValue = operationValue.replaceAll(""", "\"");
|
||||||
operation_value = operation_value.replaceAll("'", "\'");
|
operationValue = operationValue.replaceAll("'", "\'");
|
||||||
operation_value = operation_value.replaceAll("@@", "@");
|
operationValue = operationValue.replaceAll("@@", "@");
|
||||||
}
|
}
|
||||||
|
|
||||||
luckyclient.publicclass.LogUtil.APP.info("二次解析用例过程完成,等待进行对象操作......");
|
luckyclient.publicclass.LogUtil.APP.info("二次解析用例过程完成,等待进行对象操作......");
|
||||||
caselog.CaseLogDetail(taskid, casenum, "对象操作:"+operation+"; 操作值:"+operation_value,"info", String.valueOf(stepno),"");
|
caselog.caseLogDetail(taskid, casenum, "对象操作:"+operation+"; 操作值:"+operationValue,"info", String.valueOf(stepno),"");
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -209,9 +220,9 @@ public class WebCaseExecutionTestLink extends TestLinkCaseExecution{
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//调用接口用例
|
//调用接口用例
|
||||||
if(operation!=null&&operation_value!=null&&"runcase".equals(operation)){
|
if(operation!=null&&operationValue!=null&&"runcase".equals(operation)){
|
||||||
String temp[]=operation_value.split(",",-1);
|
String[] temp=operationValue.split(",",-1);
|
||||||
String ex = TestLinkCaseExecution.OneCaseExecuteForWebDriver(temp[0], Integer.valueOf(temp[1]),taskid,caselog);
|
String ex = TestLinkCaseExecution.oneCaseExecuteForWebDriver(temp[0], Integer.valueOf(temp[1]),taskid,caselog);
|
||||||
if(ex.indexOf("CallCase调用出错!")<=-1&&ex.indexOf("解析出错啦!")<=-1&&ex.indexOf("匹配失败")<=-1){
|
if(ex.indexOf("CallCase调用出错!")<=-1&&ex.indexOf("解析出错啦!")<=-1&&ex.indexOf("匹配失败")<=-1){
|
||||||
return ex;
|
return ex;
|
||||||
}else{
|
}else{
|
||||||
|
@ -221,8 +232,8 @@ public class WebCaseExecutionTestLink extends TestLinkCaseExecution{
|
||||||
|
|
||||||
WebElement we = null;
|
WebElement we = null;
|
||||||
|
|
||||||
if (property != null && property_value != null) { // 页面元素层
|
if (property != null && propertyValue != null) { // 页面元素层
|
||||||
we = isElementExist(wd, property, property_value);
|
we = isElementExist(wd, property, propertyValue);
|
||||||
// 判断此元素是否存在
|
// 判断此元素是否存在
|
||||||
if (we == null) {
|
if (we == null) {
|
||||||
luckyclient.publicclass.LogUtil.APP.error("定位对象失败,isElementExist为null!");
|
luckyclient.publicclass.LogUtil.APP.error("定位对象失败,isElementExist为null!");
|
||||||
|
@ -230,22 +241,22 @@ public class WebCaseExecutionTestLink extends TestLinkCaseExecution{
|
||||||
}
|
}
|
||||||
|
|
||||||
if (operation.indexOf("select") > -1) {
|
if (operation.indexOf("select") > -1) {
|
||||||
result = EncapsulateOperation.SelectOperation(we, operation, operation_value);
|
result = EncapsulateOperation.selectOperation(we, operation, operationValue);
|
||||||
} else if (operation.indexOf("get") > -1){
|
} else if (operation.indexOf("get") > -1){
|
||||||
result = EncapsulateOperation.GetOperation(wd, we, operation);
|
result = EncapsulateOperation.getOperation(wd, we, operation);
|
||||||
} else if (operation.indexOf("mouse") > -1){
|
} else if (operation.indexOf("mouse") > -1){
|
||||||
result = EncapsulateOperation.ActionWeOperation(wd, we, operation, operation_value, property, property_value);
|
result = EncapsulateOperation.actionWeOperation(wd, we, operation, operationValue, property, propertyValue);
|
||||||
} else {
|
} else {
|
||||||
result = EncapsulateOperation.ObjectOperation(wd, we, operation, operation_value, property, property_value);
|
result = EncapsulateOperation.objectOperation(wd, we, operation, operationValue, property, propertyValue);
|
||||||
}
|
}
|
||||||
} else if (property == null && operation != null) { // Driver层操作
|
} else if (property == null && operation != null) { // Driver层操作
|
||||||
// 处理弹出框事件
|
// 处理弹出框事件
|
||||||
if (operation.indexOf("alert") > -1){
|
if (operation.indexOf("alert") > -1){
|
||||||
result = EncapsulateOperation.AlertOperation(wd, operation);
|
result = EncapsulateOperation.alertOperation(wd, operation);
|
||||||
}else if(operation.indexOf("mouse") > -1){
|
}else if(operation.indexOf("mouse") > -1){
|
||||||
result = EncapsulateOperation.ActionOperation(wd, operation, operation_value);
|
result = EncapsulateOperation.actionOperation(wd, operation, operationValue);
|
||||||
}else{
|
}else{
|
||||||
result = EncapsulateOperation.DriverOperation(wd, operation, operation_value);
|
result = EncapsulateOperation.driverOperation(wd, operation, operationValue);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
luckyclient.publicclass.LogUtil.APP.error("元素操作过程失败!");
|
luckyclient.publicclass.LogUtil.APP.error("元素操作过程失败!");
|
||||||
|
@ -255,7 +266,7 @@ public class WebCaseExecutionTestLink extends TestLinkCaseExecution{
|
||||||
luckyclient.publicclass.LogUtil.APP.error("元素定位过程或是操作过程失败或异常!"+e.getMessage());
|
luckyclient.publicclass.LogUtil.APP.error("元素定位过程或是操作过程失败或异常!"+e.getMessage());
|
||||||
return "元素定位过程或是操作过程失败或异常!" + e.getMessage();
|
return "元素定位过程或是操作过程失败或异常!" + e.getMessage();
|
||||||
}
|
}
|
||||||
caselog.CaseLogDetail(taskid, casenum, result,"info", String.valueOf(stepno),"");
|
caselog.caseLogDetail(taskid, casenum, result,"info", String.valueOf(stepno),"");
|
||||||
|
|
||||||
if(result.indexOf("获取到的值是【")>-1&&result.indexOf("】")>-1){
|
if(result.indexOf("获取到的值是【")>-1&&result.indexOf("】")>-1){
|
||||||
result = result.substring(7, result.length()-1);
|
result = result.substring(7, result.length()-1);
|
||||||
|
@ -264,7 +275,7 @@ public class WebCaseExecutionTestLink extends TestLinkCaseExecution{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String SettingParameter(String parameter) {
|
private static String settingParameter(String parameter) {
|
||||||
int keyexistidentity = 0;
|
int keyexistidentity = 0;
|
||||||
if (parameter.indexOf(""") > -1 || parameter.indexOf("'") > -1) { // 页面转义字符转换
|
if (parameter.indexOf(""") > -1 || parameter.indexOf("'") > -1) { // 页面转义字符转换
|
||||||
parameter = parameter.replaceAll(""", "\"");
|
parameter = parameter.replaceAll(""", "\"");
|
||||||
|
@ -333,19 +344,19 @@ public class WebCaseExecutionTestLink extends TestLinkCaseExecution{
|
||||||
}
|
}
|
||||||
if (keyexistidentity == 1) {
|
if (keyexistidentity == 1) {
|
||||||
// 拼装参数(传参+原有字符串)
|
// 拼装参数(传参+原有字符串)
|
||||||
String ParameterValues = parameter.replaceAll("@" + uservariable, variable.get(uservariable).toString());
|
String parameterValues = parameter.replaceAll("@" + uservariable, variable.get(uservariable).toString());
|
||||||
// 处理第二个传参
|
// 处理第二个传参
|
||||||
if (sumvariable == 2 || sumvariable == 3) {
|
if (sumvariable == 2 || sumvariable == 3) {
|
||||||
ParameterValues = ParameterValues.replaceAll("@" + uservariable1,
|
parameterValues = parameterValues.replaceAll("@" + uservariable1,
|
||||||
variable.get(uservariable1).toString());
|
variable.get(uservariable1).toString());
|
||||||
}
|
}
|
||||||
// 处理第三个传参
|
// 处理第三个传参
|
||||||
if (sumvariable == 3) {
|
if (sumvariable == 3) {
|
||||||
ParameterValues = ParameterValues.replaceAll("@" + uservariable2,
|
parameterValues = parameterValues.replaceAll("@" + uservariable2,
|
||||||
variable.get(uservariable2).toString());
|
variable.get(uservariable2).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return ParameterValues;
|
return parameterValues;
|
||||||
} else {
|
} else {
|
||||||
luckyclient.publicclass.LogUtil.APP.error("没有找到你要的变量哦,再找下吧!第一个变量名称是:" + uservariable + ",第" + "二个变量名称是:" + uservariable1
|
luckyclient.publicclass.LogUtil.APP.error("没有找到你要的变量哦,再找下吧!第一个变量名称是:" + uservariable + ",第" + "二个变量名称是:" + uservariable1
|
||||||
+ ",第三个变量名称是:" + uservariable2);
|
+ ",第三个变量名称是:" + uservariable2);
|
||||||
|
@ -354,29 +365,29 @@ public class WebCaseExecutionTestLink extends TestLinkCaseExecution{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static WebElement isElementExist(WebDriver wd, String property, String property_value) {
|
public static WebElement isElementExist(WebDriver wd, String property, String propertyValue) {
|
||||||
try {
|
try {
|
||||||
WebElement we = null;
|
WebElement we = null;
|
||||||
|
|
||||||
// 处理WebElement对象定位
|
// 处理WebElement对象定位
|
||||||
switch (property) {
|
switch (property) {
|
||||||
case "id":
|
case "id":
|
||||||
we = wd.findElement(By.id(property_value));
|
we = wd.findElement(By.id(propertyValue));
|
||||||
break;
|
break;
|
||||||
case "name":
|
case "name":
|
||||||
we = wd.findElement(By.name(property_value));
|
we = wd.findElement(By.name(propertyValue));
|
||||||
break;
|
break;
|
||||||
case "xpath":
|
case "xpath":
|
||||||
we = wd.findElement(By.xpath(property_value));
|
we = wd.findElement(By.xpath(propertyValue));
|
||||||
break;
|
break;
|
||||||
case "linktext":
|
case "linktext":
|
||||||
we = wd.findElement(By.linkText(property_value));
|
we = wd.findElement(By.linkText(propertyValue));
|
||||||
break;
|
break;
|
||||||
case "tagname":
|
case "tagname":
|
||||||
we = wd.findElement(By.tagName(property_value));
|
we = wd.findElement(By.tagName(propertyValue));
|
||||||
break;
|
break;
|
||||||
case "cssselector":
|
case "cssselector":
|
||||||
we = wd.findElement(By.cssSelector(property_value));
|
we = wd.findElement(By.cssSelector(propertyValue));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -12,13 +12,24 @@ import luckyclient.dblog.LogOperation;
|
||||||
import luckyclient.testlinkapi.TestBuildApi;
|
import luckyclient.testlinkapi.TestBuildApi;
|
||||||
import luckyclient.testlinkapi.TestCaseApi;
|
import luckyclient.testlinkapi.TestCaseApi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class WebOneCaseExecuteTestLink{
|
public class WebOneCaseExecuteTestLink{
|
||||||
|
|
||||||
@SuppressWarnings("static-access")
|
@SuppressWarnings("static-access")
|
||||||
public static void OneCaseExecuteForTast(String projectname,String testCaseExternalId,int version,String taskid){
|
public static void oneCaseExecuteForTast(String projectname,String testCaseExternalId,int version,String taskid){
|
||||||
DbLink.exetype = 0; //记录日志到数据库
|
DbLink.exetype = 0; //记录日志到数据库
|
||||||
TestControl.TASKID = taskid;
|
TestControl.TASKID = taskid;
|
||||||
int drivertype = LogOperation.Querydrivertype(taskid);
|
int drivertype = LogOperation.querydrivertype(taskid);
|
||||||
WebDriver wd = null;
|
WebDriver wd = null;
|
||||||
try {
|
try {
|
||||||
wd = WebDriverInitialization.setWebDriverForTask(taskid,drivertype);
|
wd = WebDriverInitialization.setWebDriverForTask(taskid,drivertype);
|
||||||
|
@ -27,13 +38,13 @@ public class WebOneCaseExecuteTestLink{
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
LogOperation caselog = new LogOperation(); // 初始化写用例结果以及日志模块
|
LogOperation caselog = new LogOperation(); // 初始化写用例结果以及日志模块
|
||||||
caselog.DeleteCaseDetail(testCaseExternalId, taskid); //删除旧的用例
|
LogOperation.deleteCaseDetail(testCaseExternalId, taskid); //删除旧的用例
|
||||||
caselog.DeleteCaseLogDetail(testCaseExternalId, taskid); //删除旧的日志
|
LogOperation.deleteCaseLogDetail(testCaseExternalId, taskid); //删除旧的日志
|
||||||
TestBuildApi.GetBuild(projectname);
|
TestBuildApi.getBuild(projectname);
|
||||||
TestCase testcase = TestCaseApi.getTestCaseByExternalId(testCaseExternalId, version);
|
TestCase testcase = TestCaseApi.getTestCaseByExternalId(testCaseExternalId, version);
|
||||||
luckyclient.publicclass.LogUtil.APP.info("开始执行用例:【"+testCaseExternalId+"】......");
|
luckyclient.publicclass.LogUtil.APP.info("开始执行用例:【"+testCaseExternalId+"】......");
|
||||||
try {
|
try {
|
||||||
WebCaseExecutionTestLink.CaseExcution(projectname,testcase, taskid,wd,caselog);
|
WebCaseExecutionTestLink.caseExcution(projectname,testcase, taskid,wd,caselog);
|
||||||
luckyclient.publicclass.LogUtil.APP.info("当前用例:【"+testcase.getFullExternalId()+"】执行完成......进入下一条");
|
luckyclient.publicclass.LogUtil.APP.info("当前用例:【"+testcase.getFullExternalId()+"】执行完成......进入下一条");
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
luckyclient.publicclass.LogUtil.APP.error("用户执行过程中抛出异常!", e);
|
||||||
|
|
|
@ -18,6 +18,17 @@ import org.openqa.selenium.WebDriver;
|
||||||
import org.openqa.selenium.WebElement;
|
import org.openqa.selenium.WebElement;
|
||||||
import org.openqa.selenium.remote.Augmenter;
|
import org.openqa.selenium.remote.Augmenter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class Ocr {
|
public class Ocr {
|
||||||
private static String readtextpath = System.getProperty("user.dir")+"\\CAPTCHA.txt"; //默认读取工程根目录下的文件
|
private static String readtextpath = System.getProperty("user.dir")+"\\CAPTCHA.txt"; //默认读取工程根目录下的文件
|
||||||
private static String screenshotpath = System.getProperty("user.dir")+"\\CAPTCHA.png"; //默认把截图放在工程根目录
|
private static String screenshotpath = System.getProperty("user.dir")+"\\CAPTCHA.png"; //默认把截图放在工程根目录
|
||||||
|
|
|
@ -4,6 +4,17 @@ import java.util.Properties;
|
||||||
|
|
||||||
import luckyclient.publicclass.DBOperation;
|
import luckyclient.publicclass.DBOperation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class DbLink {
|
public class DbLink {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,13 +29,13 @@ public class DbLink {
|
||||||
* @date 2015年4月20日 上午9:29:40
|
* @date 2015年4月20日 上午9:29:40
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static DBOperation DbLogLink(){
|
public static DBOperation dbLogLink(){
|
||||||
Properties properties = luckyclient.publicclass.SysConfig.getConfiguration();
|
Properties properties = luckyclient.publicclass.SysConfig.getConfiguration();
|
||||||
String url_base = "jdbc:mysql://"+properties.getProperty("mysql.db.ip")+":"+properties.getProperty("mysql.db.port")
|
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";
|
+"/"+properties.getProperty("mysql.db.dbname")+"?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&useSSL=false";
|
||||||
String username_base = properties.getProperty("mysql.db.username");
|
String userNameBase = properties.getProperty("mysql.db.username");
|
||||||
String password_base = properties.getProperty("mysql.db.userpwd");
|
String passwordBase = properties.getProperty("mysql.db.userpwd");
|
||||||
return new DBOperation(url_base, username_base, password_base);
|
return new DBOperation(urlBase, userNameBase, passwordBase);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int exetype; //任务执行类型: 0 任务调度模式 1 控制台模式
|
public static int exetype; //任务执行类型: 0 任务调度模式 1 控制台模式
|
||||||
|
|
|
@ -8,8 +8,8 @@ import luckyclient.publicclass.DBOperation;
|
||||||
/**
|
/**
|
||||||
* =================================================================
|
* =================================================================
|
||||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
* 此测试框架主要采用testlink做分层框架,负责数据驱动以及用例管理部分,有任何疑问欢迎联系作者讨论。
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
* QQ:24163551 seagull1985
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
* =================================================================
|
* =================================================================
|
||||||
* @ClassName: LogOperation
|
* @ClassName: LogOperation
|
||||||
* @Description: 日志写入数据库
|
* @Description: 日志写入数据库
|
||||||
|
@ -18,14 +18,14 @@ import luckyclient.publicclass.DBOperation;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class LogOperation {
|
public class LogOperation {
|
||||||
public static DBOperation dbt = DbLink.DbLogLink();
|
public static DBOperation dbt = DbLink.dbLogLink();
|
||||||
static int exetype = DbLink.exetype;
|
static int exetype = DbLink.exetype;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 插入用例执行状态
|
* 插入用例执行状态
|
||||||
* casestatus pass:0 fail:1 lock:2 unexecute:4
|
* casestatus pass:0 fail:1 lock:2 unexecute:4
|
||||||
*/
|
*/
|
||||||
public void AddCaseDetail(String taskid,String caseno,String caseversion,String casename,Integer casestatus){
|
public void addCaseDetail(String taskid,String caseno,String caseversion,String casename,Integer casestatus){
|
||||||
if(0 == exetype){
|
if(0 == exetype){
|
||||||
int taskidtoint = Integer.parseInt(taskid);
|
int taskidtoint = Integer.parseInt(taskid);
|
||||||
casename = casename.replace("'", "''");
|
casename = casename.replace("'", "''");
|
||||||
|
@ -46,7 +46,7 @@ public class LogOperation {
|
||||||
* 更新用例执行状态
|
* 更新用例执行状态
|
||||||
* casestatus pass:0 fail:1 lock:2 unexecute:4
|
* casestatus pass:0 fail:1 lock:2 unexecute:4
|
||||||
*/
|
*/
|
||||||
public void UpdateCaseDetail(String taskid,String caseno,Integer casestatus){
|
public void updateCaseDetail(String taskid,String caseno,Integer casestatus){
|
||||||
if(0 == exetype){
|
if(0 == exetype){
|
||||||
int taskidtoint = Integer.parseInt(taskid);
|
int taskidtoint = Integer.parseInt(taskid);
|
||||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //设置日期格式
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //设置日期格式
|
||||||
|
@ -63,7 +63,7 @@ public class LogOperation {
|
||||||
/*
|
/*
|
||||||
* 插入用例执行日志
|
* 插入用例执行日志
|
||||||
*/
|
*/
|
||||||
public void CaseLogDetail(String taskid,String caseno,String detail,String loggrade,String step,String imgname) {
|
public void caseLogDetail(String taskid,String caseno,String detail,String loggrade,String step,String imgname) {
|
||||||
if(0 == exetype){
|
if(0 == exetype){
|
||||||
if(detail.indexOf("'")>-1){
|
if(detail.indexOf("'")>-1){
|
||||||
detail = detail.replaceAll("'", "''");
|
detail = detail.replaceAll("'", "''");
|
||||||
|
@ -102,7 +102,7 @@ public class LogOperation {
|
||||||
/*
|
/*
|
||||||
*更新本次任务的执行统计情况
|
*更新本次任务的执行统计情况
|
||||||
*/
|
*/
|
||||||
public static int[] UpdateTastdetail(String taskid,int casecount){
|
public static int[] updateTastdetail(String taskid,int casecount){
|
||||||
int[] taskcount = null;
|
int[] taskcount = null;
|
||||||
if(0 == exetype){
|
if(0 == exetype){
|
||||||
try {
|
try {
|
||||||
|
@ -146,7 +146,7 @@ public class LogOperation {
|
||||||
/*
|
/*
|
||||||
*更新本次任务的执行状态
|
*更新本次任务的执行状态
|
||||||
*/
|
*/
|
||||||
public static void UpdateTastStatus(String taskid,int casecount){
|
public static void updateTastStatus(String taskid,int casecount){
|
||||||
if(0 == exetype){
|
if(0 == exetype){
|
||||||
try {
|
try {
|
||||||
int id = Integer.parseInt(taskid);
|
int id = Integer.parseInt(taskid);
|
||||||
|
@ -163,7 +163,7 @@ public class LogOperation {
|
||||||
/*
|
/*
|
||||||
*更新本次任务的单条用例执行日志
|
*更新本次任务的单条用例执行日志
|
||||||
*/
|
*/
|
||||||
public static void UpdateCaseLogDetail(String caseno,String taskid,String detail,String loggrade,String step) {
|
public static void updateCaseLogDetail(String caseno,String taskid,String detail,String loggrade,String step) {
|
||||||
try {
|
try {
|
||||||
if(detail.indexOf("'")>-1){
|
if(detail.indexOf("'")>-1){
|
||||||
detail = detail.replaceAll("'", "''");
|
detail = detail.replaceAll("'", "''");
|
||||||
|
@ -192,7 +192,7 @@ public class LogOperation {
|
||||||
/*
|
/*
|
||||||
* 删除单次任务指定的用例日志明细
|
* 删除单次任务指定的用例日志明细
|
||||||
*/
|
*/
|
||||||
public static void DeleteCaseLogDetail(String caseno,String taskid){
|
public static void deleteCaseLogDetail(String caseno,String taskid){
|
||||||
int inttaskid = Integer.parseInt(taskid);
|
int inttaskid = Integer.parseInt(taskid);
|
||||||
String casesidsql;
|
String casesidsql;
|
||||||
try {
|
try {
|
||||||
|
@ -208,7 +208,7 @@ public class LogOperation {
|
||||||
/*
|
/*
|
||||||
* 删除单次任务指定的用例明细
|
* 删除单次任务指定的用例明细
|
||||||
*/
|
*/
|
||||||
public static void DeleteCaseDetail(String caseno, String taskid) {
|
public static void deleteCaseDetail(String caseno, String taskid) {
|
||||||
int inttaskid = Integer.parseInt(taskid);
|
int inttaskid = Integer.parseInt(taskid);
|
||||||
try {
|
try {
|
||||||
dbt.executeSql("delete from TEST_CASEDETAIL where caseno = '" + caseno + "' and taskid = " + inttaskid); // 删除原来的用例
|
dbt.executeSql("delete from TEST_CASEDETAIL where caseno = '" + caseno + "' and taskid = " + inttaskid); // 删除原来的用例
|
||||||
|
@ -221,7 +221,7 @@ public class LogOperation {
|
||||||
/*
|
/*
|
||||||
* 取出指定任务ID中的不属于成功状态的用例编写以及版本号
|
* 取出指定任务ID中的不属于成功状态的用例编写以及版本号
|
||||||
*/
|
*/
|
||||||
public String UnSucCaseUpdate(String taskid){
|
public String unSucCaseUpdate(String taskid){
|
||||||
int inttaskid = Integer.parseInt(taskid);
|
int inttaskid = Integer.parseInt(taskid);
|
||||||
String casesidsql = null;
|
String casesidsql = null;
|
||||||
try {
|
try {
|
||||||
|
@ -239,14 +239,14 @@ public class LogOperation {
|
||||||
eMailer varchar(100) ; --收件人
|
eMailer varchar(100) ; --收件人
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("finally")
|
@SuppressWarnings("finally")
|
||||||
public static String[] GetEmailAddress(String taskid){
|
public static String[] getEmailAddress(String taskid){
|
||||||
int inttaskid = Integer.parseInt(taskid);
|
int inttaskid = Integer.parseInt(taskid);
|
||||||
String casesidsql = null;
|
String casesidsql = null;
|
||||||
String address[] = null;
|
String[] address = null;
|
||||||
try {
|
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+")");
|
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("%"));
|
String status = casesidsql.substring(0, casesidsql.indexOf("%"));
|
||||||
if(status.equals("1")){
|
if("1".equals(status)){
|
||||||
String temp = casesidsql.substring(casesidsql.indexOf("%")+1,casesidsql.length()-1);
|
String temp = casesidsql.substring(casesidsql.indexOf("%")+1,casesidsql.length()-1);
|
||||||
if(temp.indexOf(";")>-1&&temp.substring(temp.length()-1, temp.length()).indexOf(";")>-1){ //清除最后一个;
|
if(temp.indexOf(";")>-1&&temp.substring(temp.length()-1, temp.length()).indexOf(";")>-1){ //清除最后一个;
|
||||||
temp = temp.substring(0, temp.length()-1);
|
temp = temp.substring(0, temp.length()-1);
|
||||||
|
@ -261,9 +261,9 @@ public class LogOperation {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}finally{
|
|
||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
return address;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -272,14 +272,14 @@ public class LogOperation {
|
||||||
BuildName varchar(100) ; --构建项目名称
|
BuildName varchar(100) ; --构建项目名称
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("finally")
|
@SuppressWarnings("finally")
|
||||||
public static String[] GetBuildName(String taskid){
|
public static String[] getBuildName(String taskid){
|
||||||
int inttaskid = Integer.parseInt(taskid);
|
int inttaskid = Integer.parseInt(taskid);
|
||||||
String casesidsql = null;
|
String casesidsql = null;
|
||||||
String buildname[] = null;
|
String[] buildname = null;
|
||||||
try {
|
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+")");
|
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+")");
|
||||||
String status = casesidsql.substring(0, casesidsql.indexOf("%"));
|
String status = casesidsql.substring(0, casesidsql.indexOf("%"));
|
||||||
if(status.equals("1")){
|
if("1".equals(status)){
|
||||||
String temp = casesidsql.substring(casesidsql.indexOf("%")+1,casesidsql.length()-1);
|
String temp = casesidsql.substring(casesidsql.indexOf("%")+1,casesidsql.length()-1);
|
||||||
if(temp.indexOf(";")>-1&&temp.substring(temp.length()-1, temp.length()).indexOf(";")>-1){ //清除最后一个;
|
if(temp.indexOf(";")>-1&&temp.substring(temp.length()-1, temp.length()).indexOf(";")>-1){ //清除最后一个;
|
||||||
temp = temp.substring(0, temp.length()-1);
|
temp = temp.substring(0, temp.length()-1);
|
||||||
|
@ -294,9 +294,9 @@ public class LogOperation {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}finally{
|
|
||||||
return buildname;
|
return buildname;
|
||||||
}
|
}
|
||||||
|
return buildname;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -307,14 +307,14 @@ public class LogOperation {
|
||||||
例:10.211.19.72;pospsettle;pospsettle;22;cd /home/pospsettle/tomcat-7.0-7080/bin&&./restart.sh;
|
例:10.211.19.72;pospsettle;pospsettle;22;cd /home/pospsettle/tomcat-7.0-7080/bin&&./restart.sh;
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("finally")
|
@SuppressWarnings("finally")
|
||||||
public static String[] Getrestartcomm(String taskid){
|
public static String[] getrestartcomm(String taskid){
|
||||||
int inttaskid = Integer.parseInt(taskid);
|
int inttaskid = Integer.parseInt(taskid);
|
||||||
String casesidsql = null;
|
String casesidsql = null;
|
||||||
String command[] = null;
|
String[] command = null;
|
||||||
try {
|
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+")");
|
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+")");
|
||||||
String status = casesidsql.substring(0, casesidsql.indexOf("%"));
|
String status = casesidsql.substring(0, casesidsql.indexOf("%"));
|
||||||
if(status.equals("1")){
|
if("1".equals(status)){
|
||||||
String temp = casesidsql.substring(casesidsql.indexOf("%")+1,casesidsql.length()-1);
|
String temp = casesidsql.substring(casesidsql.indexOf("%")+1,casesidsql.length()-1);
|
||||||
if(temp.indexOf(";")>-1&&temp.substring(temp.length()-1, temp.length()).indexOf(";")>-1){ //清除最后一个;
|
if(temp.indexOf(";")>-1&&temp.substring(temp.length()-1, temp.length()).indexOf(";")>-1){ //清除最后一个;
|
||||||
temp = temp.substring(0, temp.length()-1);
|
temp = temp.substring(0, temp.length()-1);
|
||||||
|
@ -329,9 +329,10 @@ public class LogOperation {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}finally{
|
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
return command;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -339,7 +340,7 @@ public class LogOperation {
|
||||||
* 获取测试计划名称
|
* 获取测试计划名称
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("finally")
|
@SuppressWarnings("finally")
|
||||||
public static String GetTestPlanName(String taskid) {
|
public static String getTestPlanName(String taskid) {
|
||||||
int inttaskid = Integer.parseInt(taskid);
|
int inttaskid = Integer.parseInt(taskid);
|
||||||
String testplanname = "NULL";
|
String testplanname = "NULL";
|
||||||
try {
|
try {
|
||||||
|
@ -350,18 +351,18 @@ public class LogOperation {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
|
||||||
return testplanname;
|
return testplanname;
|
||||||
}
|
}
|
||||||
|
return testplanname;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 获取任务测试时长
|
* 获取任务测试时长
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("finally")
|
@SuppressWarnings("finally")
|
||||||
public static String GetTestTime(String taskid) {
|
public static String getTestTime(String taskid) {
|
||||||
int inttaskid = Integer.parseInt(taskid);
|
int inttaskid = Integer.parseInt(taskid);
|
||||||
String Destime = "计算测试时长出错!";
|
String desTime = "计算测试时长出错!";
|
||||||
try {
|
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 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 starttime = sql.substring(0, sql.indexOf("%"));
|
||||||
|
@ -374,19 +375,19 @@ public class LogOperation {
|
||||||
long hour=(l/(60*60*1000)-day*24);
|
long hour=(l/(60*60*1000)-day*24);
|
||||||
long min=((l/(60*1000))-day*24*60-hour*60);
|
long min=((l/(60*1000))-day*24*60-hour*60);
|
||||||
long s=(l/1000-day*24*60*60-hour*60*60-min*60);
|
long s=(l/1000-day*24*60*60-hour*60*60-min*60);
|
||||||
Destime = "<font color='#2828FF'>"+hour+"</font>小时<font color='#2828FF'>"+min+"</font>分<font color='#2828FF'>"+s+"</font>秒";
|
desTime = "<font color='#2828FF'>"+hour+"</font>小时<font color='#2828FF'>"+min+"</font>分<font color='#2828FF'>"+s+"</font>秒";
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
return desTime;
|
||||||
return Destime;
|
|
||||||
}
|
}
|
||||||
|
return desTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 查询web执行,浏览器类型
|
* 查询web执行,浏览器类型
|
||||||
*/
|
*/
|
||||||
public static int Querydrivertype(String taskid) {
|
public static int querydrivertype(String taskid) {
|
||||||
int taskidtoint = Integer.parseInt(taskid);
|
int taskidtoint = Integer.parseInt(taskid);
|
||||||
int drivertype=0;
|
int drivertype=0;
|
||||||
try {
|
try {
|
||||||
|
@ -403,7 +404,7 @@ public class LogOperation {
|
||||||
/*
|
/*
|
||||||
* 查询任务中用例步骤日志执行实际结果
|
* 查询任务中用例步骤日志执行实际结果
|
||||||
*/
|
*/
|
||||||
public static String getlogdetail_testresult(int taskid,String caseno,int casestatus) {
|
public static String getLogDetailTestResult(int taskid,String caseno,int casestatus) {
|
||||||
String sqlresult="";
|
String sqlresult="";
|
||||||
try {
|
try {
|
||||||
sqlresult = dbt.executeQuery("select detail from test_logdetail where logid=(select MIN(logid) from test_logdetail "
|
sqlresult = dbt.executeQuery("select detail from test_logdetail where logid=(select MIN(logid) from test_logdetail "
|
||||||
|
@ -424,7 +425,7 @@ public class LogOperation {
|
||||||
/*
|
/*
|
||||||
* 根据任务名称查询任务ID
|
* 根据任务名称查询任务ID
|
||||||
*/
|
*/
|
||||||
public static int gettaskexcute_taskid(String taskname) {
|
public static int getTaskExcuteTaskid(String taskname) {
|
||||||
String sqlresult="";
|
String sqlresult="";
|
||||||
try {
|
try {
|
||||||
sqlresult = dbt.executeQuery("select id from test_taskexcute t where t.taskid='"+taskname+"'");
|
sqlresult = dbt.executeQuery("select id from test_taskexcute t where t.taskid='"+taskname+"'");
|
||||||
|
@ -441,7 +442,7 @@ public class LogOperation {
|
||||||
* 查询任务中用例步骤日志预期结果
|
* 查询任务中用例步骤日志预期结果
|
||||||
* 2017-09-16
|
* 2017-09-16
|
||||||
*/
|
*/
|
||||||
public static String getlogdetail_expectresult(int taskid,String caseno,int casestatus) {
|
public static String getLogDetailExpectResult(int taskid,String caseno,int casestatus) {
|
||||||
String sqlresult="";
|
String sqlresult="";
|
||||||
try {
|
try {
|
||||||
sqlresult = dbt.executeQuery("select detail from test_logdetail where logid=(select MIN(logid) from test_logdetail "
|
sqlresult = dbt.executeQuery("select detail from test_logdetail where logid=(select MIN(logid) from test_logdetail "
|
||||||
|
|
|
@ -2,15 +2,26 @@ package luckyclient.jenkinsapi;
|
||||||
|
|
||||||
import luckyclient.dblog.LogOperation;
|
import luckyclient.dblog.LogOperation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class BuildingInitialization {
|
public class BuildingInitialization {
|
||||||
|
|
||||||
public static String BooleanBuildingOver(String[] buildname) throws InterruptedException{
|
public static String booleanBuildingOver(String[] buildname) throws InterruptedException{
|
||||||
String buildresult = "Status:true"+" 项目全部构建成功!";
|
String buildresult = "Status:true"+" 项目全部构建成功!";
|
||||||
int k;
|
int k;
|
||||||
for(int i=0;i<300;i++){
|
for(int i=0;i<300;i++){
|
||||||
k=0;
|
k=0;
|
||||||
for(int j=0;j<buildname.length;j++){
|
for(int j=0;j<buildname.length;j++){
|
||||||
String result = JenkinsBuilding.BuildingResult(buildname[i]);
|
String result = JenkinsBuilding.buildingResult(buildname[i]);
|
||||||
if(result.indexOf("alt=\"Failed\"")>-1){
|
if(result.indexOf("alt=\"Failed\"")>-1){
|
||||||
buildresult = "项目"+buildname[i]+"构建失败,自动化测试退出!";
|
buildresult = "项目"+buildname[i]+"构建失败,自动化测试退出!";
|
||||||
luckyclient.publicclass.LogUtil.APP.error("项目"+buildname[i]+"构建失败,自动化测试退出!");
|
luckyclient.publicclass.LogUtil.APP.error("项目"+buildname[i]+"构建失败,自动化测试退出!");
|
||||||
|
@ -32,10 +43,10 @@ public class BuildingInitialization {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("finally")
|
@SuppressWarnings("finally")
|
||||||
public static String BuildingRun(String tastid) throws InterruptedException{
|
public static String buildingRun(String tastid) throws InterruptedException{
|
||||||
String result = "Status:true"+" 当前任务没有找到需要构建的项目!";
|
String result = "Status:true"+" 当前任务没有找到需要构建的项目!";
|
||||||
try{
|
try{
|
||||||
String[] buildname = LogOperation.GetBuildName(tastid);
|
String[] buildname = LogOperation.getBuildName(tastid);
|
||||||
|
|
||||||
if(buildname!=null){
|
if(buildname!=null){
|
||||||
luckyclient.publicclass.LogUtil.APP.info("准备将配置的测试项目进行构建!请稍等。。。。");
|
luckyclient.publicclass.LogUtil.APP.info("准备将配置的测试项目进行构建!请稍等。。。。");
|
||||||
|
@ -43,7 +54,7 @@ public class BuildingInitialization {
|
||||||
JenkinsBuilding.sendBuilding(buildname[i], 0);
|
JenkinsBuilding.sendBuilding(buildname[i], 0);
|
||||||
}
|
}
|
||||||
Thread.sleep(10000); //等待构建检查
|
Thread.sleep(10000); //等待构建检查
|
||||||
result = BooleanBuildingOver(buildname);
|
result = booleanBuildingOver(buildname);
|
||||||
}else{
|
}else{
|
||||||
luckyclient.publicclass.LogUtil.APP.info("当前任务没有找到需要构建的项目!");
|
luckyclient.publicclass.LogUtil.APP.info("当前任务没有找到需要构建的项目!");
|
||||||
}
|
}
|
||||||
|
@ -51,9 +62,9 @@ public class BuildingInitialization {
|
||||||
luckyclient.publicclass.LogUtil.APP.error("项目构建过程中出现异常");
|
luckyclient.publicclass.LogUtil.APP.error("项目构建过程中出现异常");
|
||||||
luckyclient.publicclass.LogUtil.APP.error(e);
|
luckyclient.publicclass.LogUtil.APP.error(e);
|
||||||
result = "项目构建过程中出现异常";
|
result = "项目构建过程中出现异常";
|
||||||
}finally{
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,17 @@ import java.net.URLConnection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class JenkinsBuilding {
|
public class JenkinsBuilding {
|
||||||
/**
|
/**
|
||||||
* 向指定URL发送GET方法的请求
|
* 向指定URL发送GET方法的请求
|
||||||
|
@ -75,7 +86,7 @@ public class JenkinsBuilding {
|
||||||
*
|
*
|
||||||
* alt="Success" alt="In progress" alt="Failed"
|
* alt="Success" alt="In progress" alt="Failed"
|
||||||
*/
|
*/
|
||||||
public static String BuildingResult(String buildname) {
|
public static String buildingResult(String buildname) {
|
||||||
String result = "";
|
String result = "";
|
||||||
BufferedReader in = null;
|
BufferedReader in = null;
|
||||||
try {
|
try {
|
||||||
|
@ -124,11 +135,7 @@ public class JenkinsBuilding {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
//发送 GET 请求
|
|
||||||
//http://10.211.19.19:18080/jenkins/job/72_deploy_settle_check_server/lastBuild/
|
|
||||||
String s=JenkinsBuilding.BuildingResult("deploy-abc-b2cApi");
|
|
||||||
System.out.println(s);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,13 +2,24 @@ package luckyclient.jenkinsapi;
|
||||||
|
|
||||||
import luckyclient.dblog.LogOperation;
|
import luckyclient.dblog.LogOperation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class RestartServerInitialization {
|
public class RestartServerInitialization {
|
||||||
|
|
||||||
@SuppressWarnings("finally")
|
@SuppressWarnings("finally")
|
||||||
public static String RestartServerRun(String tastid){
|
public static String restartServerRun(String tastid){
|
||||||
String result = "Status:true"+" 重启命令执行成功!";
|
String result = "Status:true"+" 重启命令执行成功!";
|
||||||
try{
|
try{
|
||||||
String[] command = LogOperation.Getrestartcomm(tastid);
|
String[] command = LogOperation.getrestartcomm(tastid);
|
||||||
if(command!=null){
|
if(command!=null){
|
||||||
luckyclient.publicclass.LogUtil.APP.info("准备重启指定的TOMCAT!请稍等。。。参数个数:"+command.length);
|
luckyclient.publicclass.LogUtil.APP.info("准备重启指定的TOMCAT!请稍等。。。参数个数:"+command.length);
|
||||||
if(command.length==5){
|
if(command.length==5){
|
||||||
|
@ -27,15 +38,14 @@ public class RestartServerInitialization {
|
||||||
luckyclient.publicclass.LogUtil.APP.error("重启TOMCAT过程中出现异常");
|
luckyclient.publicclass.LogUtil.APP.error("重启TOMCAT过程中出现异常");
|
||||||
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(),e);
|
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(),e);
|
||||||
result = "重启TOMCAT过程中出现异常";
|
result = "重启TOMCAT过程中出现异常";
|
||||||
}finally{
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
RestartServerRun("1460");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,11 +102,12 @@ public class RmtShellExecutor {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
result = "重启TOMCAT过程中,出现异常!";
|
result = "重启TOMCAT过程中,出现异常!";
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
return result;
|
||||||
} finally {
|
} finally {
|
||||||
session.disconnect();
|
session.disconnect();
|
||||||
channel.disconnect();
|
channel.disconnect();
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String args[]) throws Exception {
|
public static void main(String args[]) throws Exception {
|
||||||
|
|
|
@ -3,10 +3,21 @@ package luckyclient.mail;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class HtmlMail {
|
public class HtmlMail {
|
||||||
static FreemarkerEmailTemplate fet=new FreemarkerEmailTemplate();
|
static FreemarkerEmailTemplate fet=new FreemarkerEmailTemplate();
|
||||||
|
|
||||||
public static String HtmlContentFormat(int[] taskcount,String taskid,String buildstatus,String restartstatus,String time,String jobname){
|
public static String htmlContentFormat(int[] taskcount,String taskid,String buildstatus,String restartstatus,String time,String jobname){
|
||||||
Map<Object, Object> parameters = new HashMap<Object, Object>();
|
Map<Object, Object> parameters = new HashMap<Object, Object>();
|
||||||
parameters.put("buildstatus", buildstatus);
|
parameters.put("buildstatus", buildstatus);
|
||||||
parameters.put("restartstatus", restartstatus);
|
parameters.put("restartstatus", restartstatus);
|
||||||
|
@ -17,7 +28,7 @@ public class HtmlMail {
|
||||||
return fet.getText("task-body", parameters);
|
return fet.getText("task-body", parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String HtmlSubjectFormat(String jobname){
|
public static String htmlSubjectFormat(String jobname){
|
||||||
Map<Object, Object> parameters = new HashMap<Object, Object>();
|
Map<Object, Object> parameters = new HashMap<Object, Object>();
|
||||||
parameters.put("jobname", jobname);
|
parameters.put("jobname", jobname);
|
||||||
return fet.getText("task-title", parameters);
|
return fet.getText("task-title", parameters);
|
||||||
|
|
|
@ -4,10 +4,21 @@ import java.util.Properties;
|
||||||
|
|
||||||
import luckyclient.dblog.LogOperation;
|
import luckyclient.dblog.LogOperation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class MailSendInitialization {
|
public class MailSendInitialization {
|
||||||
|
|
||||||
public static void SendMailInitialization(String subject,String content,String taskid){
|
public static void sendMailInitialization(String subject,String content,String taskid){
|
||||||
String[] addresses = LogOperation.GetEmailAddress(taskid);
|
String[] addresses = LogOperation.getEmailAddress(taskid);
|
||||||
Properties properties = luckyclient.publicclass.SysConfig.getConfiguration();
|
Properties properties = luckyclient.publicclass.SysConfig.getConfiguration();
|
||||||
if(addresses!=null){
|
if(addresses!=null){
|
||||||
luckyclient.publicclass.LogUtil.APP.info("准备将测试结果发送邮件通知!请稍等。。。。");
|
luckyclient.publicclass.LogUtil.APP.info("准备将测试结果发送邮件通知!请稍等。。。。");
|
||||||
|
@ -37,9 +48,6 @@ public class MailSendInitialization {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
int[] taskcount = {79,78,1,0,0};
|
|
||||||
String test = HtmlMail.HtmlContentFormat(taskcount, "220", "Status:true 当前任务没有找到需要构建的项目!", "Status:true 当前任务没有找到需要重启的TOMCAT命令!", "0小时1分1秒","testtask");
|
|
||||||
MailSendInitialization.SendMailInitialization("test", test, "220");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,17 @@
|
||||||
package luckyclient.mail;
|
package luckyclient.mail;
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
/**
|
/**
|
||||||
* 发送邮件需要使用的基本信息
|
* =================================================================
|
||||||
*/
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class MailSenderInfo {
|
public class MailSenderInfo {
|
||||||
// 发送邮件的服务器的IP和端口
|
// 发送邮件的服务器的IP和端口
|
||||||
private String mailServerHost;
|
private String mailServerHost;
|
||||||
|
|
|
@ -2,16 +2,29 @@ package luckyclient.mail;
|
||||||
|
|
||||||
import javax.mail.*;
|
import javax.mail.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class MyAuthenticator extends Authenticator{
|
public class MyAuthenticator extends Authenticator{
|
||||||
String userName=null;
|
String userName=null;
|
||||||
String password=null;
|
String password=null;
|
||||||
|
|
||||||
public MyAuthenticator(){
|
public MyAuthenticator(){
|
||||||
}
|
}
|
||||||
|
|
||||||
public MyAuthenticator(String username, String password) {
|
public MyAuthenticator(String username, String password) {
|
||||||
this.userName = username;
|
this.userName = username;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
protected PasswordAuthentication getPasswordAuthentication(){
|
protected PasswordAuthentication getPasswordAuthentication(){
|
||||||
return new PasswordAuthentication(userName, password);
|
return new PasswordAuthentication(userName, password);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,11 +14,18 @@ import javax.mail.internet.InternetAddress;
|
||||||
import javax.mail.internet.MimeBodyPart;
|
import javax.mail.internet.MimeBodyPart;
|
||||||
import javax.mail.internet.MimeMessage;
|
import javax.mail.internet.MimeMessage;
|
||||||
import javax.mail.internet.MimeMultipart;
|
import javax.mail.internet.MimeMultipart;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 简单邮件(不带附件的邮件)发送器
|
* =================================================================
|
||||||
http://www.bt285.cn BT下载
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
*/
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class SimpleMailSender {
|
public class SimpleMailSender {
|
||||||
/**
|
/**
|
||||||
* 以文本格式发送邮件
|
* 以文本格式发送邮件
|
||||||
|
|
|
@ -5,12 +5,24 @@ import java.util.List;
|
||||||
|
|
||||||
import luckyclient.planapi.entity.ProjectCase;
|
import luckyclient.planapi.entity.ProjectCase;
|
||||||
import luckyclient.planapi.entity.ProjectCasesteps;
|
import luckyclient.planapi.entity.ProjectCasesteps;
|
||||||
|
import luckyclient.planapi.entity.PublicCaseParams;
|
||||||
import luckyclient.planapi.entity.TestTaskexcute;
|
import luckyclient.planapi.entity.TestTaskexcute;
|
||||||
import luckyclient.publicclass.remoterInterface.HttpRequest;
|
import luckyclient.publicclass.remoterinterface.HttpRequest;
|
||||||
import net.sf.json.JSONArray;
|
import net.sf.json.JSONArray;
|
||||||
import net.sf.json.JSONObject;
|
import net.sf.json.JSONObject;
|
||||||
import net.sf.json.JsonConfig;
|
import net.sf.json.JsonConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class GetServerAPI {
|
public class GetServerAPI {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -54,6 +66,15 @@ public class GetServerAPI {
|
||||||
return pc;
|
return pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<PublicCaseParams> cgetParamsByProjectid(String projectid) {
|
||||||
|
String result = HttpRequest.loadJSON("/publicCaseParams/cgetParamsByProjectid.do?projectid="+projectid);
|
||||||
|
JSONObject jsonObject = JSONObject.fromObject(result.toString());
|
||||||
|
JSONArray jsonarr = JSONArray.fromObject(jsonObject.getString("params"));
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<PublicCaseParams> list = JSONArray.toList(jsonarr, new PublicCaseParams(), new JsonConfig());
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
public static void cPostDebugLog(String sign, String executor, String loglevel, String detail){
|
public static void cPostDebugLog(String sign, String executor, String loglevel, String detail){
|
||||||
sign = sign.replace("%","BBFFHH");
|
sign = sign.replace("%","BBFFHH");
|
||||||
sign = sign.replace("=","DHDHDH");
|
sign = sign.replace("=","DHDHDH");
|
||||||
|
|
|
@ -1,5 +1,16 @@
|
||||||
package luckyclient.planapi.entity;
|
package luckyclient.planapi.entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class ProjectCase implements java.io.Serializable{
|
public class ProjectCase implements java.io.Serializable{
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,5 +1,16 @@
|
||||||
package luckyclient.planapi.entity;
|
package luckyclient.planapi.entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class ProjectCasesteps implements java.io.Serializable{
|
public class ProjectCasesteps implements java.io.Serializable{
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,5 +1,16 @@
|
||||||
package luckyclient.planapi.entity;
|
package luckyclient.planapi.entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class ProjectPlan implements java.io.Serializable{
|
public class ProjectPlan implements java.io.Serializable{
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,5 +1,16 @@
|
||||||
package luckyclient.planapi.entity;
|
package luckyclient.planapi.entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class ProjectPlanCase implements java.io.Serializable{
|
public class ProjectPlanCase implements java.io.Serializable{
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,5 +1,16 @@
|
||||||
package luckyclient.planapi.entity;
|
package luckyclient.planapi.entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class ProjectProtocolTemplate{
|
public class ProjectProtocolTemplate{
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,5 +1,16 @@
|
||||||
package luckyclient.planapi.entity;
|
package luckyclient.planapi.entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class ProjectTemplateParams{
|
public class ProjectTemplateParams{
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -9,6 +20,14 @@ public class ProjectTemplateParams{
|
||||||
private int templateid;
|
private int templateid;
|
||||||
private String paramname;
|
private String paramname;
|
||||||
private String param;
|
private String param;
|
||||||
|
private int paramtype;
|
||||||
|
|
||||||
|
public int getParamtype() {
|
||||||
|
return paramtype;
|
||||||
|
}
|
||||||
|
public void setParamtype(int paramtype) {
|
||||||
|
this.paramtype = paramtype;
|
||||||
|
}
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
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,5 +1,16 @@
|
||||||
package luckyclient.planapi.entity;
|
package luckyclient.planapi.entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class TestJobs implements java.io.Serializable {
|
public class TestJobs implements java.io.Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,16 @@
|
||||||
package luckyclient.planapi.entity;
|
package luckyclient.planapi.entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class TestTaskexcute implements java.io.Serializable {
|
public class TestTaskexcute implements java.io.Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
package luckyclient.publicclass;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ChangString {
|
||||||
|
|
||||||
|
public static String changparams(String str,Map<String,String> variable,String changname){
|
||||||
|
try{
|
||||||
|
if(null==str){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
str = str.replaceAll(""", "\"");
|
||||||
|
str = str.replaceAll("'", "\'");
|
||||||
|
//@@用来注释@的引用作用
|
||||||
|
int varcount=counter(str,"@")-counter(str,"@@")*2;
|
||||||
|
if(varcount>0){//如果存在传参,进行处理
|
||||||
|
luckyclient.publicclass.LogUtil.APP.info("在"+changname+"【"+str+"】中找到"+varcount+"个可替换参数");
|
||||||
|
int changcount=0;
|
||||||
|
//从参数列表中查找匹配变量
|
||||||
|
for (Map.Entry<String, String> entry : variable.entrySet()) {
|
||||||
|
if(str.indexOf("@"+entry.getKey())>-1){
|
||||||
|
if(str.indexOf("@@"+entry.getKey())>-1){
|
||||||
|
str=str.replaceAll("@@"+entry.getKey(), "////CHANG////");
|
||||||
|
}
|
||||||
|
int viewcount=counter(str,"@"+entry.getKey());
|
||||||
|
str=str.replaceAll("@"+entry.getKey(), entry.getValue());
|
||||||
|
luckyclient.publicclass.LogUtil.APP.info("将"+changname+"引用变量【@"+entry.getKey()+"】替换成值【"+entry.getValue()+"】");
|
||||||
|
str=str.replaceAll("////CHANG////","@@"+entry.getKey());
|
||||||
|
changcount=changcount+viewcount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(varcount!=changcount){
|
||||||
|
luckyclient.publicclass.LogUtil.APP.error(changname+"有引用变量未在参数列中找到,请检查!处理结果【"+str+"】");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
str=str.replaceAll("@@","@");
|
||||||
|
return str;
|
||||||
|
}catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int counter(String str1,String str2){
|
||||||
|
int total = 0;
|
||||||
|
for (String tmp = str1; tmp != null&&tmp.length()>=str2.length();){
|
||||||
|
if(tmp.indexOf(str2) == 0){
|
||||||
|
total ++;
|
||||||
|
tmp = tmp.substring(str2.length());
|
||||||
|
}else{
|
||||||
|
tmp = tmp.substring(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -7,8 +7,8 @@ import java.sql.SQLException;
|
||||||
/**
|
/**
|
||||||
* =================================================================
|
* =================================================================
|
||||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
* 此测试框架主要采用testlink做分层框架,负责数据驱动以及用例管理部分,有任何疑问欢迎联系作者讨论。
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
* QQ:24163551 seagull1985
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
* =================================================================
|
* =================================================================
|
||||||
* @ClassName: DBOperation
|
* @ClassName: DBOperation
|
||||||
* @Description: 封装自动化过程中,对数据库的部分操作
|
* @Description: 封装自动化过程中,对数据库的部分操作
|
||||||
|
@ -22,8 +22,8 @@ public class DBOperation {
|
||||||
/**
|
/**
|
||||||
* 创建链接池,注意此方法不能new多次,会导致多次创建链接池,最好放在任务启动方法中
|
* 创建链接池,注意此方法不能new多次,会导致多次创建链接池,最好放在任务启动方法中
|
||||||
*/
|
*/
|
||||||
public DBOperation(String url_base,String username_base,String password_base) {
|
public DBOperation(String urlBase,String usernameBase,String passwordBase) {
|
||||||
dbt = new DBToolkit(url_base,username_base,password_base);
|
dbt = new DBToolkit(urlBase,usernameBase,passwordBase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -90,8 +90,9 @@ public class DBOperation {
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
throw e;
|
throw e;
|
||||||
}finally{
|
}finally{
|
||||||
if(rs!=null)
|
if(rs!=null){
|
||||||
rs.close();
|
rs.close();
|
||||||
|
}
|
||||||
DBToolkit.closeConnection(conn);
|
DBToolkit.closeConnection(conn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,7 +143,7 @@ public class DBOperation {
|
||||||
* @return int
|
* @return int
|
||||||
* @throws
|
* @throws
|
||||||
*/
|
*/
|
||||||
public static void Wait(String s) throws InterruptedException{
|
public static void stepWait(String s) throws InterruptedException{
|
||||||
int second = Integer.parseInt(s);
|
int second = Integer.parseInt(s);
|
||||||
Thread.sleep(second*1000);
|
Thread.sleep(second*1000);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,8 @@ import com.mchange.v2.c3p0.ComboPooledDataSource;
|
||||||
/**
|
/**
|
||||||
* =================================================================
|
* =================================================================
|
||||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
* 此测试框架主要采用testlink做分层框架,负责数据驱动以及用例管理部分,有任何疑问欢迎联系作者讨论。
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
* QQ:24163551 seagull1985
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
* =================================================================
|
* =================================================================
|
||||||
* @ClassName: DBToolkit
|
* @ClassName: DBToolkit
|
||||||
* @Description: 创建与关闭数据库链接
|
* @Description: 创建与关闭数据库链接
|
||||||
|
@ -26,11 +26,11 @@ public class DBToolkit {
|
||||||
*/
|
*/
|
||||||
public ComboPooledDataSource cpds=null;
|
public ComboPooledDataSource cpds=null;
|
||||||
|
|
||||||
public DBToolkit(String url_base,String username_base,String password_base){
|
public DBToolkit(String urlBase,String usernameBase,String passwordBase){
|
||||||
cpds=new ComboPooledDataSource();
|
cpds=new ComboPooledDataSource();
|
||||||
cpds.setUser(username_base);
|
cpds.setUser(usernameBase);
|
||||||
cpds.setPassword(password_base);
|
cpds.setPassword(passwordBase);
|
||||||
cpds.setJdbcUrl(url_base);
|
cpds.setJdbcUrl(urlBase);
|
||||||
try {
|
try {
|
||||||
cpds.setDriverClass("com.mysql.cj.jdbc.Driver");
|
cpds.setDriverClass("com.mysql.cj.jdbc.Driver");
|
||||||
} catch (PropertyVetoException e) {
|
} catch (PropertyVetoException e) {
|
||||||
|
@ -113,7 +113,9 @@ public class DBToolkit {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void closeConnection(Connection conn) {
|
public static void closeConnection(Connection conn) {
|
||||||
if (conn == null) return;
|
if (conn == null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
if (!conn.isClosed()) {
|
if (!conn.isClosed()) {
|
||||||
//关闭数据库连接
|
//关闭数据库连接
|
||||||
|
|
|
@ -7,8 +7,8 @@ import java.util.Map;
|
||||||
|
|
||||||
import luckyclient.planapi.entity.ProjectProtocolTemplate;
|
import luckyclient.planapi.entity.ProjectProtocolTemplate;
|
||||||
import luckyclient.planapi.entity.ProjectTemplateParams;
|
import luckyclient.planapi.entity.ProjectTemplateParams;
|
||||||
import luckyclient.publicclass.remoterInterface.HttpClientHelper;
|
import luckyclient.publicclass.remoterinterface.HttpClientHelper;
|
||||||
import luckyclient.publicclass.remoterInterface.HttpRequest;
|
import luckyclient.publicclass.remoterinterface.HttpRequest;
|
||||||
import net.sf.json.JSONArray;
|
import net.sf.json.JSONArray;
|
||||||
import net.sf.json.JSONObject;
|
import net.sf.json.JSONObject;
|
||||||
import net.sf.json.JsonConfig;
|
import net.sf.json.JsonConfig;
|
||||||
|
@ -16,12 +16,14 @@ import net.sf.json.JsonConfig;
|
||||||
/**
|
/**
|
||||||
* =================================================================
|
* =================================================================
|
||||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
* 此测试框架主要采用testlink做分层框架,负责数据驱动以及用例管理部分,有任何疑问欢迎联系作者讨论。 QQ:24163551 seagull1985
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
* =================================================================
|
* =================================================================
|
||||||
*
|
*
|
||||||
* @ClassName: InvokeMethod
|
* @ClassName: InvokeMethod
|
||||||
* @Description: 动态调用方法 @author: seagull
|
* @Description: 动态调用方法
|
||||||
* @date 2014年6月24日 上午9:29:40
|
* @author: seagull
|
||||||
|
* @date 2017年9月24日 上午9:29:40
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class InvokeMethod {
|
public class InvokeMethod {
|
||||||
|
@ -30,7 +32,7 @@ public class InvokeMethod {
|
||||||
* @param args
|
* @param args
|
||||||
* @throws Throwable
|
* @throws Throwable
|
||||||
*/
|
*/
|
||||||
public static String CallCase(String packagename, String functionname, Object[] getParameterValues, int steptype,
|
public static String callCase(String packagename, String functionname, Object[] getParameterValues, int steptype,
|
||||||
String action) {
|
String action) {
|
||||||
String result = "调用异常,请查看错误日志!";
|
String result = "调用异常,请查看错误日志!";
|
||||||
try {
|
try {
|
||||||
|
@ -49,7 +51,7 @@ public class InvokeMethod {
|
||||||
Method method = getMethod(server.getClass().getMethods(), functionname, getParameterTypes);
|
Method method = getMethod(server.getClass().getMethods(), functionname, getParameterTypes);
|
||||||
if (method == null) {
|
if (method == null) {
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
"客户端本地lib目录下没有在包名为【" + packagename + "】中找到被调用的方法【" + functionname + "】,请检查方法名称以及参数个数是否一致!");
|
"客户端本地驱动目录下没有在包名为【" + packagename + "】中找到被调用的方法【" + functionname + "】,请检查方法名称以及参数个数是否一致!");
|
||||||
}
|
}
|
||||||
Object str = method.invoke(server, getParameterValues);
|
Object str = method.invoke(server, getParameterValues);
|
||||||
if (str == null) {
|
if (str == null) {
|
||||||
|
@ -107,12 +109,23 @@ public class InvokeMethod {
|
||||||
if(ptp.getParam().indexOf("***[")>-1&&"***[".equals(ptp.getParam().substring(0, 4))){
|
if(ptp.getParam().indexOf("***[")>-1&&"***[".equals(ptp.getParam().substring(0, 4))){
|
||||||
ptp.setParam(ptp.getParam().substring(3));
|
ptp.setParam(ptp.getParam().substring(3));
|
||||||
}
|
}
|
||||||
params.put(ptp.getParamname().replaceAll(""", "\""), ptp.getParam().replaceAll(""", "\""));
|
//处理参数对象
|
||||||
|
if(ptp.getParamtype()==1){
|
||||||
|
String tempparam=ptp.getParam().replaceAll(""", "\"");
|
||||||
|
JSONObject json= JSONObject.fromObject(tempparam);
|
||||||
|
params.put(ptp.getParamname().replaceAll(""", "\""), json);
|
||||||
|
}else if(ptp.getParamtype()==2){
|
||||||
|
String tempparam=ptp.getParam().replaceAll(""", "\"");
|
||||||
|
JSONArray jarr=JSONArray.fromObject(tempparam);
|
||||||
|
params.put(ptp.getParamname().replaceAll(""", "\""), jarr);
|
||||||
|
}else{
|
||||||
|
params.put(ptp.getParamname().replaceAll(""", "\""), ptp.getParam().replaceAll(""", "\""));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//处理头域
|
//处理头域
|
||||||
Map<String, String> headmsg = new HashMap<String, String>();
|
Map<String, String> headmsg = new HashMap<String, String>();
|
||||||
if(null!=ppt.getHeadmsg()&&!ppt.getHeadmsg().equals("")&&ppt.getHeadmsg().indexOf("=")>0){
|
if(null!=ppt.getHeadmsg()&&!ppt.getHeadmsg().equals("")&&ppt.getHeadmsg().indexOf("=")>0){
|
||||||
String temp[]=ppt.getHeadmsg().split(";",-1);
|
String[] temp=ppt.getHeadmsg().split(";",-1);
|
||||||
for(int i=0;i<temp.length;i++){
|
for(int i=0;i<temp.length;i++){
|
||||||
if(null!=temp[i]&&!temp[i].equals("")&&temp[i].indexOf("=")>0){
|
if(null!=temp[i]&&!temp[i].equals("")&&temp[i].indexOf("=")>0){
|
||||||
String key=temp[i].substring(0, temp[i].indexOf("="));
|
String key=temp[i].substring(0, temp[i].indexOf("="));
|
||||||
|
@ -213,12 +226,23 @@ public class InvokeMethod {
|
||||||
if(ptp.getParam().indexOf("***[")>-1&&"***[".equals(ptp.getParam().substring(0, 4))){
|
if(ptp.getParam().indexOf("***[")>-1&&"***[".equals(ptp.getParam().substring(0, 4))){
|
||||||
ptp.setParam(ptp.getParam().substring(3));
|
ptp.setParam(ptp.getParam().substring(3));
|
||||||
}
|
}
|
||||||
params.put(ptp.getParamname().replaceAll(""", "\""), ptp.getParam().replaceAll(""", "\""));
|
//处理参数对象
|
||||||
|
if(ptp.getParamtype()==1){
|
||||||
|
String tempparam=ptp.getParam().replaceAll(""", "\"");
|
||||||
|
JSONObject json= JSONObject.fromObject(tempparam);
|
||||||
|
params.put(ptp.getParamname().replaceAll(""", "\""), json);
|
||||||
|
}else if(ptp.getParamtype()==2){
|
||||||
|
String tempparam=ptp.getParam().replaceAll(""", "\"");
|
||||||
|
JSONArray jarr=JSONArray.fromObject(tempparam);
|
||||||
|
params.put(ptp.getParamname().replaceAll(""", "\""), jarr);
|
||||||
|
}else{
|
||||||
|
params.put(ptp.getParamname().replaceAll(""", "\""), ptp.getParam().replaceAll(""", "\""));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//处理头域
|
//处理头域
|
||||||
Map<String, String> headmsg = new HashMap<String, String>();
|
Map<String, String> headmsg = new HashMap<String, String>();
|
||||||
if(null!=ppt.getHeadmsg()&&!ppt.getHeadmsg().equals("")&&ppt.getHeadmsg().indexOf("=")>0){
|
if(null!=ppt.getHeadmsg()&&!ppt.getHeadmsg().equals("")&&ppt.getHeadmsg().indexOf("=")>0){
|
||||||
String temp[]=ppt.getHeadmsg().split(";",-1);
|
String[] temp=ppt.getHeadmsg().split(";",-1);
|
||||||
for(int i=0;i<temp.length;i++){
|
for(int i=0;i<temp.length;i++){
|
||||||
if(null!=temp[i]&&!temp[i].equals("")&&temp[i].indexOf("=")>0){
|
if(null!=temp[i]&&!temp[i].equals("")&&temp[i].indexOf("=")>0){
|
||||||
String key=temp[i].substring(0, temp[i].indexOf("="));
|
String key=temp[i].substring(0, temp[i].indexOf("="));
|
||||||
|
@ -249,10 +273,13 @@ public class InvokeMethod {
|
||||||
|
|
||||||
public static Method getMethod(Method[] methods, String methodName, @SuppressWarnings("rawtypes") Class[] parameterTypes) {
|
public static Method getMethod(Method[] methods, String methodName, @SuppressWarnings("rawtypes") Class[] parameterTypes) {
|
||||||
for (int i = 0; i < methods.length; i++) {
|
for (int i = 0; i < methods.length; i++) {
|
||||||
if (!methods[i].getName().equals(methodName))
|
if (!methods[i].getName().equals(methodName)){
|
||||||
continue;
|
continue;
|
||||||
if (compareParameterTypes(parameterTypes, methods[i].getParameterTypes()))
|
}
|
||||||
|
if (compareParameterTypes(parameterTypes, methods[i].getParameterTypes())){
|
||||||
return methods[i];
|
return methods[i];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -260,22 +287,28 @@ public class InvokeMethod {
|
||||||
public static boolean compareParameterTypes(@SuppressWarnings("rawtypes") Class[] parameterTypes, @SuppressWarnings("rawtypes") Class[] orgParameterTypes) {
|
public static boolean compareParameterTypes(@SuppressWarnings("rawtypes") Class[] parameterTypes, @SuppressWarnings("rawtypes") Class[] orgParameterTypes) {
|
||||||
// parameterTypes 里面,int->Integer
|
// parameterTypes 里面,int->Integer
|
||||||
// orgParameterTypes是原始参数类型
|
// orgParameterTypes是原始参数类型
|
||||||
if (parameterTypes == null && orgParameterTypes == null)
|
if (parameterTypes == null && orgParameterTypes == null){
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
if (parameterTypes == null && orgParameterTypes != null) {
|
if (parameterTypes == null && orgParameterTypes != null) {
|
||||||
if (orgParameterTypes.length == 0)
|
if (orgParameterTypes.length == 0){
|
||||||
return true;
|
return true;
|
||||||
else
|
}else{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (parameterTypes != null && orgParameterTypes == null) {
|
if (parameterTypes != null && orgParameterTypes == null) {
|
||||||
if (parameterTypes.length == 0)
|
if (parameterTypes.length == 0){
|
||||||
return true;
|
return true;
|
||||||
else
|
}else{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (parameterTypes.length != orgParameterTypes.length)
|
if (parameterTypes.length != orgParameterTypes.length){
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,20 @@ package luckyclient.publicclass;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class JarClassFind {
|
public class JarClassFind {
|
||||||
|
|
||||||
private static void FindClassInLocalSystem(String path,String classname) {
|
private static void findClassInLocalSystem(String path,String classname) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
//String path = "D:\\web_task\\TestFrame\\lib\\"; //Ö¸¶¨²éÕÒ·¾¶
|
//String path = "D:\\web_task\\TestFrame\\lib\\"; //Ö¸¶¨²éÕÒ·¾¶
|
||||||
classname = classname.replace('.', '/') + ".class";
|
classname = classname.replace('.', '/') + ".class";
|
||||||
|
@ -58,7 +69,7 @@ public class JarClassFind {
|
||||||
static public void main(String[] args) {
|
static public void main(String[] args) {
|
||||||
String path = args[0];
|
String path = args[0];
|
||||||
String classname = args[1];
|
String classname = args[1];
|
||||||
FindClassInLocalSystem(path,classname);
|
findClassInLocalSystem(path,classname);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,13 +43,15 @@ public class LogUtil {
|
||||||
for(Field field:fieldArray){
|
for(Field field:fieldArray){
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
obj = field.get(bean);
|
obj = field.get(bean);
|
||||||
if(!(obj instanceof List) && !field.getName().equals("serialVersionUID")){
|
if(!(obj instanceof List) && !"serialVersionUID".equals(field.getName())){
|
||||||
if(indexId>0)
|
if(indexId>0){
|
||||||
sb.append(",");
|
sb.append(",");
|
||||||
if(obj != null)
|
}
|
||||||
sb.append(field.getName()).append("=").append( obj.toString());
|
if(obj != null){
|
||||||
else
|
sb.append(field.getName()).append("=").append( obj.toString());
|
||||||
|
}else{
|
||||||
sb.append(field.getName()).append("=");
|
sb.append(field.getName()).append("=");
|
||||||
|
}
|
||||||
indexId += 1;
|
indexId += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import java.util.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统配置参数
|
* 系统配置参数
|
||||||
* @author Administrator
|
* @author seagull
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class SysConfig {
|
public class SysConfig {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package luckyclient.publicclass.remoterInterface;
|
package luckyclient.publicclass.remoterinterface;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
@ -12,33 +12,44 @@ import java.util.Map;
|
||||||
import com.caucho.hessian.client.HessianProxyFactory;
|
import com.caucho.hessian.client.HessianProxyFactory;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class HessianTestUtil {
|
public class HessianTestUtil {
|
||||||
private static final ObjectMapper mapper = new ObjectMapper();
|
private static final ObjectMapper MAPPER = new ObjectMapper();
|
||||||
private static final int connect_time_out = 30 * 1000;
|
private static final int CONNECT_TIME_OUT = 30 * 1000;
|
||||||
private static final Map<String, Class<?>> base_type = new HashMap<String, Class<?>>();
|
private static final Map<String, Class<?>> BASE_TYPE = new HashMap<String, Class<?>>();
|
||||||
static {
|
static {
|
||||||
base_type.put("long.class", long.class);
|
BASE_TYPE.put("long.class", long.class);
|
||||||
base_type.put("long.class", long.class);
|
BASE_TYPE.put("long.class", long.class);
|
||||||
base_type.put("float.class", float.class);
|
BASE_TYPE.put("float.class", float.class);
|
||||||
base_type.put("boolean.class", boolean.class);
|
BASE_TYPE.put("boolean.class", boolean.class);
|
||||||
base_type.put("char.class", char.class);
|
BASE_TYPE.put("char.class", char.class);
|
||||||
base_type.put("byte.class", byte.class);
|
BASE_TYPE.put("byte.class", byte.class);
|
||||||
// base_type.put("void.class", void.class);
|
// BASE_TYPE.put("void.class", void.class);
|
||||||
base_type.put("short.class", short.class);
|
BASE_TYPE.put("short.class", short.class);
|
||||||
base_type.put("long", long.class);
|
BASE_TYPE.put("long", long.class);
|
||||||
base_type.put("float", float.class);
|
BASE_TYPE.put("float", float.class);
|
||||||
base_type.put("boolean", boolean.class);
|
BASE_TYPE.put("boolean", boolean.class);
|
||||||
base_type.put("char", char.class);
|
BASE_TYPE.put("char", char.class);
|
||||||
base_type.put("byte", byte.class);
|
BASE_TYPE.put("byte", byte.class);
|
||||||
// base_type.put("void", void.class);
|
// BASE_TYPE.put("void", void.class);
|
||||||
base_type.put("short", short.class);
|
BASE_TYPE.put("short", short.class);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, Object> startInvoke(InterfaceObject object)
|
public static Map<String, Object> startInvoke(InterfaceObject object)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
// 获取带请求参数列表将(参数类型,参数值)数组转成InterfaceParamObject数组
|
// 获取带请求参数列表将(参数类型,参数值)数组转成InterfaceParamObject数组
|
||||||
InterfaceParamObject[] paramContent = mapper
|
InterfaceParamObject[] paramContent = MAPPER
|
||||||
.readValue(object.getParams(), InterfaceParamObject[].class);
|
.readValue(object.getParams(), InterfaceParamObject[].class);
|
||||||
Map<String, Object> resultMap = hessianInvoke(object.getRemoteUrl(),
|
Map<String, Object> resultMap = hessianInvoke(object.getRemoteUrl(),
|
||||||
object.getInterfaceClass(), object.getInterfaceMethod(),
|
object.getInterfaceClass(), object.getInterfaceMethod(),
|
||||||
|
@ -51,15 +62,15 @@ public class HessianTestUtil {
|
||||||
String className, String methodName,
|
String className, String methodName,
|
||||||
InterfaceParamObject[] interfaceParamArray) throws Exception {
|
InterfaceParamObject[] interfaceParamArray) throws Exception {
|
||||||
HessianProxyFactory factory = new HessianProxyFactory();
|
HessianProxyFactory factory = new HessianProxyFactory();
|
||||||
factory.setReadTimeout(connect_time_out);
|
factory.setReadTimeout(CONNECT_TIME_OUT);
|
||||||
// factory.setConnectTimeout(connect_time_out);
|
// factory.setConnectTimeout(connect_time_out);
|
||||||
// factory.setReadTimeout(read_time_out);
|
// factory.setReadTimeout(read_time_out);
|
||||||
Object InterfaceObject = null;
|
Object interfaceObject = null;
|
||||||
Class<?> allRequstParasClass[] = new Class[interfaceParamArray.length];
|
Class<?>[] allRequstParasClass = new Class[interfaceParamArray.length];
|
||||||
Object[] allRequstParas = new Object[interfaceParamArray.length];
|
Object[] allRequstParas = new Object[interfaceParamArray.length];
|
||||||
Map<String, Object> resultMap = new HashMap<String, Object>();
|
Map<String, Object> resultMap = new HashMap<String, Object>();
|
||||||
try {
|
try {
|
||||||
InterfaceObject = factory.create(Class.forName(className),remoteUrl);
|
interfaceObject = factory.create(Class.forName(className),remoteUrl);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
|
@ -71,15 +82,15 @@ public class HessianTestUtil {
|
||||||
.getClassname();
|
.getClassname();
|
||||||
if (isBaseTypeForArray(tempParaClassName)) {
|
if (isBaseTypeForArray(tempParaClassName)) {
|
||||||
// 如果是基础数据类型,那么mapper转换再获取类类型就会有问题,所以值和类分开
|
// 如果是基础数据类型,那么mapper转换再获取类类型就会有问题,所以值和类分开
|
||||||
allRequstParasClass[index] = base_type
|
allRequstParasClass[index] = BASE_TYPE
|
||||||
.get(tempParaClassName);
|
.get(tempParaClassName);
|
||||||
allRequstParas[index] = mapper.readValue(
|
allRequstParas[index] = MAPPER.readValue(
|
||||||
interfaceParamArray[index].getValue(),
|
interfaceParamArray[index].getValue(),
|
||||||
base_type.get(tempParaClassName));
|
BASE_TYPE.get(tempParaClassName));
|
||||||
} else {
|
} else {
|
||||||
allRequstParasClass[index] = Class
|
allRequstParasClass[index] = Class
|
||||||
.forName(tempParaClassName);
|
.forName(tempParaClassName);
|
||||||
allRequstParas[index] = mapper.readValue(
|
allRequstParas[index] = MAPPER.readValue(
|
||||||
interfaceParamArray[index].getValue(),
|
interfaceParamArray[index].getValue(),
|
||||||
allRequstParasClass[index]);
|
allRequstParasClass[index]);
|
||||||
}
|
}
|
||||||
|
@ -90,10 +101,10 @@ public class HessianTestUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Method method = InterfaceObject.getClass().getMethod(methodName,
|
Method method = interfaceObject.getClass().getMethod(methodName,
|
||||||
allRequstParasClass);
|
allRequstParasClass);
|
||||||
Class<?> returnClass = method.getReturnType();
|
Class<?> returnClass = method.getReturnType();
|
||||||
Object result = method.invoke(InterfaceObject, allRequstParas);
|
Object result = method.invoke(interfaceObject, allRequstParas);
|
||||||
|
|
||||||
if (returnClass == void.class) {
|
if (returnClass == void.class) {
|
||||||
resultMap.put("参数返回类型为void", "执行结束,没有返回值");
|
resultMap.put("参数返回类型为void", "执行结束,没有返回值");
|
||||||
|
@ -133,9 +144,9 @@ public class HessianTestUtil {
|
||||||
|
|
||||||
public static Map<String, Object> objectToMap(Object obj) throws Exception {
|
public static Map<String, Object> objectToMap(Object obj) throws Exception {
|
||||||
Map<String, Object> map = new HashMap<String, Object>();
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
String ObjClass = obj.getClass().getName();
|
String objClass = obj.getClass().getName();
|
||||||
if (isBaseTypeForArray(ObjClass)) {
|
if (isBaseTypeForArray(objClass)) {
|
||||||
map.put(ObjClass, obj.toString());
|
map.put(objClass, obj.toString());
|
||||||
} else {
|
} else {
|
||||||
// Field[] allField = obj.getClass().getDeclaredFields();
|
// Field[] allField = obj.getClass().getDeclaredFields();
|
||||||
Field[] allField = getAllFields(obj);
|
Field[] allField = getAllFields(obj);
|
||||||
|
@ -161,11 +172,11 @@ public class HessianTestUtil {
|
||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isBaseTypeForArray(String ObjClassName) {
|
private static boolean isBaseTypeForArray(String objClassName) {
|
||||||
|
|
||||||
boolean isBase = false;
|
boolean isBase = false;
|
||||||
if (ObjClassName != null) {
|
if (objClassName != null) {
|
||||||
isBase = base_type.get(ObjClassName) != null ? true : false;
|
isBase = BASE_TYPE.get(objClassName) != null ? true : false;
|
||||||
}
|
}
|
||||||
return isBase;
|
return isBase;
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package luckyclient.publicclass.remoterInterface;
|
package luckyclient.publicclass.remoterinterface;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
@ -13,18 +13,15 @@ import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.apache.commons.httpclient.methods.EntityEnclosingMethod;
|
import javax.xml.bind.DatatypeConverter;
|
||||||
import org.apache.commons.httpclient.methods.RequestEntity;
|
|
||||||
import org.apache.commons.httpclient.methods.StringRequestEntity;
|
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
import org.apache.http.NameValuePair;
|
import org.apache.http.NameValuePair;
|
||||||
import org.apache.http.client.HttpClient;
|
|
||||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpGet;
|
||||||
|
@ -32,16 +29,21 @@ import org.apache.http.client.methods.HttpPost;
|
||||||
import org.apache.http.client.methods.HttpPut;
|
import org.apache.http.client.methods.HttpPut;
|
||||||
import org.apache.http.entity.StringEntity;
|
import org.apache.http.entity.StringEntity;
|
||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
import org.apache.http.impl.client.DefaultHttpClient;
|
|
||||||
import org.apache.http.impl.client.HttpClients;
|
import org.apache.http.impl.client.HttpClients;
|
||||||
import org.apache.http.message.BasicNameValuePair;
|
import org.apache.http.message.BasicNameValuePair;
|
||||||
|
|
||||||
import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
|
|
||||||
|
|
||||||
import net.sf.json.JSONObject;
|
import net.sf.json.JSONObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description:·¢ËÍhttpÇëÇó°ïÖúÀà
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public class HttpClientHelper {
|
public class HttpClientHelper {
|
||||||
/**
|
/**
|
||||||
|
@ -76,9 +78,10 @@ public class HttpClientHelper {
|
||||||
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
||||||
String key=m.getKey();
|
String key=m.getKey();
|
||||||
String value=m.getValue();
|
String value=m.getValue();
|
||||||
if(null!=value&&value.indexOf("Base64(")>0){
|
if(null!=value&&value.indexOf("Base64(")==0){
|
||||||
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
||||||
value="Basic " + Base64.encode((valuesub).getBytes());
|
//value="Basic " + Base64.encode((valuesub).getBytes());
|
||||||
|
value="Basic " + DatatypeConverter.printBase64Binary((valuesub).getBytes());
|
||||||
con.setRequestProperty(key, value);
|
con.setRequestProperty(key, value);
|
||||||
}else{
|
}else{
|
||||||
con.setRequestProperty(key, value);
|
con.setRequestProperty(key, value);
|
||||||
|
@ -164,9 +167,9 @@ public class HttpClientHelper {
|
||||||
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
||||||
String key=m.getKey();
|
String key=m.getKey();
|
||||||
String value=m.getValue();
|
String value=m.getValue();
|
||||||
if(null!=value&&value.indexOf("Base64(")>0){
|
if(null!=value&&value.indexOf("Base64(")==0){
|
||||||
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
||||||
value="Basic " + Base64.encode((valuesub).getBytes());
|
value="Basic " + DatatypeConverter.printBase64Binary((valuesub).getBytes());
|
||||||
con.setRequestProperty(key, value);
|
con.setRequestProperty(key, value);
|
||||||
}else{
|
}else{
|
||||||
con.setRequestProperty(key, value);
|
con.setRequestProperty(key, value);
|
||||||
|
@ -248,9 +251,9 @@ public class HttpClientHelper {
|
||||||
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
||||||
String key=m.getKey();
|
String key=m.getKey();
|
||||||
String value=m.getValue();
|
String value=m.getValue();
|
||||||
if(null!=value&&value.indexOf("Base64(")>0){
|
if(null!=value&&value.indexOf("Base64(")==0){
|
||||||
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
||||||
value="Basic " + Base64.encode((valuesub).getBytes());
|
value="Basic " + DatatypeConverter.printBase64Binary((valuesub).getBytes());
|
||||||
con.setRequestProperty(key, value);
|
con.setRequestProperty(key, value);
|
||||||
}else{
|
}else{
|
||||||
con.setRequestProperty(key, value);
|
con.setRequestProperty(key, value);
|
||||||
|
@ -328,9 +331,9 @@ public class HttpClientHelper {
|
||||||
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
||||||
String key=m.getKey();
|
String key=m.getKey();
|
||||||
String value=m.getValue();
|
String value=m.getValue();
|
||||||
if(null!=value&&value.indexOf("Base64(")>0){
|
if(null!=value&&value.indexOf("Base64(")==0){
|
||||||
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
||||||
value="Basic " + Base64.encode((valuesub).getBytes());
|
value="Basic " + DatatypeConverter.printBase64Binary((valuesub).getBytes());
|
||||||
con.setRequestProperty(key, value);
|
con.setRequestProperty(key, value);
|
||||||
}else{
|
}else{
|
||||||
con.setRequestProperty(key, value);
|
con.setRequestProperty(key, value);
|
||||||
|
@ -397,9 +400,9 @@ public class HttpClientHelper {
|
||||||
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
||||||
String key=m.getKey();
|
String key=m.getKey();
|
||||||
String value=m.getValue();
|
String value=m.getValue();
|
||||||
if(null!=value&&value.indexOf("Base64(")>0){
|
if(null!=value&&value.indexOf("Base64(")==0){
|
||||||
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
||||||
value="Basic " + Base64.encode((valuesub).getBytes());
|
value="Basic " + DatatypeConverter.printBase64Binary((valuesub).getBytes());
|
||||||
con.setRequestProperty(key, value);
|
con.setRequestProperty(key, value);
|
||||||
}else{
|
}else{
|
||||||
con.setRequestProperty(key, value);
|
con.setRequestProperty(key, value);
|
||||||
|
@ -442,9 +445,9 @@ public class HttpClientHelper {
|
||||||
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
||||||
String key=m.getKey();
|
String key=m.getKey();
|
||||||
String value=m.getValue();
|
String value=m.getValue();
|
||||||
if(null!=value&&value.indexOf("Base64(")>0){
|
if(null!=value&&value.indexOf("Base64(")==0){
|
||||||
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
||||||
value="Basic " + Base64.encode((valuesub).getBytes());
|
value="Basic " + DatatypeConverter.printBase64Binary((valuesub).getBytes());
|
||||||
httpPost.setHeader(key, value);
|
httpPost.setHeader(key, value);
|
||||||
}else{
|
}else{
|
||||||
httpPost.setHeader(key, value);
|
httpPost.setHeader(key, value);
|
||||||
|
@ -494,9 +497,9 @@ public class HttpClientHelper {
|
||||||
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
||||||
String key=m.getKey();
|
String key=m.getKey();
|
||||||
String value=m.getValue();
|
String value=m.getValue();
|
||||||
if(null!=value&&value.indexOf("Base64(")>0){
|
if(null!=value&&value.indexOf("Base64(")==0){
|
||||||
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
||||||
value="Basic " + Base64.encode((valuesub).getBytes());
|
value="Basic " + DatatypeConverter.printBase64Binary((valuesub).getBytes());
|
||||||
httpPost.setHeader(key, value);
|
httpPost.setHeader(key, value);
|
||||||
}else{
|
}else{
|
||||||
httpPost.setHeader(key, value);
|
httpPost.setHeader(key, value);
|
||||||
|
@ -578,9 +581,9 @@ public class HttpClientHelper {
|
||||||
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
||||||
String key=m.getKey();
|
String key=m.getKey();
|
||||||
String value=m.getValue();
|
String value=m.getValue();
|
||||||
if(null!=value&&value.indexOf("Base64(")>0){
|
if(null!=value&&value.indexOf("Base64(")==0){
|
||||||
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
||||||
value="Basic " + Base64.encode((valuesub).getBytes());
|
value="Basic " + DatatypeConverter.printBase64Binary((valuesub).getBytes());
|
||||||
httpGet.setHeader(key, value);
|
httpGet.setHeader(key, value);
|
||||||
}else{
|
}else{
|
||||||
httpGet.setHeader(key, value);
|
httpGet.setHeader(key, value);
|
||||||
|
@ -644,9 +647,9 @@ public class HttpClientHelper {
|
||||||
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
||||||
String key=m.getKey();
|
String key=m.getKey();
|
||||||
String value=m.getValue();
|
String value=m.getValue();
|
||||||
if(null!=value&&value.indexOf("Base64(")>0){
|
if(null!=value&&value.indexOf("Base64(")==0){
|
||||||
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
||||||
value="Basic " + Base64.encode((valuesub).getBytes());
|
value="Basic " + DatatypeConverter.printBase64Binary((valuesub).getBytes());
|
||||||
sb.append(key+": "+value+" \r\n");
|
sb.append(key+": "+value+" \r\n");
|
||||||
}else{
|
}else{
|
||||||
sb.append(key+": "+value+" \r\n");
|
sb.append(key+": "+value+" \r\n");
|
||||||
|
@ -675,7 +678,7 @@ public class HttpClientHelper {
|
||||||
contentLength = Integer.parseInt(line.split(":")[1].trim());
|
contentLength = Integer.parseInt(line.split(":")[1].trim());
|
||||||
}
|
}
|
||||||
// 如果遇到了一个单独的回车换行,则表示请求头结束
|
// 如果遇到了一个单独的回车换行,则表示请求头结束
|
||||||
} while (!line.equals("\r\n"));
|
} while (!"\r\n".equals(line));
|
||||||
// 读取出响应体数据(就是你要的数据)
|
// 读取出响应体数据(就是你要的数据)
|
||||||
result = readLine(is, contentLength, charset);
|
result = readLine(is, contentLength, charset);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -753,9 +756,9 @@ public class HttpClientHelper {
|
||||||
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
||||||
String key=m.getKey();
|
String key=m.getKey();
|
||||||
String value=m.getValue();
|
String value=m.getValue();
|
||||||
if(null!=value&&value.indexOf("Base64(")>0){
|
if(null!=value&&value.indexOf("Base64(")==0){
|
||||||
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
||||||
value="Basic " + Base64.encode((valuesub).getBytes());
|
value="Basic " + DatatypeConverter.printBase64Binary((valuesub).getBytes());
|
||||||
sb.append(key+": "+value+" \r\n");
|
sb.append(key+": "+value+" \r\n");
|
||||||
}else{
|
}else{
|
||||||
sb.append(key+": "+value+" \r\n");
|
sb.append(key+": "+value+" \r\n");
|
||||||
|
@ -784,7 +787,7 @@ public class HttpClientHelper {
|
||||||
contentLength = Integer.parseInt(line.split(":")[1].trim());
|
contentLength = Integer.parseInt(line.split(":")[1].trim());
|
||||||
}
|
}
|
||||||
// 如果遇到了一个单独的回车换行,则表示请求头结束
|
// 如果遇到了一个单独的回车换行,则表示请求头结束
|
||||||
} while (!line.equals("\r\n"));
|
} while (!"\r\n".equals(line));
|
||||||
// 读取出响应体数据(就是你要的数据)
|
// 读取出响应体数据(就是你要的数据)
|
||||||
result = readLine(is, contentLength, charset);
|
result = readLine(is, contentLength, charset);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -887,9 +890,9 @@ public class HttpClientHelper {
|
||||||
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
||||||
String key=m.getKey();
|
String key=m.getKey();
|
||||||
String value=m.getValue();
|
String value=m.getValue();
|
||||||
if(null!=value&&value.indexOf("Base64(")>0){
|
if(null!=value&&value.indexOf("Base64(")==0){
|
||||||
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
||||||
value="Basic " + Base64.encode((valuesub).getBytes());
|
value="Basic " + DatatypeConverter.printBase64Binary((valuesub).getBytes());
|
||||||
con.setRequestProperty(key,value);
|
con.setRequestProperty(key,value);
|
||||||
}else{
|
}else{
|
||||||
con.setRequestProperty(key,value);
|
con.setRequestProperty(key,value);
|
||||||
|
@ -960,9 +963,9 @@ public class HttpClientHelper {
|
||||||
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
for (Map.Entry<String, String> m :headmsg.entrySet()) {
|
||||||
String key=m.getKey();
|
String key=m.getKey();
|
||||||
String value=m.getValue();
|
String value=m.getValue();
|
||||||
if(null!=value&&value.indexOf("Base64(")>0){
|
if(null!=value&&value.indexOf("Base64(")==0){
|
||||||
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
String valuesub=value.substring(value.indexOf("Base64(")+7,value.lastIndexOf(")"));
|
||||||
value="Basic " + Base64.encode((valuesub).getBytes());
|
value="Basic " + DatatypeConverter.printBase64Binary((valuesub).getBytes());
|
||||||
httpput.setHeader(key,value);
|
httpput.setHeader(key,value);
|
||||||
}else{
|
}else{
|
||||||
httpput.setHeader(key,value);
|
httpput.setHeader(key,value);
|
|
@ -1,4 +1,4 @@
|
||||||
package luckyclient.publicclass.remoterInterface;
|
package luckyclient.publicclass.remoterinterface;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -12,10 +12,21 @@ import java.util.Properties;
|
||||||
import luckyclient.publicclass.LogUtil;
|
import luckyclient.publicclass.LogUtil;
|
||||||
import luckyclient.publicclass.SysConfig;
|
import luckyclient.publicclass.SysConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class HttpRequest {
|
public class HttpRequest {
|
||||||
final static Properties properties = luckyclient.publicclass.SysConfig.getConfiguration();
|
final static Properties PROPERTIES = luckyclient.publicclass.SysConfig.getConfiguration();
|
||||||
private final static String Web_URL = "http://" + properties.getProperty("server.web.ip") + ":"
|
private final static String WEB_URL = "http://" + PROPERTIES.getProperty("server.web.ip") + ":"
|
||||||
+ properties.getProperty("server.web.port");
|
+ PROPERTIES.getProperty("server.web.port");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字符串参数
|
* 字符串参数
|
||||||
|
@ -27,7 +38,7 @@ public class HttpRequest {
|
||||||
StringBuilder json = new StringBuilder();
|
StringBuilder json = new StringBuilder();
|
||||||
URL url=null;
|
URL url=null;
|
||||||
try {
|
try {
|
||||||
url = new URL(Web_URL+repath);
|
url = new URL(WEB_URL+repath);
|
||||||
URLConnection yc = url.openConnection();
|
URLConnection yc = url.openConnection();
|
||||||
BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
|
BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
|
||||||
String inputLine = null;
|
String inputLine = null;
|
||||||
|
@ -58,7 +69,7 @@ public class HttpRequest {
|
||||||
BufferedReader in = null;
|
BufferedReader in = null;
|
||||||
String result = "";
|
String result = "";
|
||||||
try {
|
try {
|
||||||
URL realUrl = new URL(Web_URL+repath);
|
URL realUrl = new URL(WEB_URL+repath);
|
||||||
// 打开和URL之间的连接
|
// 打开和URL之间的连接
|
||||||
URLConnection conn = realUrl.openConnection();
|
URLConnection conn = realUrl.openConnection();
|
||||||
// 设置通用的请求属性
|
// 设置通用的请求属性
|
|
@ -1,5 +1,16 @@
|
||||||
package luckyclient.publicclass.remoterInterface;
|
package luckyclient.publicclass.remoterinterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class InterfaceObject {
|
public class InterfaceObject {
|
||||||
/**
|
/**
|
||||||
* ½Ó¿ÚÀà
|
* ½Ó¿ÚÀà
|
|
@ -1,5 +1,16 @@
|
||||||
package luckyclient.publicclass.remoterInterface;
|
package luckyclient.publicclass.remoterinterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class InterfaceParamObject {
|
public class InterfaceParamObject {
|
||||||
/**
|
/**
|
||||||
* 参数类
|
* 参数类
|
|
@ -1,4 +1,4 @@
|
||||||
package luckyclient.publicclass.remoterInterface;
|
package luckyclient.publicclass.remoterinterface;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
@ -16,27 +16,38 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class InterfaceTestUtil {
|
public class InterfaceTestUtil {
|
||||||
private static Logger log = LoggerFactory
|
private static Logger log = LoggerFactory
|
||||||
.getLogger(InterfaceTestUtil.class);
|
.getLogger(InterfaceTestUtil.class);
|
||||||
private static final ObjectMapper map = new ObjectMapper();
|
private static final ObjectMapper MAP = new ObjectMapper();
|
||||||
private static final int read_time_out = 30 * 1000;
|
private static final int READ_TIME_OUT = 30 * 1000;
|
||||||
private static final Map<String, Class<?>> base_type = new HashMap<String, Class<?>>();
|
private static final Map<String, Class<?>> BASE_TYPE = new HashMap<String, Class<?>>();
|
||||||
static {
|
static {
|
||||||
base_type.put("long", long.class);
|
BASE_TYPE.put("long", long.class);
|
||||||
base_type.put("double", double.class);
|
BASE_TYPE.put("double", double.class);
|
||||||
base_type.put("float", float.class);
|
BASE_TYPE.put("float", float.class);
|
||||||
base_type.put("bool", boolean.class);
|
BASE_TYPE.put("bool", boolean.class);
|
||||||
base_type.put("char", char.class);
|
BASE_TYPE.put("char", char.class);
|
||||||
base_type.put("byte", byte.class);
|
BASE_TYPE.put("byte", byte.class);
|
||||||
base_type.put("void", void.class);
|
BASE_TYPE.put("void", void.class);
|
||||||
base_type.put("short", short.class);
|
BASE_TYPE.put("short", short.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, Object> doTest(InterfaceObject object)
|
public static Map<String, Object> doTest(InterfaceObject object)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
// 获取带请求参数列表将(参数类型,参数值)数组转成InterfaceParamObject数组
|
// 获取带请求参数列表将(参数类型,参数值)数组转成InterfaceParamObject数组
|
||||||
InterfaceParamObject[] paramContent = map.readValue(object.getParams(),
|
InterfaceParamObject[] paramContent = MAP.readValue(object.getParams(),
|
||||||
InterfaceParamObject[].class);
|
InterfaceParamObject[].class);
|
||||||
Object result = hessian(object.getRemoteUrl(),
|
Object result = hessian(object.getRemoteUrl(),
|
||||||
object.getInterfaceClass(), object.getInterfaceMethod(),
|
object.getInterfaceClass(), object.getInterfaceMethod(),
|
||||||
|
@ -54,9 +65,9 @@ public class InterfaceTestUtil {
|
||||||
|
|
||||||
public static Map<String, Object> objectToMap(Object obj) throws Exception {
|
public static Map<String, Object> objectToMap(Object obj) throws Exception {
|
||||||
Map<String, Object> map = new HashMap<String, Object>();
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
String ObjClass = obj.getClass().getName();
|
String objClass = obj.getClass().getName();
|
||||||
if (isBaseTypeForArray(ObjClass)) {
|
if (isBaseTypeForArray(objClass)) {
|
||||||
map.put(ObjClass, obj.toString());
|
map.put(objClass, obj.toString());
|
||||||
} else {
|
} else {
|
||||||
// Field[] allField = obj.getClass().getDeclaredFields();
|
// Field[] allField = obj.getClass().getDeclaredFields();
|
||||||
Field[] allField = getAllFields(obj);
|
Field[] allField = getAllFields(obj);
|
||||||
|
@ -85,25 +96,25 @@ public class InterfaceTestUtil {
|
||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isBaseTypeForArray(String ObjClassName) {
|
private static boolean isBaseTypeForArray(String objClassName) {
|
||||||
|
|
||||||
boolean isBase = false;
|
boolean isBase = false;
|
||||||
if (ObjClassName != null) {
|
if (objClassName != null) {
|
||||||
isBase = base_type.get(ObjClassName) != null ? true : false;
|
isBase = BASE_TYPE.get(objClassName) != null ? true : false;
|
||||||
}
|
}
|
||||||
return isBase;
|
return isBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String genJsonStr(Object object)
|
public static String genJsonStr(Object object)
|
||||||
throws JsonProcessingException {
|
throws JsonProcessingException {
|
||||||
return map.writeValueAsString(object);
|
return MAP.writeValueAsString(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Object hessian(String remoteUrl, String className,
|
private static Object hessian(String remoteUrl, String className,
|
||||||
String methodName, InterfaceParamObject[] paramContent)
|
String methodName, InterfaceParamObject[] paramContent)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
HessianProxyFactory factory = new HessianProxyFactory();
|
HessianProxyFactory factory = new HessianProxyFactory();
|
||||||
factory.setReadTimeout(read_time_out);
|
factory.setReadTimeout(READ_TIME_OUT);
|
||||||
Object interfaceObj = null;
|
Object interfaceObj = null;
|
||||||
Class<?> interfaceClassName = null;
|
Class<?> interfaceClassName = null;
|
||||||
|
|
||||||
|
@ -162,7 +173,7 @@ public class InterfaceTestUtil {
|
||||||
Object[] allRequstParas) {
|
Object[] allRequstParas) {
|
||||||
int totalRequestParam = allRequstParas.length;
|
int totalRequestParam = allRequstParas.length;
|
||||||
|
|
||||||
Class<?> allRequstParasClass[] = null;
|
Class<?>[] allRequstParasClass = null;
|
||||||
if (allRequstParas != null) {// 存在
|
if (allRequstParas != null) {// 存在
|
||||||
int len = allRequstParas.length;
|
int len = allRequstParas.length;
|
||||||
allRequstParasClass = new Class[len];
|
allRequstParasClass = new Class[len];
|
||||||
|
@ -201,12 +212,12 @@ public class InterfaceTestUtil {
|
||||||
* @see
|
* @see
|
||||||
*/
|
*/
|
||||||
private static Class<?> getBaseTypeClassByName(String className) {
|
private static Class<?> getBaseTypeClassByName(String className) {
|
||||||
return base_type.get(className);
|
return BASE_TYPE.get(className);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Boolean isBaseType(String className) {
|
private static Boolean isBaseType(String className) {
|
||||||
Boolean istrue = false;
|
Boolean istrue = false;
|
||||||
for (String key : base_type.keySet()) {
|
for (String key : BASE_TYPE.keySet()) {
|
||||||
istrue = className.equals(key) ? true : false;
|
istrue = className.equals(key) ? true : false;
|
||||||
}
|
}
|
||||||
return istrue;
|
return istrue;
|
|
@ -12,8 +12,8 @@ import luckyclient.dblog.LogOperation;
|
||||||
/**
|
/**
|
||||||
* =================================================================
|
* =================================================================
|
||||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
* 此测试框架主要采用testlink做分层框架,负责数据驱动以及用例管理部分,有任何疑问欢迎联系作者讨论。
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
* QQ:24163551 seagull1985
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
* =================================================================
|
* =================================================================
|
||||||
* @ClassName: AnalyticCase
|
* @ClassName: AnalyticCase
|
||||||
* @Description: 解析单个用例中描述部分的脚本
|
* @Description: 解析单个用例中描述部分的脚本
|
||||||
|
@ -28,7 +28,7 @@ public class InterfaceAnalyticTestLinkCase{
|
||||||
* @param args
|
* @param args
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("finally")
|
@SuppressWarnings("finally")
|
||||||
public static Map<String,String> AnalyticCaseStep(TestCase testcase,Integer ordersteps,String tastid,LogOperation caselog){
|
public static Map<String,String> analyticCaseStep(TestCase testcase,Integer ordersteps,String tastid,LogOperation caselog){
|
||||||
String time = "0";
|
String time = "0";
|
||||||
Map<String,String> params = new HashMap<String,String>();
|
Map<String,String> params = new HashMap<String,String>();
|
||||||
|
|
||||||
|
@ -36,13 +36,13 @@ public class InterfaceAnalyticTestLinkCase{
|
||||||
try {
|
try {
|
||||||
List<TestCaseStep> testcasesteps = (List<TestCaseStep>) testcase.getSteps();
|
List<TestCaseStep> testcasesteps = (List<TestCaseStep>) testcase.getSteps();
|
||||||
String stepsstr = testcasesteps.get(ordersteps-1).getActions(); //获取actions字符串
|
String stepsstr = testcasesteps.get(ordersteps-1).getActions(); //获取actions字符串
|
||||||
String scriptstr = SubComment(stepsstr);
|
String scriptstr = subComment(stepsstr);
|
||||||
if(scriptstr.substring(scriptstr.length()-6, scriptstr.length()).indexOf("*Wait;")>-1){ //添加步骤之间等待时间
|
if(scriptstr.substring(scriptstr.length()-6, scriptstr.length()).indexOf("*Wait;")>-1){ //添加步骤之间等待时间
|
||||||
time = scriptstr.substring(scriptstr.lastIndexOf("|")+1,scriptstr.lastIndexOf("*Wait;"));
|
time = scriptstr.substring(scriptstr.lastIndexOf("|")+1,scriptstr.lastIndexOf("*Wait;"));
|
||||||
scriptstr = scriptstr.substring(0, scriptstr.lastIndexOf("|")+1);
|
scriptstr = scriptstr.substring(0, scriptstr.lastIndexOf("|")+1);
|
||||||
}
|
}
|
||||||
resultstr = testcasesteps.get(ordersteps-1).getExpectedResults(); //获取预期结果字符串
|
resultstr = testcasesteps.get(ordersteps-1).getExpectedResults(); //获取预期结果字符串
|
||||||
String temp[]=scriptstr.split(splitFlag,-1);
|
String[] temp=scriptstr.split(splitFlag,-1);
|
||||||
for(int i=0;i<temp.length;i++){
|
for(int i=0;i<temp.length;i++){
|
||||||
if(i==0){
|
if(i==0){
|
||||||
String packagenage = temp[i].substring(0, temp[i].indexOf("#"));
|
String packagenage = temp[i].substring(0, temp[i].indexOf("#"));
|
||||||
|
@ -50,58 +50,58 @@ public class InterfaceAnalyticTestLinkCase{
|
||||||
// String functionname = temp[i].substring(0, temp[i].indexOf(";"));
|
// String functionname = temp[i].substring(0, temp[i].indexOf(";"));
|
||||||
params.put("PackageName", packagenage.trim()); //set包名
|
params.put("PackageName", packagenage.trim()); //set包名
|
||||||
params.put("FunctionName", functionname.trim()); //set方法名称
|
params.put("FunctionName", functionname.trim()); //set方法名称
|
||||||
}else if(temp[i].equals("")){
|
}else if("".equals(temp[i])){
|
||||||
continue;
|
continue;
|
||||||
}else{
|
}else{
|
||||||
params.put("FunctionParams"+i, temp[i]); //set第N个传入参数
|
params.put("FunctionParams"+i, temp[i]); //set第N个传入参数
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//set预期结果
|
//set预期结果
|
||||||
if(resultstr.equals("")){
|
if("".equals(resultstr)){
|
||||||
params.put("ExpectedResults", "");
|
params.put("ExpectedResults", "");
|
||||||
}else{
|
}else{
|
||||||
params.put("ExpectedResults", SubComment(resultstr));
|
params.put("ExpectedResults", subComment(resultstr));
|
||||||
}
|
}
|
||||||
params.put("StepWait", time);
|
params.put("StepWait", time);
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例编号:"+testcase.getFullExternalId()+" 步骤编号:"+ordersteps+" 解析自动化用例步骤脚本完成!");
|
luckyclient.publicclass.LogUtil.APP.info("用例编号:"+testcase.getFullExternalId()+" 步骤编号:"+ordersteps+" 解析自动化用例步骤脚本完成!");
|
||||||
if(null!=caselog){
|
if(null!=caselog){
|
||||||
caselog.CaseLogDetail(tastid, testcase.getFullExternalId(),"步骤编号:"+ordersteps+" 解析自动化用例步骤脚本完成!","info",String.valueOf(ordersteps),"");
|
caselog.caseLogDetail(tastid, testcase.getFullExternalId(),"步骤编号:"+ordersteps+" 解析自动化用例步骤脚本完成!","info",String.valueOf(ordersteps),"");
|
||||||
}
|
}
|
||||||
}catch(Exception e) {
|
}catch(Exception e) {
|
||||||
luckyclient.publicclass.LogUtil.ERROR.error("用例编号:"+testcase.getFullExternalId()+" 步骤编号:"+ordersteps+" 解析自动化用例步骤脚本出错!");
|
luckyclient.publicclass.LogUtil.ERROR.error("用例编号:"+testcase.getFullExternalId()+" 步骤编号:"+ordersteps+" 解析自动化用例步骤脚本出错!");
|
||||||
if(null!=caselog){
|
if(null!=caselog){
|
||||||
caselog.CaseLogDetail(tastid, testcase.getFullExternalId(),"步骤编号:"+ordersteps+" 解析自动化用例步骤脚本出错!","error",String.valueOf(ordersteps),"");
|
caselog.caseLogDetail(tastid, testcase.getFullExternalId(),"步骤编号:"+ordersteps+" 解析自动化用例步骤脚本出错!","error",String.valueOf(ordersteps),"");
|
||||||
}
|
}
|
||||||
luckyclient.publicclass.LogUtil.ERROR.error(e,e);
|
luckyclient.publicclass.LogUtil.ERROR.error(e,e);
|
||||||
params.put("FunctionName","用例编号:"+testcase.getFullExternalId()+"|解析异常,用例步骤为空或是用例脚本错误!");
|
params.put("FunctionName","用例编号:"+testcase.getFullExternalId()+"|解析异常,用例步骤为空或是用例脚本错误!");
|
||||||
}finally{
|
return params;
|
||||||
return params;
|
|
||||||
}
|
}
|
||||||
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String SubComment(String htmlStr) throws InterruptedException{
|
public static String subComment(String htmlStr) throws InterruptedException{
|
||||||
String regEx_script = "<script[^>]*?>[\\s\\S]*?<\\/script>"; // 定义script的正则表达式
|
String regExScript = "<script[^>]*?>[\\s\\S]*?<\\/script>"; // 定义script的正则表达式
|
||||||
String regEx_style = "<style[^>]*?>[\\s\\S]*?<\\/style>"; // 定义style的正则表达式
|
String regExStyle = "<style[^>]*?>[\\s\\S]*?<\\/style>"; // 定义style的正则表达式
|
||||||
String regEx_html = "<[^>]+>"; // 定义HTML标签的正则表达式
|
String regExHtml = "<[^>]+>"; // 定义HTML标签的正则表达式
|
||||||
String regEx_space = "\t|\r|\n";//定义空格回车换行符
|
String regExSpace = "\t|\r|\n";//定义空格回车换行符
|
||||||
|
|
||||||
String scriptstr = null;
|
String scriptstr = null;
|
||||||
if (htmlStr!=null) {
|
if (htmlStr!=null) {
|
||||||
Pattern p_script = Pattern.compile(regEx_script, Pattern.CASE_INSENSITIVE);
|
Pattern pScript = Pattern.compile(regExScript, Pattern.CASE_INSENSITIVE);
|
||||||
Matcher m_script = p_script.matcher(htmlStr);
|
Matcher mScript = pScript.matcher(htmlStr);
|
||||||
htmlStr = m_script.replaceAll(""); // 过滤script标签
|
htmlStr = mScript.replaceAll(""); // 过滤script标签
|
||||||
|
|
||||||
Pattern p_style = Pattern.compile(regEx_style, Pattern.CASE_INSENSITIVE);
|
Pattern pStyle = Pattern.compile(regExStyle, Pattern.CASE_INSENSITIVE);
|
||||||
Matcher m_style = p_style.matcher(htmlStr);
|
Matcher mStyle = pStyle.matcher(htmlStr);
|
||||||
htmlStr = m_style.replaceAll(""); // 过滤style标签
|
htmlStr = mStyle.replaceAll(""); // 过滤style标签
|
||||||
|
|
||||||
Pattern p_html = Pattern.compile(regEx_html, Pattern.CASE_INSENSITIVE);
|
Pattern pHtml = Pattern.compile(regExHtml, Pattern.CASE_INSENSITIVE);
|
||||||
Matcher m_html = p_html.matcher(htmlStr);
|
Matcher mHtml = pHtml.matcher(htmlStr);
|
||||||
htmlStr = m_html.replaceAll(""); // 过滤html标签
|
htmlStr = mHtml.replaceAll(""); // 过滤html标签
|
||||||
|
|
||||||
Pattern p_space = Pattern.compile(regEx_space, Pattern.CASE_INSENSITIVE);
|
Pattern pSpace = Pattern.compile(regExSpace, Pattern.CASE_INSENSITIVE);
|
||||||
Matcher m_space = p_space.matcher(htmlStr);
|
Matcher mSpace = pSpace.matcher(htmlStr);
|
||||||
htmlStr = m_space.replaceAll(""); // 过滤空格回车标签
|
htmlStr = mSpace.replaceAll(""); // 过滤空格回车标签
|
||||||
|
|
||||||
}
|
}
|
||||||
if(htmlStr.indexOf("/*")>-1&&htmlStr.indexOf("*/")>-1){
|
if(htmlStr.indexOf("/*")>-1&&htmlStr.indexOf("*/")>-1){
|
||||||
|
|
|
@ -11,8 +11,8 @@ import luckyclient.dblog.LogOperation;
|
||||||
/**
|
/**
|
||||||
* =================================================================
|
* =================================================================
|
||||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
* 此测试框架主要采用testlink做分层框架,负责数据驱动以及用例管理部分,有任何疑问欢迎联系作者讨论。
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
* QQ:24163551 seagull1985
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
* =================================================================
|
* =================================================================
|
||||||
* @ClassName: TestBuildApi
|
* @ClassName: TestBuildApi
|
||||||
* @Description: 二次封装关于测试版本部分的API
|
* @Description: 二次封装关于测试版本部分的API
|
||||||
|
@ -34,10 +34,10 @@ public class TestBuildApi extends TestLinkBaseApi {
|
||||||
//能过项目名称以及计划名称获取计划ID
|
//能过项目名称以及计划名称获取计划ID
|
||||||
TestPlan testplanob = new TestPlan();
|
TestPlan testplanob = new TestPlan();
|
||||||
// testplanob = api.getTestPlanByName(TestPlanName(projectname), projectname);
|
// testplanob = api.getTestPlanByName(TestPlanName(projectname), projectname);
|
||||||
if(TestControl.TASKID.indexOf("NULL")>-1||LogOperation.GetTestPlanName(TestControl.TASKID).indexOf("NULL")>-1){
|
if(TestControl.TASKID.indexOf("NULL")>-1||LogOperation.getTestPlanName(TestControl.TASKID).indexOf("NULL")>-1){
|
||||||
testplanob = api.getTestPlanByName(TestPlanName(projectname), projectname);
|
testplanob = api.getTestPlanByName(testPlanName(projectname), projectname);
|
||||||
}else{
|
}else{
|
||||||
testplanob = api.getTestPlanByName(LogOperation.GetTestPlanName(TestControl.TASKID), projectname);
|
testplanob = api.getTestPlanByName(LogOperation.getTestPlanName(TestControl.TASKID), projectname);
|
||||||
}
|
}
|
||||||
Integer planid = testplanob.getId();
|
Integer planid = testplanob.getId();
|
||||||
|
|
||||||
|
@ -57,14 +57,14 @@ public class TestBuildApi extends TestLinkBaseApi {
|
||||||
/**
|
/**
|
||||||
* 当没在测试计划中找到版本后,自动创建一个版本
|
* 当没在测试计划中找到版本后,自动创建一个版本
|
||||||
*/
|
*/
|
||||||
public static void GetBuild(String projectname){
|
public static void getBuild(String projectname){
|
||||||
//能过项目名称以及计划名称获取计划ID
|
//能过项目名称以及计划名称获取计划ID
|
||||||
TestPlan testplanob = new TestPlan();
|
TestPlan testplanob = new TestPlan();
|
||||||
// testplanob = api.getTestPlanByName(TestPlanName(projectname), projectname);
|
// testplanob = api.getTestPlanByName(TestPlanName(projectname), projectname);
|
||||||
if(TestControl.TASKID.indexOf("NULL")>-1||LogOperation.GetTestPlanName(TestControl.TASKID).indexOf("NULL")>-1){
|
if(TestControl.TASKID.indexOf("NULL")>-1||LogOperation.getTestPlanName(TestControl.TASKID).indexOf("NULL")>-1){
|
||||||
testplanob = api.getTestPlanByName(TestPlanName(projectname), projectname);
|
testplanob = api.getTestPlanByName(testPlanName(projectname), projectname);
|
||||||
}else{
|
}else{
|
||||||
testplanob = api.getTestPlanByName(LogOperation.GetTestPlanName(TestControl.TASKID), projectname);
|
testplanob = api.getTestPlanByName(LogOperation.getTestPlanName(TestControl.TASKID), projectname);
|
||||||
}
|
}
|
||||||
Integer planid = testplanob.getId();
|
Integer planid = testplanob.getId();
|
||||||
try{
|
try{
|
||||||
|
|
|
@ -17,13 +17,13 @@ import br.eti.kinoshita.testlinkjavaapi.model.TestSuite;
|
||||||
import br.eti.kinoshita.testlinkjavaapi.util.TestLinkAPIException;
|
import br.eti.kinoshita.testlinkjavaapi.util.TestLinkAPIException;
|
||||||
import luckyclient.caserun.exinterface.TestControl;
|
import luckyclient.caserun.exinterface.TestControl;
|
||||||
import luckyclient.dblog.LogOperation;
|
import luckyclient.dblog.LogOperation;
|
||||||
import luckyclient.publicclass.remoterInterface.HttpRequest;
|
import luckyclient.publicclass.remoterinterface.HttpRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* =================================================================
|
* =================================================================
|
||||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
* 此测试框架主要采用testlink做分层框架,负责数据驱动以及用例管理部分,有任何疑问欢迎联系作者讨论。
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
* QQ:24163551 seagull1985
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
* =================================================================
|
* =================================================================
|
||||||
* @ClassName: TestCaseApi
|
* @ClassName: TestCaseApi
|
||||||
* @Description: 二次封装关于测试用例部分的API
|
* @Description: 二次封装关于测试用例部分的API
|
||||||
|
@ -111,12 +111,12 @@ public class TestCaseApi extends TestLinkBaseApi {
|
||||||
//能过项目名称以及计划名称获取计划ID
|
//能过项目名称以及计划名称获取计划ID
|
||||||
TestPlan testplanob = new TestPlan();
|
TestPlan testplanob = new TestPlan();
|
||||||
//testplanob = api.getTestPlanByName(TestPlanName(projectname), projectname);
|
//testplanob = api.getTestPlanByName(TestPlanName(projectname), projectname);
|
||||||
testplanob = api.getTestPlanByName(LogOperation.GetTestPlanName(TestControl.TASKID), projectname);
|
testplanob = api.getTestPlanByName(LogOperation.getTestPlanName(TestControl.TASKID), projectname);
|
||||||
Integer planid = testplanob.getId();
|
Integer planid = testplanob.getId();
|
||||||
|
|
||||||
Map<String, Object> params = new HashMap<String, Object>();
|
Map<String, Object> params = new HashMap<String, Object>();
|
||||||
params.put("devKey", TESTLINK_DEVKEY);
|
params.put("devKey", TESTLINK_DEVKEY);
|
||||||
params.put("testprojectid", ProjectID(projectname));
|
params.put("testprojectid", projectID(projectname));
|
||||||
params.put("testplanid", planid);
|
params.put("testplanid", planid);
|
||||||
params.put("testcaseexternalid", testCaseExternalID);
|
params.put("testcaseexternalid", testCaseExternalID);
|
||||||
params.put("version", version);
|
params.put("version", version);
|
||||||
|
@ -161,10 +161,10 @@ public class TestCaseApi extends TestLinkBaseApi {
|
||||||
|
|
||||||
if ("888888".equals(taskid)) {
|
if ("888888".equals(taskid)) {
|
||||||
tp = api.getTestPlanByName(testplan, projectname);
|
tp = api.getTestPlanByName(testplan, projectname);
|
||||||
} else if (taskid.indexOf("NULL") > -1 || LogOperation.GetTestPlanName(taskid).indexOf("NULL") > -1) {
|
} else if (taskid.indexOf("NULL") > -1 || LogOperation.getTestPlanName(taskid).indexOf("NULL") > -1) {
|
||||||
tp = api.getTestPlanByName(TestPlanName(projectname), projectname);
|
tp = api.getTestPlanByName(testPlanName(projectname), projectname);
|
||||||
} else {
|
} else {
|
||||||
tp = api.getTestPlanByName(LogOperation.GetTestPlanName(taskid), projectname);
|
tp = api.getTestPlanByName(LogOperation.getTestPlanName(taskid), projectname);
|
||||||
}
|
}
|
||||||
planid = tp.getId();
|
planid = tp.getId();
|
||||||
//用例明细全部信息
|
//用例明细全部信息
|
||||||
|
@ -198,27 +198,27 @@ public class TestCaseApi extends TestLinkBaseApi {
|
||||||
|
|
||||||
}catch( TestLinkAPIException te) {
|
}catch( TestLinkAPIException te) {
|
||||||
te.printStackTrace( System.err );
|
te.printStackTrace( System.err );
|
||||||
luckyclient.publicclass.LogUtil.ERROR.error("项目:"+projectname+" 测试计划:"+TestPlanName(projectname)+" 读取自动化用例对象异常!");
|
luckyclient.publicclass.LogUtil.ERROR.error("项目:"+projectname+" 测试计划:"+testPlanName(projectname)+" 读取自动化用例对象异常!");
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
return testCases;
|
return testCases;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TestCase getTestCaseByExternalId(String TestCaseExternalId,int version){
|
public static TestCase getTestCaseByExternalId(String testCaseExternalId,int version){
|
||||||
return api.getTestCaseByExternalId(TestCaseExternalId, version);
|
return api.getTestCaseByExternalId(testCaseExternalId, version);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新testlink中用例指定步骤的预期结果
|
* 更新testlink中用例指定步骤的预期结果
|
||||||
*/
|
*/
|
||||||
public static String setTestLinkExpectedResults(String TestCaseExternalId, int version, int steps, String expectedResults) {
|
public static String setTestLinkExpectedResults(String testCaseExternalId, int version, int steps, String expectedResults) {
|
||||||
String results = "设置结果失败";
|
String results = "设置结果失败";
|
||||||
try {
|
try {
|
||||||
TestCase tc = api.getTestCaseByExternalId(TestCaseExternalId, version);
|
TestCase tc = api.getTestCaseByExternalId(testCaseExternalId, version);
|
||||||
|
|
||||||
tc.getSteps().get(steps - 1).setExpectedResults(expectedResults);
|
tc.getSteps().get(steps - 1).setExpectedResults(expectedResults);
|
||||||
api.createTestCaseSteps(tc.getId(), TestCaseExternalId, tc.getVersion(), TestCaseStepAction.UPDATE, tc.getSteps());
|
api.createTestCaseSteps(tc.getId(), testCaseExternalId, tc.getVersion(), TestCaseStepAction.UPDATE, tc.getSteps());
|
||||||
results = "设置结果成功";
|
results = "设置结果成功";
|
||||||
} catch (TestLinkAPIException te) {
|
} catch (TestLinkAPIException te) {
|
||||||
te.printStackTrace(System.err);
|
te.printStackTrace(System.err);
|
||||||
|
@ -232,14 +232,14 @@ public class TestCaseApi extends TestLinkBaseApi {
|
||||||
/**
|
/**
|
||||||
* 更新系统中用例指定步骤的预期结果
|
* 更新系统中用例指定步骤的预期结果
|
||||||
*/
|
*/
|
||||||
public static String setExpectedResults(String TestCaseSign, int steps, String expectedResults) {
|
public static String setExpectedResults(String testCaseSign, int steps, String expectedResults) {
|
||||||
String results = "设置结果失败";
|
String results = "设置结果失败";
|
||||||
String params="";
|
String params="";
|
||||||
try {
|
try {
|
||||||
expectedResults = expectedResults.replace("%", "BBFFHH");
|
expectedResults = expectedResults.replace("%", "BBFFHH");
|
||||||
expectedResults = expectedResults.replace("=", "DHDHDH");
|
expectedResults = expectedResults.replace("=", "DHDHDH");
|
||||||
expectedResults = expectedResults.replace("&", "ANDAND");
|
expectedResults = expectedResults.replace("&", "ANDAND");
|
||||||
params="caseno="+TestCaseSign;
|
params="caseno="+testCaseSign;
|
||||||
params+="&stepnum="+steps;
|
params+="&stepnum="+steps;
|
||||||
params+="&expectedresults="+expectedResults;
|
params+="&expectedresults="+expectedResults;
|
||||||
results=HttpRequest.sendPost("/projectCasesteps/cUpdateStepExpectedResults.do", params);
|
results=HttpRequest.sendPost("/projectCasesteps/cUpdateStepExpectedResults.do", params);
|
||||||
|
@ -256,9 +256,9 @@ public class TestCaseApi extends TestLinkBaseApi {
|
||||||
* 获取指定任务名称以及用例号报错日志中的执行测试结果
|
* 获取指定任务名称以及用例号报错日志中的执行测试结果
|
||||||
* casestatus说明 pass:0 fail:1 lock:2 unexcute:4
|
* casestatus说明 pass:0 fail:1 lock:2 unexcute:4
|
||||||
*/
|
*/
|
||||||
public static String getLogdetail_Runresult(String taskname,String caseno,int casestatus){
|
public static String getLogDetailRunresult(String taskname,String caseno,int casestatus){
|
||||||
int taskid = LogOperation.gettaskexcute_taskid(taskname);
|
int taskid = LogOperation.getTaskExcuteTaskid(taskname);
|
||||||
return LogOperation.getlogdetail_testresult(taskid, caseno,casestatus);
|
return LogOperation.getLogDetailTestResult(taskid, caseno,casestatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -273,7 +273,7 @@ public class TestCaseApi extends TestLinkBaseApi {
|
||||||
TestCase suitecase=api.getTestCaseByExternalId(cases.getFullExternalId(), cases.getVersion());
|
TestCase suitecase=api.getTestCaseByExternalId(cases.getFullExternalId(), cases.getVersion());
|
||||||
List<Integer> suiteid=new ArrayList<Integer>();
|
List<Integer> suiteid=new ArrayList<Integer>();
|
||||||
suiteid.add(suitecase.getTestSuiteId());
|
suiteid.add(suitecase.getTestSuiteId());
|
||||||
TestSuite suite[]=api.getTestSuiteByID(suiteid);
|
TestSuite[] suite=api.getTestSuiteByID(suiteid);
|
||||||
|
|
||||||
String params="";
|
String params="";
|
||||||
|
|
||||||
|
@ -290,7 +290,7 @@ public class TestCaseApi extends TestLinkBaseApi {
|
||||||
String stepsparams="";
|
String stepsparams="";
|
||||||
String resultstr = null;
|
String resultstr = null;
|
||||||
String stepsstr = step.getActions(); //获取actions字符串
|
String stepsstr = step.getActions(); //获取actions字符串
|
||||||
String scriptstr = InterfaceAnalyticTestLinkCase.SubComment(stepsstr);
|
String scriptstr = InterfaceAnalyticTestLinkCase.subComment(stepsstr);
|
||||||
|
|
||||||
if(scriptstr.substring(scriptstr.length()-6, scriptstr.length()).indexOf("*Wait;")>-1){
|
if(scriptstr.substring(scriptstr.length()-6, scriptstr.length()).indexOf("*Wait;")>-1){
|
||||||
String action="";
|
String action="";
|
||||||
|
@ -304,13 +304,13 @@ public class TestCaseApi extends TestLinkBaseApi {
|
||||||
stepsparams="action="+action+"&";
|
stepsparams="action="+action+"&";
|
||||||
scriptstr = scriptstr.substring(0, scriptstr.lastIndexOf("|")+1);
|
scriptstr = scriptstr.substring(0, scriptstr.lastIndexOf("|")+1);
|
||||||
}
|
}
|
||||||
resultstr = InterfaceAnalyticTestLinkCase.SubComment(step.getExpectedResults()); //获取预期结果字符串
|
resultstr = InterfaceAnalyticTestLinkCase.subComment(step.getExpectedResults()); //获取预期结果字符串
|
||||||
stepsparams+="expectedresult="+resultstr.replace("%", "BBFFHH");
|
stepsparams+="expectedresult="+resultstr.replace("%", "BBFFHH");
|
||||||
stepsparams+="&caseid="+caseid;
|
stepsparams+="&caseid="+caseid;
|
||||||
stepsparams+="&stepnum="+k;
|
stepsparams+="&stepnum="+k;
|
||||||
stepsparams+="&projectid="+projectid;
|
stepsparams+="&projectid="+projectid;
|
||||||
stepsparams+="&steptype=0";
|
stepsparams+="&steptype=0";
|
||||||
String temp[]=scriptstr.split("\\|",-1);
|
String[] temp=scriptstr.split("\\|",-1);
|
||||||
String param="";
|
String param="";
|
||||||
for(int i=0;i<temp.length;i++){
|
for(int i=0;i<temp.length;i++){
|
||||||
if(i==0){
|
if(i==0){
|
||||||
|
@ -318,7 +318,7 @@ public class TestCaseApi extends TestLinkBaseApi {
|
||||||
String functionname = temp[i].substring(temp[i].indexOf("#")+1, temp[i].indexOf(";"));
|
String functionname = temp[i].substring(temp[i].indexOf("#")+1, temp[i].indexOf(";"));
|
||||||
stepsparams+="&path="+packagenage.trim(); //set包名
|
stepsparams+="&path="+packagenage.trim(); //set包名
|
||||||
stepsparams+="&operation="+functionname.trim(); //set方法名称
|
stepsparams+="&operation="+functionname.trim(); //set方法名称
|
||||||
}else if(temp[i].equals("")){
|
}else if("".equals(temp[i])){
|
||||||
continue;
|
continue;
|
||||||
}else{
|
}else{
|
||||||
param+=temp[i]+"|";
|
param+=temp[i]+"|";
|
||||||
|
@ -348,7 +348,7 @@ public class TestCaseApi extends TestLinkBaseApi {
|
||||||
TestCase suitecase=api.getTestCaseByExternalId(cases.getFullExternalId(), cases.getVersion());
|
TestCase suitecase=api.getTestCaseByExternalId(cases.getFullExternalId(), cases.getVersion());
|
||||||
List<Integer> suiteid=new ArrayList<Integer>();
|
List<Integer> suiteid=new ArrayList<Integer>();
|
||||||
suiteid.add(suitecase.getTestSuiteId());
|
suiteid.add(suitecase.getTestSuiteId());
|
||||||
TestSuite suite[]=api.getTestSuiteByID(suiteid);
|
TestSuite[] suite=api.getTestSuiteByID(suiteid);
|
||||||
|
|
||||||
String params="";
|
String params="";
|
||||||
|
|
||||||
|
@ -365,7 +365,7 @@ public class TestCaseApi extends TestLinkBaseApi {
|
||||||
String stepsparams="";
|
String stepsparams="";
|
||||||
String resultstr = null;
|
String resultstr = null;
|
||||||
String stepsstr = step.getActions(); //获取actions字符串
|
String stepsstr = step.getActions(); //获取actions字符串
|
||||||
String scriptstr = InterfaceAnalyticTestLinkCase.SubComment(stepsstr);
|
String scriptstr = InterfaceAnalyticTestLinkCase.subComment(stepsstr);
|
||||||
|
|
||||||
if(scriptstr.substring(scriptstr.length()-6, scriptstr.length()).indexOf("*Wait;")>-1){
|
if(scriptstr.substring(scriptstr.length()-6, scriptstr.length()).indexOf("*Wait;")>-1){
|
||||||
String action="";
|
String action="";
|
||||||
|
@ -379,13 +379,13 @@ public class TestCaseApi extends TestLinkBaseApi {
|
||||||
stepsparams="action="+action+"&";
|
stepsparams="action="+action+"&";
|
||||||
scriptstr = scriptstr.substring(0, scriptstr.lastIndexOf("|")+1);
|
scriptstr = scriptstr.substring(0, scriptstr.lastIndexOf("|")+1);
|
||||||
}
|
}
|
||||||
resultstr = InterfaceAnalyticTestLinkCase.SubComment(step.getExpectedResults()); //获取预期结果字符串
|
resultstr = InterfaceAnalyticTestLinkCase.subComment(step.getExpectedResults()); //获取预期结果字符串
|
||||||
stepsparams+="expectedresult="+resultstr.replace("%", "BBFFHH");
|
stepsparams+="expectedresult="+resultstr.replace("%", "BBFFHH");
|
||||||
stepsparams+="&caseid="+caseid;
|
stepsparams+="&caseid="+caseid;
|
||||||
stepsparams+="&stepnum="+k;
|
stepsparams+="&stepnum="+k;
|
||||||
stepsparams+="&projectid="+projectid;
|
stepsparams+="&projectid="+projectid;
|
||||||
stepsparams+="&steptype=1";
|
stepsparams+="&steptype=1";
|
||||||
String temp[]=scriptstr.split("\\|",-1);
|
String[] temp=scriptstr.split("\\|",-1);
|
||||||
for(int i=0;i<temp.length;i++){
|
for(int i=0;i<temp.length;i++){
|
||||||
if(i==0&&temp[i].indexOf("=")>-1&&(temp.length>2||!"".equals(temp[1]))){
|
if(i==0&&temp[i].indexOf("=")>-1&&(temp.length>2||!"".equals(temp[1]))){
|
||||||
stepsparams+="&path="+temp[i].replace("=", "DHDHDH"); //set包名
|
stepsparams+="&path="+temp[i].replace("=", "DHDHDH"); //set包名
|
||||||
|
@ -393,16 +393,16 @@ public class TestCaseApi extends TestLinkBaseApi {
|
||||||
continue;
|
continue;
|
||||||
}else{
|
}else{
|
||||||
String operation = null;
|
String operation = null;
|
||||||
String operation_value = null;
|
String operationValue = null;
|
||||||
if(temp[i].indexOf("(")>-1&&temp[i].indexOf(")")>-1){
|
if(temp[i].indexOf("(")>-1&&temp[i].indexOf(")")>-1){
|
||||||
operation = temp[i].substring(0, temp[i].indexOf("("));
|
operation = temp[i].substring(0, temp[i].indexOf("("));
|
||||||
operation_value = temp[i].substring(temp[i].indexOf("(")+1, temp[i].lastIndexOf(")"));
|
operationValue = temp[i].substring(temp[i].indexOf("(")+1, temp[i].lastIndexOf(")"));
|
||||||
}else{
|
}else{
|
||||||
operation = temp[i];
|
operation = temp[i];
|
||||||
}
|
}
|
||||||
stepsparams+="&operation="+operation.toLowerCase(); //set方法名称
|
stepsparams+="&operation="+operation.toLowerCase(); //set方法名称
|
||||||
if(null!=operation_value){
|
if(null!=operationValue){
|
||||||
stepsparams+="¶meters="+operation_value.replace("%", "BBFFHH"); //set方法名称
|
stepsparams+="¶meters="+operationValue.replace("%", "BBFFHH"); //set方法名称
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -421,9 +421,9 @@ public class TestCaseApi extends TestLinkBaseApi {
|
||||||
* 获取指定任务名称以及用例号报错日志中的执行预期结果
|
* 获取指定任务名称以及用例号报错日志中的执行预期结果
|
||||||
* casestatus说明 pass:0 fail:1 lock:2 unexcute:4
|
* casestatus说明 pass:0 fail:1 lock:2 unexcute:4
|
||||||
*/
|
*/
|
||||||
public static String getLogdetail_Expectresult(String taskname,String caseno,int casestatus){
|
public static String getLogDetailExpectresult(String taskname,String caseno,int casestatus){
|
||||||
int taskid = LogOperation.gettaskexcute_taskid(taskname);
|
int taskid = LogOperation.getTaskExcuteTaskid(taskname);
|
||||||
return LogOperation.getlogdetail_expectresult(taskid, caseno,casestatus);
|
return LogOperation.getLogDetailExpectResult(taskid, caseno,casestatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args){
|
public static void main(String[] args){
|
||||||
|
|
|
@ -9,8 +9,8 @@ import br.eti.kinoshita.testlinkjavaapi.TestLinkAPI;
|
||||||
/**
|
/**
|
||||||
* =================================================================
|
* =================================================================
|
||||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
* 此测试框架主要采用testlink做分层框架,负责数据驱动以及用例管理部分,有任何疑问欢迎联系作者讨论。
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
* QQ:24163551 seagull1985
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
* =================================================================
|
* =================================================================
|
||||||
* @ClassName: TestLinkBaseApi
|
* @ClassName: TestLinkBaseApi
|
||||||
* @Description: 初始化TESTLINK接口
|
* @Description: 初始化TESTLINK接口
|
||||||
|
@ -23,9 +23,9 @@ class TestLinkBaseApi{
|
||||||
/**
|
/**
|
||||||
* @param args
|
* @param args
|
||||||
*/
|
*/
|
||||||
final static Properties properties = luckyclient.publicclass.SysConfig.getConfiguration();
|
final static Properties PROPERTIES = luckyclient.publicclass.SysConfig.getConfiguration();
|
||||||
private final static String TESTLINK_URL = "http://"+properties.getProperty("testlink.api.ip")+":80/testlink/lib/api/xmlrpc/v1/xmlrpc.php";
|
private final static String TESTLINK_URL = "http://"+PROPERTIES.getProperty("testlink.api.ip")+":80/testlink/lib/api/xmlrpc/v1/xmlrpc.php";
|
||||||
protected final static String TESTLINK_DEVKEY = properties.getProperty("testlink.api.devkey");
|
protected final static String TESTLINK_DEVKEY = PROPERTIES.getProperty("testlink.api.devkey");
|
||||||
protected final static Integer PLATFORMID = 0;
|
protected final static Integer PLATFORMID = 0;
|
||||||
protected final static String PLATFORMNAME = null;
|
protected final static String PLATFORMNAME = null;
|
||||||
protected static TestLinkAPI api= iniTestlinkApi();
|
protected static TestLinkAPI api= iniTestlinkApi();
|
||||||
|
@ -41,13 +41,13 @@ class TestLinkBaseApi{
|
||||||
return new TestLinkAPI(testlinkURL, TESTLINK_DEVKEY);
|
return new TestLinkAPI(testlinkURL, TESTLINK_DEVKEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static String TestPlanName(String projectname){
|
protected static String testPlanName(String projectname){
|
||||||
return api.getTestProjectByName(projectname).getNotes().substring(
|
return api.getTestProjectByName(projectname).getNotes().substring(
|
||||||
api.getTestProjectByName(projectname).getNotes().indexOf("<p>")+3,
|
api.getTestProjectByName(projectname).getNotes().indexOf("<p>")+3,
|
||||||
api.getTestProjectByName(projectname).getNotes().indexOf("</p>")).trim();
|
api.getTestProjectByName(projectname).getNotes().indexOf("</p>")).trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static Integer ProjectID(String projectname){
|
protected static Integer projectID(String projectname){
|
||||||
return api.getTestProjectByName(projectname).getId();
|
return api.getTestProjectByName(projectname).getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,8 @@ import luckyclient.dblog.LogOperation;
|
||||||
/**
|
/**
|
||||||
* =================================================================
|
* =================================================================
|
||||||
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
* 此测试框架主要采用testlink做分层框架,负责数据驱动以及用例管理部分,有任何疑问欢迎联系作者讨论。
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
* QQ:24163551 seagull1985
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
* =================================================================
|
* =================================================================
|
||||||
* @ClassName: AnalyticCase
|
* @ClassName: AnalyticCase
|
||||||
* @Description: 解析单个用例中描述部分的脚本
|
* @Description: 解析单个用例中描述部分的脚本
|
||||||
|
@ -28,7 +28,7 @@ public class WebDriverAnalyticTestLinkCase {
|
||||||
* @param args
|
* @param args
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("finally")
|
@SuppressWarnings("finally")
|
||||||
public static Map<String,String> AnalyticCaseStep(TestCase testcase,Integer ordersteps,String tastid,LogOperation caselog){
|
public static Map<String,String> analyticCaseStep(TestCase testcase,Integer ordersteps,String tastid,LogOperation caselog){
|
||||||
String time = "0";
|
String time = "0";
|
||||||
Map<String,String> params = new HashMap<String,String>();
|
Map<String,String> params = new HashMap<String,String>();
|
||||||
|
|
||||||
|
@ -36,91 +36,91 @@ public class WebDriverAnalyticTestLinkCase {
|
||||||
try {
|
try {
|
||||||
List<TestCaseStep> testcasesteps = (List<TestCaseStep>) testcase.getSteps();
|
List<TestCaseStep> testcasesteps = (List<TestCaseStep>) testcase.getSteps();
|
||||||
String stepsstr = testcasesteps.get(ordersteps-1).getActions(); //获取actions字符串
|
String stepsstr = testcasesteps.get(ordersteps-1).getActions(); //获取actions字符串
|
||||||
String scriptstr = SubComment(stepsstr);
|
String scriptstr = subComment(stepsstr);
|
||||||
if(scriptstr.substring(scriptstr.length()-6, scriptstr.length()).toLowerCase().indexOf("*wait;")>-1){ //添加步骤之间等待时间
|
if(scriptstr.substring(scriptstr.length()-6, scriptstr.length()).toLowerCase().indexOf("*wait;")>-1){ //添加步骤之间等待时间
|
||||||
time = scriptstr.substring(scriptstr.lastIndexOf("|")+1,scriptstr.toLowerCase().lastIndexOf("*wait;"));
|
time = scriptstr.substring(scriptstr.lastIndexOf("|")+1,scriptstr.toLowerCase().lastIndexOf("*wait;"));
|
||||||
scriptstr = scriptstr.substring(0, scriptstr.lastIndexOf("|")+1);
|
scriptstr = scriptstr.substring(0, scriptstr.lastIndexOf("|")+1);
|
||||||
}
|
}
|
||||||
resultstr = testcasesteps.get(ordersteps-1).getExpectedResults(); //获取预期结果字符串
|
resultstr = testcasesteps.get(ordersteps-1).getExpectedResults(); //获取预期结果字符串
|
||||||
String temp[]=scriptstr.split(splitFlag,-1);
|
String[] temp=scriptstr.split(splitFlag,-1);
|
||||||
for(int i=0;i<temp.length;i++){
|
for(int i=0;i<temp.length;i++){
|
||||||
if(i==0&&temp[i].indexOf("=")>-1&&(temp.length>2||!"".equals(temp[1]))){
|
if(i==0&&temp[i].indexOf("=")>-1&&(temp.length>2||!"".equals(temp[1]))){
|
||||||
String property = temp[i].substring(0, temp[i].indexOf("="));
|
String property = temp[i].substring(0, temp[i].indexOf("="));
|
||||||
String property_value = temp[i].substring(temp[i].indexOf("=")+1, temp[i].length());
|
String propertyValue = temp[i].substring(temp[i].indexOf("=")+1, temp[i].length());
|
||||||
|
|
||||||
params.put("property", property.trim().toLowerCase()); //set属性
|
params.put("property", property.trim().toLowerCase()); //set属性
|
||||||
params.put("property_value", property_value.trim()); //set属性值
|
params.put("property_value", propertyValue.trim()); //set属性值
|
||||||
luckyclient.publicclass.LogUtil.APP.info("对象属性解析结果:property:"+property.trim()+"; property_value:"+property_value.trim());
|
luckyclient.publicclass.LogUtil.APP.info("对象属性解析结果:property:"+property.trim()+"; property_value:"+propertyValue.trim());
|
||||||
}else if("".equals(temp[i])){
|
}else if("".equals(temp[i])){
|
||||||
continue;
|
continue;
|
||||||
}else{
|
}else{
|
||||||
String operation = null;
|
String operation = null;
|
||||||
String operation_value = null;
|
String operationValue = null;
|
||||||
if(temp[i].indexOf("(")>-1&&temp[i].indexOf(")")>-1){
|
if(temp[i].indexOf("(")>-1&&temp[i].indexOf(")")>-1){
|
||||||
operation = temp[i].substring(0, temp[i].indexOf("("));
|
operation = temp[i].substring(0, temp[i].indexOf("("));
|
||||||
operation_value = temp[i].substring(temp[i].indexOf("(")+1, temp[i].lastIndexOf(")"));
|
operationValue = temp[i].substring(temp[i].indexOf("(")+1, temp[i].lastIndexOf(")"));
|
||||||
}else{
|
}else{
|
||||||
operation = temp[i];
|
operation = temp[i];
|
||||||
}
|
}
|
||||||
params.put("operation", operation.toLowerCase()); //set操作方法
|
params.put("operation", operation.toLowerCase()); //set操作方法
|
||||||
params.put("operation_value", operation_value); //set操作值
|
params.put("operation_value", operationValue); //set操作值
|
||||||
luckyclient.publicclass.LogUtil.APP.info("对象操作解析结果:operation:"+operation+"; operation_value:"+operation_value);
|
luckyclient.publicclass.LogUtil.APP.info("对象操作解析结果:operation:"+operation+"; operation_value:"+operationValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//set预期结果
|
//set预期结果
|
||||||
if(resultstr.equals("")){
|
if(resultstr.equals("")){
|
||||||
params.put("ExpectedResults", "");
|
params.put("ExpectedResults", "");
|
||||||
}else{
|
}else{
|
||||||
String ExpectedResults = SubComment(resultstr);
|
String expectedResults = subComment(resultstr);
|
||||||
|
|
||||||
//处理check字段
|
//处理check字段
|
||||||
if(ExpectedResults.indexOf("check(")>-1){
|
if(expectedResults.indexOf("check(")>-1){
|
||||||
params.put("checkproperty", ExpectedResults.substring(ExpectedResults.indexOf("check(")+6, ExpectedResults.indexOf("=")));
|
params.put("checkproperty", expectedResults.substring(expectedResults.indexOf("check(")+6, expectedResults.indexOf("=")));
|
||||||
params.put("checkproperty_value", ExpectedResults.substring(ExpectedResults.indexOf("=")+1, ExpectedResults.indexOf(")")));
|
params.put("checkproperty_value", expectedResults.substring(expectedResults.indexOf("=")+1, expectedResults.indexOf(")")));
|
||||||
}
|
}
|
||||||
params.put("ExpectedResults", ExpectedResults);
|
params.put("ExpectedResults", expectedResults);
|
||||||
luckyclient.publicclass.LogUtil.APP.info("预期结果解析:ExpectedResults:"+ExpectedResults);
|
luckyclient.publicclass.LogUtil.APP.info("预期结果解析:ExpectedResults:"+expectedResults);
|
||||||
}
|
}
|
||||||
params.put("StepWait", time);
|
params.put("StepWait", time);
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例编号:"+testcase.getFullExternalId()+" 步骤编号:"+ordersteps+" 解析自动化用例步骤脚本完成!");
|
luckyclient.publicclass.LogUtil.APP.info("用例编号:"+testcase.getFullExternalId()+" 步骤编号:"+ordersteps+" 解析自动化用例步骤脚本完成!");
|
||||||
if(null!=caselog){
|
if(null!=caselog){
|
||||||
caselog.CaseLogDetail(tastid, testcase.getFullExternalId(),"步骤编号:"+ordersteps+" 解析自动化用例步骤脚本完成!","info",String.valueOf(ordersteps),"");
|
caselog.caseLogDetail(tastid, testcase.getFullExternalId(),"步骤编号:"+ordersteps+" 解析自动化用例步骤脚本完成!","info",String.valueOf(ordersteps),"");
|
||||||
}
|
}
|
||||||
}catch(Exception e) {
|
}catch(Exception e) {
|
||||||
luckyclient.publicclass.LogUtil.ERROR.error("用例编号:"+testcase.getFullExternalId()+" 步骤编号:"+ordersteps+" 解析自动化用例步骤脚本出错!");
|
luckyclient.publicclass.LogUtil.ERROR.error("用例编号:"+testcase.getFullExternalId()+" 步骤编号:"+ordersteps+" 解析自动化用例步骤脚本出错!");
|
||||||
if(null!=caselog){
|
if(null!=caselog){
|
||||||
caselog.CaseLogDetail(tastid, testcase.getFullExternalId(),"步骤编号:"+ordersteps+" 解析自动化用例步骤脚本出错!","error",String.valueOf(ordersteps),"");
|
caselog.caseLogDetail(tastid, testcase.getFullExternalId(),"步骤编号:"+ordersteps+" 解析自动化用例步骤脚本出错!","error",String.valueOf(ordersteps),"");
|
||||||
}
|
}
|
||||||
luckyclient.publicclass.LogUtil.ERROR.error(e,e);
|
luckyclient.publicclass.LogUtil.ERROR.error(e,e);
|
||||||
params.put("exception","用例编号:"+testcase.getFullExternalId()+"|解析异常,用例步骤为空或是用例脚本错误!");
|
params.put("exception","用例编号:"+testcase.getFullExternalId()+"|解析异常,用例步骤为空或是用例脚本错误!");
|
||||||
}finally{
|
return params;
|
||||||
return params;
|
|
||||||
}
|
}
|
||||||
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String SubComment(String htmlStr) throws InterruptedException{
|
private static String subComment(String htmlStr) throws InterruptedException{
|
||||||
String regEx_script = "<script[^>]*?>[\\s\\S]*?<\\/script>"; // 定义script的正则表达式
|
String regExScript = "<script[^>]*?>[\\s\\S]*?<\\/script>"; // 定义script的正则表达式
|
||||||
String regEx_style = "<style[^>]*?>[\\s\\S]*?<\\/style>"; // 定义style的正则表达式
|
String regExStyle = "<style[^>]*?>[\\s\\S]*?<\\/style>"; // 定义style的正则表达式
|
||||||
String regEx_html = "<[^>]+>"; // 定义HTML标签的正则表达式
|
String regExHtml = "<[^>]+>"; // 定义HTML标签的正则表达式
|
||||||
String regEx_space = "\t|\r|\n";//定义空格回车换行符
|
String regExSpace = "\t|\r|\n";//定义空格回车换行符
|
||||||
|
|
||||||
String scriptstr = null;
|
String scriptstr = null;
|
||||||
if (htmlStr!=null) {
|
if (htmlStr!=null) {
|
||||||
Pattern p_script = Pattern.compile(regEx_script, Pattern.CASE_INSENSITIVE);
|
Pattern pScript = Pattern.compile(regExScript, Pattern.CASE_INSENSITIVE);
|
||||||
Matcher m_script = p_script.matcher(htmlStr);
|
Matcher mScript = pScript.matcher(htmlStr);
|
||||||
htmlStr = m_script.replaceAll(""); // 过滤script标签
|
htmlStr = mScript.replaceAll(""); // 过滤script标签
|
||||||
|
|
||||||
Pattern p_style = Pattern.compile(regEx_style, Pattern.CASE_INSENSITIVE);
|
Pattern pStyle = Pattern.compile(regExStyle, Pattern.CASE_INSENSITIVE);
|
||||||
Matcher m_style = p_style.matcher(htmlStr);
|
Matcher mStyle = pStyle.matcher(htmlStr);
|
||||||
htmlStr = m_style.replaceAll(""); // 过滤style标签
|
htmlStr = mStyle.replaceAll(""); // 过滤style标签
|
||||||
|
|
||||||
Pattern p_html = Pattern.compile(regEx_html, Pattern.CASE_INSENSITIVE);
|
Pattern pHtml = Pattern.compile(regExHtml, Pattern.CASE_INSENSITIVE);
|
||||||
Matcher m_html = p_html.matcher(htmlStr);
|
Matcher mHtml = pHtml.matcher(htmlStr);
|
||||||
htmlStr = m_html.replaceAll(""); // 过滤html标签
|
htmlStr = mHtml.replaceAll(""); // 过滤html标签
|
||||||
|
|
||||||
Pattern p_space = Pattern.compile(regEx_space, Pattern.CASE_INSENSITIVE);
|
Pattern pSpace = Pattern.compile(regExSpace, Pattern.CASE_INSENSITIVE);
|
||||||
Matcher m_space = p_space.matcher(htmlStr);
|
Matcher mSpace = pSpace.matcher(htmlStr);
|
||||||
htmlStr = m_space.replaceAll(""); // 过滤空格回车标签
|
htmlStr = mSpace.replaceAll(""); // 过滤空格回车标签
|
||||||
|
|
||||||
}
|
}
|
||||||
if(htmlStr.indexOf("/*")>-1&&htmlStr.indexOf("*/")>-1){
|
if(htmlStr.indexOf("/*")>-1&&htmlStr.indexOf("*/")>-1){
|
||||||
|
|
|
@ -2,6 +2,17 @@ package rmi.model;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
//注意对象必须继承Serializable
|
//注意对象必须继承Serializable
|
||||||
public class RunBatchCaseEntity implements Serializable {
|
public class RunBatchCaseEntity implements Serializable {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,6 +2,17 @@ package rmi.model;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
//注意对象必须继承Serializable
|
//注意对象必须继承Serializable
|
||||||
public class RunCaseEntity implements Serializable {
|
public class RunCaseEntity implements Serializable {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,6 +2,17 @@ package rmi.model;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
//注意对象必须继承Serializable
|
//注意对象必须继承Serializable
|
||||||
public class RunTaskEntity implements Serializable {
|
public class RunTaskEntity implements Serializable {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -4,9 +4,19 @@ import java.rmi.Naming;
|
||||||
import java.rmi.registry.LocateRegistry;
|
import java.rmi.registry.LocateRegistry;
|
||||||
|
|
||||||
import rmi.service.RunService;
|
import rmi.service.RunService;
|
||||||
import rmi.serviceImpl.RunServiceImpl;
|
import rmi.serviceimpl.RunServiceImpl;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class Program{
|
public class Program{
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
|
@ -7,6 +7,17 @@ import rmi.model.RunBatchCaseEntity;
|
||||||
import rmi.model.RunCaseEntity;
|
import rmi.model.RunCaseEntity;
|
||||||
import rmi.model.RunTaskEntity;
|
import rmi.model.RunTaskEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
//此为远程对象调用的接口,必须继承Remote类
|
//此为远程对象调用的接口,必须继承Remote类
|
||||||
public interface RunService extends Remote {
|
public interface RunService extends Remote {
|
||||||
public String runtask(RunTaskEntity task,String loadpath) throws RemoteException;
|
public String runtask(RunTaskEntity task,String loadpath) throws RemoteException;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package rmi.serviceImpl;
|
package rmi.serviceimpl;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
|
@ -19,7 +19,17 @@ import rmi.model.RunTaskEntity;
|
||||||
import rmi.service.RunService;
|
import rmi.service.RunService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* =================================================================
|
||||||
|
* 这是一个受限制的自由软件!您不能在任何未经允许的前提下对程序代码进行修改和用于商业用途;也不允许对程序代码修改后以任何形式任何目的的再发布。
|
||||||
|
* 为了尊重作者的劳动成果,LuckyFrame关键版权信息严禁篡改
|
||||||
|
* 有任何疑问欢迎联系作者讨论。 QQ:1573584944 seagull1985
|
||||||
|
* =================================================================
|
||||||
|
*
|
||||||
|
* @author: seagull
|
||||||
|
* @date 2017年12月1日 上午9:29:40
|
||||||
|
*
|
||||||
|
*/
|
||||||
//此为远程对象的实现类,须继承UnicastRemoteObject
|
//此为远程对象的实现类,须继承UnicastRemoteObject
|
||||||
public class RunServiceImpl extends UnicastRemoteObject implements RunService{
|
public class RunServiceImpl extends UnicastRemoteObject implements RunService{
|
||||||
|
|
||||||
|
@ -143,6 +153,7 @@ public class RunServiceImpl extends UnicastRemoteObject implements RunService{
|
||||||
* @param realName
|
* @param realName
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getlogdetail(String storeName) throws RemoteException{
|
public String getlogdetail(String storeName) throws RemoteException{
|
||||||
BufferedReader bos = null;
|
BufferedReader bos = null;
|
||||||
String ctxPath = System.getProperty("user.dir")+"\\log\\";
|
String ctxPath = System.getProperty("user.dir")+"\\log\\";
|
||||||
|
@ -187,6 +198,7 @@ public class RunServiceImpl extends UnicastRemoteObject implements RunService{
|
||||||
* @param realName
|
* @param realName
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public byte[] getlogimg(String imgName) throws RemoteException{
|
public byte[] getlogimg(String imgName) throws RemoteException{
|
||||||
String ctxPath = System.getProperty("user.dir")+"\\log\\ScreenShot\\";
|
String ctxPath = System.getProperty("user.dir")+"\\log\\ScreenShot\\";
|
||||||
String downLoadPath = ctxPath+imgName;
|
String downLoadPath = ctxPath+imgName;
|
||||||
|
@ -218,6 +230,7 @@ public class RunServiceImpl extends UnicastRemoteObject implements RunService{
|
||||||
* @param realName
|
* @param realName
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String uploadjar(byte[] fileContent,String name,String loadpath) throws RemoteException{
|
public String uploadjar(byte[] fileContent,String name,String loadpath) throws RemoteException{
|
||||||
String path = System.getProperty("user.dir")+loadpath;
|
String path = System.getProperty("user.dir")+loadpath;
|
||||||
if (!new File(path) .isDirectory())
|
if (!new File(path) .isDirectory())
|
||||||
|
@ -249,6 +262,7 @@ public class RunServiceImpl extends UnicastRemoteObject implements RunService{
|
||||||
return "上传"+name+"至客户端成功!";
|
return "上传"+name+"至客户端成功!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getClientStatus() throws RemoteException{
|
public String getClientStatus() throws RemoteException{
|
||||||
return "success";
|
return "success";
|
||||||
}
|
}
|
Loading…
Reference in New Issue