修复部分全并支干导致的bug

This commit is contained in:
seagull 2018-03-12 18:55:40 +08:00
parent 155f8112e0
commit acfa518d83
6 changed files with 52 additions and 254 deletions

View File

@ -1,92 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="Spring" name="Spring">
<configuration />
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/Resources" type="java-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:3.8.1" level="project" />
<orderEntry type="library" name="Maven: c3p0:c3p0:0.9.1.2" level="project" />
<orderEntry type="library" name="Maven: com.jcraft:jsch:0.1.54" level="project" />
<orderEntry type="library" name="Maven: javax.mail:mail:1.4.7" level="project" />
<orderEntry type="library" name="Maven: javax.activation:activation:1.1" level="project" />
<orderEntry type="library" name="Maven: commons-beanutils:commons-beanutils:1.9.3" level="project" />
<orderEntry type="library" name="Maven: commons-cli:commons-cli:1.3.1" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.10" level="project" />
<orderEntry type="library" name="Maven: commons-collections:commons-collections:3.2.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-compress:1.13" level="project" />
<orderEntry type="library" name="Maven: commons-configuration:commons-configuration:1.10" level="project" />
<orderEntry type="library" name="Maven: commons-daemon:commons-daemon:1.0.15" level="project" />
<orderEntry type="library" name="Maven: commons-digester:commons-digester:2.1" level="project" />
<orderEntry type="library" name="Maven: commons-el:commons-el:1.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.3" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.6" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.5" level="project" />
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-math:2.2" level="project" />
<orderEntry type="library" name="Maven: commons-net:commons-net:3.6" level="project" />
<orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.24" level="project" />
<orderEntry type="library" name="Maven: br.eti.kinoshita:testlink-java-api:1.9.16-0" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.5" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.8.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-core:2.8.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-configuration2:2.1.1" level="project" />
<orderEntry type="library" name="Maven: commons-httpclient:commons-httpclient:3.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.xmlrpc:xmlrpc-client:3.1.3" level="project" />
<orderEntry type="library" name="Maven: org.apache.xmlrpc:xmlrpc-common:3.1.3" level="project" />
<orderEntry type="library" name="Maven: org.apache.ws.commons.util:ws-commons-util:1.0.2" level="project" />
<orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-java:3.8.1" level="project" />
<orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-api:3.8.1" level="project" />
<orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-chrome-driver:3.8.1" level="project" />
<orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-edge-driver:3.8.1" level="project" />
<orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-firefox-driver:3.8.1" level="project" />
<orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-ie-driver:3.8.1" level="project" />
<orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-opera-driver:3.8.1" level="project" />
<orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-safari-driver:3.8.1" level="project" />
<orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-support:3.8.1" level="project" />
<orderEntry type="library" name="Maven: net.bytebuddy:byte-buddy:1.7.5" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-exec:1.3" level="project" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.2" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:23.0" level="project" />
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:1.3.9" level="project" />
<orderEntry type="library" name="Maven: com.google.errorprone:error_prone_annotations:2.0.18" level="project" />
<orderEntry type="library" name="Maven: com.google.j2objc:j2objc-annotations:1.1" level="project" />
<orderEntry type="library" name="Maven: org.codehaus.mojo:animal-sniffer-annotations:1.14" level="project" />
<orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-remote-driver:3.8.1" level="project" />
<orderEntry type="library" name="Maven: xml-apis:xml-apis:1.4.01" level="project" />
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:6.0.5" level="project" />
<orderEntry type="library" name="Maven: org.freemarker:freemarker:2.3.26-incubating" level="project" />
<orderEntry type="library" name="Maven: net.sf.json-lib:json-lib:jdk15:2.4" level="project" />
<orderEntry type="library" name="Maven: net.sf.ezmorph:ezmorph:1.0.6" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.5.2" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.5.0" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.5.1" level="project" />
<orderEntry type="library" name="Maven: io.appium:java-client:6.0.0-BETA2" level="project" />
<orderEntry type="library" name="Maven: cglib:cglib:3.2.5" level="project" />
<orderEntry type="library" name="Maven: org.ow2.asm:asm:5.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.ant:ant:1.9.6" level="project" />
<orderEntry type="library" name="Maven: org.apache.ant:ant-launcher:1.9.6" level="project" />
<orderEntry type="library" name="Maven: commons-validator:commons-validator:1.6" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context:5.0.2.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.0.2.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:5.0.2.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:5.0.2.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.0.2.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-expression:5.0.2.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.aspectj:aspectjweaver:1.8.13" level="project" />
<orderEntry type="library" name="Maven: org.openpnp:opencv:3.2.0-1" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpmime:4.5.4" level="project" />
</component>
</module>

View File

@ -23,7 +23,7 @@ mail.smtp.ip=XX.XX.XX.XX
#smtp邮件端口 例25
mail.smtp.port=465
#smtp邮件ssl连接开启 例true false
mail.smtp.ssl.enable=true
mail.smtp.ssl.enable=false
#smtp邮件用户名
mail.smtp.username=XX@XX.com
#smtp邮件用户密码

View File

@ -24,6 +24,7 @@ public class AppDriverAnalyticCase {
//private static String splitFlag = "\\|";
/**
* @param args
*/
public static Map<String,String> analyticCaseStep(ProjectCase projectcase,ProjectCasesteps step,String taskid,LogOperation caselog){
String time = "0";

View File

@ -208,6 +208,7 @@ public class TestCaseExecution {
* @param taskid 任务ID
* @param caselog 日志操作对象
* 用于在UI的测试过程中需要调用接口的测试用例
* @deprecated
*/
protected static String oneCaseExecuteForWebDriver(String testCaseExternalId, String taskid, LogOperation caselog) {
Map<String, String> variable = new HashMap<String, String>(0);
@ -347,6 +348,16 @@ public class TestCaseExecution {
return testnote;
}
/**
*
* @param testCaseExternalId
* @param taskid
* @param caselog
* @param driver
* @return
* @throws InterruptedException
* 提供给Web用例中runcase的时候使用
*/
protected static String oneCaseExecuteForWebCase(String testCaseExternalId, String taskid, LogOperation caselog, WebDriver driver) throws InterruptedException {
Map<String, String> variable = new HashMap<>(0);
String expectedresults = null;
@ -372,8 +383,11 @@ public class TestCaseExecution {
String result;
// 根据步骤类型来分析步骤参数
if (1 == step.getSteptype()) params = WebDriverAnalyticCase.analyticCaseStep(testcaseob, step, taskid, caselog);
else params = InterfaceAnalyticCase.analyticCaseStep(testcaseob, step, taskid, caselog);
if (1 == step.getSteptype()){
params = WebDriverAnalyticCase.analyticCaseStep(testcaseob, step, taskid, caselog);
} else{
params = InterfaceAnalyticCase.analyticCaseStep(testcaseob, step, taskid, caselog);
}
// 判断分析步骤参数是否有异常
if (params.get("exception") != null && params.get("exception").contains("解析异常")) {
@ -382,14 +396,20 @@ public class TestCaseExecution {
}
// 根据步骤类型来执行步骤
if (1 == step.getSteptype()) result = WebCaseExecution.runWebStep(params, variable, driver, taskid, testcaseob.getSign(), step.getStepnum(), caselog);
else result = WebCaseExecution.runStep(params, variable, taskid, testcaseob.getSign(), step, caselog);
if (1 == step.getSteptype()){
result = WebCaseExecution.runWebStep(params, variable, driver, taskid, testcaseob.getSign(), step.getStepnum(), caselog);
} else{
result = WebCaseExecution.runStep(params, variable, taskid, testcaseob.getSign(), step, caselog);
}
expectedresults = params.get("ExpectedResults");
expectedresults = ChangString.changparams(expectedresults, variable, "预期结果");
// 判断结果
if (0 != (setresult = WebCaseExecution.judgeResult(testcaseob, step, params, driver, taskid, expectedresults, result, caselog))) break;
setresult = WebCaseExecution.judgeResult(testcaseob, step, params, driver, taskid, expectedresults, result, caselog);
if (0 != setresult){
break;
}
}
variable.clear(); // 清空传参MAP

View File

@ -25,7 +25,6 @@ public class InterfaceAnalyticCase{
/**
*/
@SuppressWarnings("finally")
public static Map<String,String> analyticCaseStep(ProjectCase projectcase,ProjectCasesteps step,String taskid,LogOperation caselog){
String time = "0";
Map<String,String> params = new HashMap<String,String>(0);

View File

@ -40,145 +40,6 @@ public class WebCaseExecution extends TestCaseExecution {
private static String casenote = "备注初始化";
private static String imagname = "";
/*
public static void caseExcutionBak(ProjectCase testcase, List<ProjectCasesteps> steps, String taskid, WebDriver wd, LogOperation caselog, List<PublicCaseParams> pcplist)
throws InterruptedException {
// 0:成功 1:失败 2:锁定 其他锁定
int setresult = 0;
String casenote = "备注初始化";
String imagname = "";
// 把公共参数加入到MAP中
for (PublicCaseParams pcp : pcplist) {
variable.put(pcp.getParamsname(), pcp.getParamsvalue());
}
//插入开始执行的用例
caselog.addCaseDetail(taskid, testcase.getSign(), "1", testcase.getName(), 4);
for (ProjectCasesteps step : steps) {
Map<String, String> params = WebDriverAnalyticCase.analyticCaseStep(testcase, step, taskid, caselog);
if (params.get("exception") != null && params.get("exception").toString().indexOf("解析异常") > -1) {
setresult = 2;
break;
}
String result = WebCaseExecution.runStep(params, wd, taskid, testcase.getSign(), step.getStepnum(), caselog);
String expectedResults = params.get("ExpectedResults").toString();
expectedResults = ChangString.changparams(expectedResults, variable, "预期结果");
// 运行结果正常
if (result.indexOf("出错") < 0 && result.indexOf("失败") < 0) {
// 获取步骤间等待时间
int waitsec = Integer.parseInt(params.get("StepWait").toString());
if (waitsec != 0) {
luckyclient.publicclass.LogUtil.APP.info("操作休眠【" + waitsec + "】秒");
Thread.sleep(waitsec * 1000);
}
// 有预期结果
if (!"".equals(expectedResults)) {
// 判断传参
luckyclient.publicclass.LogUtil.APP.info("expectedResults=【" + expectedResults + "");
if (expectedResults.length() > 2 && expectedResults.substring(0, 2).indexOf("$=") > -1) {
String expectedResultVariable = expectedResults.substring(2);
variable.put(expectedResultVariable, result);
continue;
}
// 判断预期结果-检查模式
if (params.get("checkproperty") != null && params.get("checkproperty_value") != null) {
String checkproperty = params.get("checkproperty").toString();
String checkPropertyValue = params.get("checkproperty_value").toString();
WebElement we = isElementExist(wd, checkproperty, checkPropertyValue);
if (null != we) {
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + "" + step.getStepnum()
+ "步,在当前页面中找到预期结果中对象。当前步骤执行成功!");
caselog.caseLogDetail(taskid, testcase.getSign(), "在当前页面中找到预期结果中对象。当前步骤执行成功!",
"info", String.valueOf(step.getStepnum()), "");
continue;
} else {
casenote = "" + step.getStepnum() + "步,没有在当前页面中找到预期结果中对象。执行失败!";
setresult = 1;
java.text.DateFormat timeformat = new java.text.SimpleDateFormat("MMdd-hhmmss");
imagname = timeformat.format(new Date());
BaseWebDrive.webScreenShot(wd, imagname);
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getSign() + "" + step.getStepnum()
+ "步,没有在当前页面中找到预期结果中对象。当前步骤执行失败!");
caselog.caseLogDetail(taskid, testcase.getSign(), "在当前页面中没有找到预期结果中对象。当前步骤执行失败!"
+ "checkproperty【" + checkproperty + "】 checkproperty_value【" + checkPropertyValue + "", "error", String.valueOf(step.getStepnum()), imagname);
break;
}
} else {
// 模糊匹配预期结果模式
if (expectedResults.length() > 2 && expectedResults.substring(0, 2).indexOf("%=") > -1) {
if (result.indexOf(expectedResults.substring(2)) > -1) {
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + "" + step.getStepnum()
+ "步,模糊匹配预期结果成功!执行结果:" + result);
caselog.caseLogDetail(taskid, testcase.getSign(), "步骤模糊匹配预期结果成功!",
"info", String.valueOf(step.getStepnum()), "");
continue;
} else {
casenote = "" + step.getStepnum() + "步,模糊匹配预期结果失败!";
setresult = 1;
java.text.DateFormat timeformat = new java.text.SimpleDateFormat("MMdd-hhmmss");
imagname = timeformat.format(new Date());
BaseWebDrive.webScreenShot(wd, imagname);
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getSign() + "" + step.getStepnum()
+ "步,模糊匹配预期结果失败!执行结果:" + result);
caselog.caseLogDetail(taskid, testcase.getSign(), "步骤模糊匹配预期结果失败!执行结果:" + result,
"error", String.valueOf(step.getStepnum()), imagname);
break;
}
// 直接匹配预期结果模式
} else if (expectedResults.equals(result)) {
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + "" + step.getStepnum()
+ "步,直接匹配预期结果成功!执行结果:" + result);
caselog.caseLogDetail(taskid, testcase.getSign(), "步骤直接匹配预期结果成功!",
"info", String.valueOf(step.getStepnum()), "");
continue;
} else {
casenote = "" + step.getStepnum() + "步,直接匹配预期结果失败!";
setresult = 1;
java.text.DateFormat timeformat = new java.text.SimpleDateFormat("MMdd-hhmmss");
imagname = timeformat.format(new Date());
BaseWebDrive.webScreenShot(wd, imagname);
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getSign() + "" + step.getStepnum()
+ "步,直接匹配预期结果失败!执行结果:" + result);
caselog.caseLogDetail(taskid, testcase.getSign(), "步骤直接匹配预期结果失败!执行结果:" + result,
"error", String.valueOf(step.getStepnum()), imagname);
break;
}
}
}
} else {
casenote = result;
setresult = 2;
java.text.DateFormat timeformat = new java.text.SimpleDateFormat("MMdd-hhmmss");
imagname = timeformat.format(new Date());
BaseWebDrive.webScreenShot(wd, imagname);
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getSign() + "" + step.getStepnum() + "步," + result);
caselog.caseLogDetail(taskid, testcase.getSign(), "当前步骤在执行过程中解析|定位元素|操作对象失败!" + result,
"error", String.valueOf(step.getStepnum()), imagname);
break;
}
}
variable.clear();
caselog.updateCaseDetail(taskid, testcase.getSign(), setresult);
if (setresult == 0) {
luckyclient.publicclass.LogUtil.APP.info("用例【" + testcase.getSign() + "】全部步骤执行结果成功...");
caselog.caseLogDetail(taskid, testcase.getSign(), "用例全部步骤执行结果成功", "info", "ending", "");
} else {
luckyclient.publicclass.LogUtil.APP.error("用例【" + testcase.getSign() + "】步骤执行过程中失败或是锁定...请查看具体原因!" + casenote);
caselog.caseLogDetail(taskid, testcase.getSign(), "用例执行过程中失败或是锁定" + casenote, "error", "ending", "");
}
//LogOperation.UpdateTastdetail(taskid, 0);
}
*/
public static void caseExcution(ProjectCase testcase, List<ProjectCasesteps> steps, String taskid, WebDriver wd, LogOperation caselog, List<PublicCaseParams> pcplist) throws InterruptedException {
// 把公共参数加入到MAP中
for (PublicCaseParams pcp : pcplist) {
@ -192,24 +53,33 @@ public class WebCaseExecution extends TestCaseExecution {
String result;
// 根据步骤类型来分析步骤参数
if (1 == step.getSteptype()) params = WebDriverAnalyticCase.analyticCaseStep(testcase, step, taskid, caselog);
else params = InterfaceAnalyticCase.analyticCaseStep(testcase, step, taskid, caselog);
if (1 == step.getSteptype()){
params = WebDriverAnalyticCase.analyticCaseStep(testcase, step, taskid, caselog);
}else{
params = InterfaceAnalyticCase.analyticCaseStep(testcase, step, taskid, caselog);
}
// 判断分析步骤参数是否有异常
if (params.get("exception") != null && params.get("exception").contains("解析异常")) {
if (null != params.get("exception") && params.get("exception").contains("解析异常")) {
setresult = 2;
break;
}
// 根据步骤类型来执行步骤
if (1 == step.getSteptype()) result = runWebStep(params, variable, wd, taskid, testcase.getSign(), step.getStepnum(), caselog);
else result = runStep(params, variable, taskid, testcase.getSign(), step, caselog);
if (1 == step.getSteptype()){
result = runWebStep(params, variable, wd, taskid, testcase.getSign(), step.getStepnum(), caselog);
}else{
result = runStep(params, variable, taskid, testcase.getSign(), step, caselog);
}
String expectedResults = params.get("ExpectedResults");
expectedResults = ChangString.changparams(expectedResults, variable, "预期结果");
// 判断结果
if (0 != judgeResult(testcase, step, params, wd, taskid, expectedResults, result, caselog)) break;
setresult = judgeResult(testcase, step, params, wd, taskid, expectedResults, result, caselog);
if (0 != setresult){
break;
}
}
variable.clear();
@ -251,11 +121,11 @@ public class WebCaseExecution extends TestCaseExecution {
}
try {
//调用接口用例
//调用另一条用例支持接口web类型用例
if (null != operation && null != operationValue && "runcase".equals(operation)) {
String[] temp = operationValue.split(",", -1);
String ex = TestCaseExecution.oneCaseExecuteForWebCase(temp[0], taskid, caselog, wd);
// String ex = TestCaseExecution.oneCaseExecuteForWebDriver(temp[0], taskid, caselog);
// String ex = TestCaseExecution.oneCaseExecuteForWebDriver(temp[0], taskid, caselog);
if (!ex.contains("CallCase调用出错") && !ex.contains("解析出错啦!") && !ex.contains("失败")) {
return ex;
} else {
@ -356,8 +226,7 @@ public class WebCaseExecution extends TestCaseExecution {
LogUtil.APP.error("调用方法过程出错,方法名:" + functionname + ",请重新检查脚本方法名称以及参数!");
return "步骤执行失败:接口调用出错!";
}
if (result.contains("步骤执行失败:")) caselog.caseLogDetail(taskid, casenum, result, "error", String.valueOf(step.getStepnum()), "");
else caselog.caseLogDetail(taskid, casenum, result, "info", String.valueOf(step.getStepnum()), "");
return result;
}
@ -401,12 +270,6 @@ public class WebCaseExecution extends TestCaseExecution {
public static int judgeResult(ProjectCase testcase, ProjectCasesteps step, Map<String, String> params, WebDriver driver, String taskid, String expect, String result, LogOperation caselog) throws InterruptedException {
setresult = 0;
if (null != result && !result.contains("步骤执行失败:")) {
// 获取步骤间等待时间
int waitsec = Integer.parseInt(params.get("StepWait"));
if (waitsec > 0) {
luckyclient.publicclass.LogUtil.APP.info("操作休眠【" + waitsec + "】秒");
Thread.sleep(waitsec * 1000);
}
// 有预期结果
if (null != expect && !expect.isEmpty()) {
luckyclient.publicclass.LogUtil.APP.info("期望结果为【" + expect + "");
@ -496,6 +359,13 @@ public class WebCaseExecution extends TestCaseExecution {
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getSign() + "" + step.getStepnum() + "步,执行结果:" + result);
caselog.caseLogDetail(taskid, testcase.getSign(), "当前步骤在执行过程中解析|定位元素|操作对象失败!" + result, "error", String.valueOf(step.getStepnum()), imagname);
}
// 获取步骤间等待时间
int waitsec = Integer.parseInt(params.get("StepWait"));
if (waitsec > 0) {
luckyclient.publicclass.LogUtil.APP.info("操作休眠【" + waitsec + "】秒");
Thread.sleep(waitsec * 1000);
}
return setresult;
}