Commit 83eae874 authored by 赵然's avatar 赵然

Merge branch 'master' of gitlab2.dui88.com:mabo/test-platform

parents ffdd652a 84275adb
...@@ -318,6 +318,7 @@ ...@@ -318,6 +318,7 @@
<maxRetryCount>0</maxRetryCount> <maxRetryCount>0</maxRetryCount>
<ServiceDoctor>false</ServiceDoctor> <ServiceDoctor>false</ServiceDoctor>
<Server>false</Server> <Server>false</Server>
<sendMiria>false</sendMiria>
</systemPropertyVariables> </systemPropertyVariables>
</configuration> </configuration>
......
...@@ -35,6 +35,7 @@ public class DingdingResult { ...@@ -35,6 +35,7 @@ public class DingdingResult {
transient ApplicationContext context = new AnnotationConfigApplicationContext(Config.class); transient ApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
transient Environment env=context.getBean(Environment.class); transient Environment env=context.getBean(Environment.class);
public transient static String[] name; public transient static String[] name;
transient GitlabProjectMerges gitlabProjectMerges;
String path=null; String path=null;
public DingdingResult(int total, int passCount, int skipCount, int failCount) throws UnsupportedEncodingException { public DingdingResult(int total, int passCount, int skipCount, int failCount) throws UnsupportedEncodingException {
...@@ -42,7 +43,7 @@ public class DingdingResult { ...@@ -42,7 +43,7 @@ public class DingdingResult {
logger.info("属性:"+System.getProperties()); logger.info("属性:"+System.getProperties());
Map<String,String> changeMap=null; Map<String,String> changeMap=null;
group = duibaGroup.split(","); group = duibaGroup.split(",");
changeMap = BeTested.getLatestChanges(duibaGroup.split(",")); // changeMap = BeTested.getLatestChanges(duibaGroup.split(","));
project = "duiba-service"; project = "duiba-service";
...@@ -53,11 +54,15 @@ public class DingdingResult { ...@@ -53,11 +54,15 @@ public class DingdingResult {
names.addAll(Arrays.asList(getNames)); names.addAll(Arrays.asList(getNames));
boolean sendMiria = Boolean.parseBoolean(System.getProperty("sendMiria"));
if(sendMiria){
Map<String,String> params = new HashMap<>(); Map<String,String> params = new HashMap<>();
params.put("jobName",getJob()); params.put("jobName",getJob());
changes = Postman.sendFindTestApp(params); changes = Postman.sendFindTestApp(params);
}
GitlabProjectMerges gitlabProjectMerges = GitlabUtils.getMessage("credits-group",changes); gitlabProjectMerges = GitlabUtils.getMessage("credits-group",changes);
changes = changes+" 提交者:"+gitlabProjectMerges.getAuthor().getName()+" 描述:"+gitlabProjectMerges.getDescription(); changes = changes+" 提交者:"+gitlabProjectMerges.getAuthor().getName()+" 描述:"+gitlabProjectMerges.getDescription();
...@@ -145,6 +150,7 @@ public class DingdingResult { ...@@ -145,6 +150,7 @@ public class DingdingResult {
// System.out.println(e); // System.out.println(e);
// } // }
names.add(gitlabProjectMerges.getAuthor().getUsername());
}else { }else {
names.clear(); names.clear();
......
...@@ -72,10 +72,10 @@ public class MysqlConnPool { ...@@ -72,10 +72,10 @@ public class MysqlConnPool {
map = new HashMap<String, Object>(); map = new HashMap<String, Object>();
int index = 1; int index = 1;
log.info("bds!=null"); // log.info("bds!=null");
PreparedStatement pstmt = conn.prepareStatement(sql); PreparedStatement pstmt = conn.prepareStatement(sql);
log.info("conn!=null"); // log.info("conn!=null");
log.info(conn.toString()); // log.info(conn.toString());
if(params != null && !(params.length==0)){ if(params != null && !(params.length==0)){
for(int i=0; i<params.length; i++){ for(int i=0; i<params.length; i++){
pstmt.setObject(index++, params[i]); pstmt.setObject(index++, params[i]);
......
...@@ -14,6 +14,7 @@ public class RetryToRunCase implements IRetryAnalyzer { ...@@ -14,6 +14,7 @@ public class RetryToRunCase implements IRetryAnalyzer {
retryCount++; retryCount++;
return true; return true;
} }
retryCount = 0;
return false; return false;
} }
......
...@@ -2,10 +2,7 @@ package base; ...@@ -2,10 +2,7 @@ package base;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.*;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
...@@ -21,25 +18,70 @@ public class TestListener implements ITestListener { ...@@ -21,25 +18,70 @@ public class TestListener implements ITestListener {
String run = System.getProperty("run"); String run = System.getProperty("run");
ApplicationContext context = new AnnotationConfigApplicationContext(Config.class); ApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
Environment env=context.getBean(Environment.class); Environment env=context.getBean(Environment.class);
boolean sendMiria = Boolean.parseBoolean(System.getProperty("sendMiria"));
public TestListener() throws UnsupportedEncodingException { public TestListener() throws UnsupportedEncodingException {
} }
public void onFinish(ITestContext context) { public void onFinish(ITestContext context) {
Iterator<ITestResult> listOfFailedTests = context.getFailedTests().getAllResults().iterator(); // Iterator<ITestResult> listOfFailedTests = context.getFailedTests().getAllResults().iterator();
while (listOfFailedTests.hasNext()) { // while (listOfFailedTests.hasNext()) {
ITestResult failedTest = listOfFailedTests.next(); // ITestResult failedTest = listOfFailedTests.next();
ITestNGMethod method = failedTest.getMethod(); // ITestNGMethod method = failedTest.getMethod();
if (context.getFailedTests().getResults(method).size() > 1) { // if (context.getFailedTests().getResults(method).size() > 1) {
listOfFailedTests.remove(); // listOfFailedTests.remove();
logger.info("context.getFailedTests().getResults(method).size() > 1"); // logger.info("context.getFailedTests().getResults(method).size() > 1");
// } else {
// if (context.getPassedTests().getResults(method).size() > 0) {
// listOfFailedTests.remove();
// logger.info("context.getPassedTests().getResults(method).size() > 0");
// }
// }
// }
// super.onFinish(testContext);
// List of test results which we will delete later
ArrayList<ITestResult> testsToBeRemoved = new ArrayList<ITestResult>();
// collect all id's from passed test
Set<Integer> passedTestIds = new HashSet<Integer>();
for (ITestResult passedTest : context.getPassedTests().getAllResults()) {
logger.info("PassedTests = " + passedTest.getName());
passedTestIds.add(getId(passedTest));
}
Set<Integer> failedTestIds = new HashSet<Integer>();
for (ITestResult failedTest : context.getFailedTests().getAllResults()) {
logger.info("failedTest = " + failedTest.getName());
// id = class + method + dataprovider
int failedTestId = getId(failedTest);
// if we saw this test as a failed test before we mark as to be
// deleted
// or delete this failed test if there is at least one passed
// version
if (failedTestIds.contains(failedTestId) || passedTestIds.contains(failedTestId)) {
testsToBeRemoved.add(failedTest);
} else { } else {
if (context.getPassedTests().getResults(method).size() > 0) { failedTestIds.add(failedTestId);
listOfFailedTests.remove();
logger.info("context.getPassedTests().getResults(method).size() > 0");
} }
} }
// finally delete all tests that are marked
for (Iterator<ITestResult> iterator = context.getFailedTests().getAllResults().iterator(); iterator
.hasNext();) {
ITestResult testResult = iterator.next();
if (testsToBeRemoved.contains(testResult)) {
logger.info("Remove repeat Fail Test: " + testResult.getName());
iterator.remove();
}
} }
} }
private int getId(ITestResult result) {
int id = result.getTestClass().getName().hashCode();
id = id + result.getMethod().getMethodName().hashCode();
id = id + (result.getParameters() != null ? Arrays.hashCode(result.getParameters()) : 0);
return id;
}
// Following are all the method stubs that you do not have to implement // Following are all the method stubs that you do not have to implement
...@@ -88,6 +130,7 @@ public class TestListener implements ITestListener { ...@@ -88,6 +130,7 @@ public class TestListener implements ITestListener {
} }
//运行开始,触发互斥功能,用于定时任务 //运行开始,触发互斥功能,用于定时任务
if(sendMiria){
Map<String,String> mapJob = new HashMap<>(); Map<String,String> mapJob = new HashMap<>();
try { try {
...@@ -98,6 +141,7 @@ public class TestListener implements ITestListener { ...@@ -98,6 +141,7 @@ public class TestListener implements ITestListener {
Postman.sendTesting(mapJob); Postman.sendTesting(mapJob);
} }
}
public void serviceDoctor(){ public void serviceDoctor(){
logger.info("duiba-server开始检测"); logger.info("duiba-server开始检测");
ServiceDoctor serviceDoctor=new ServiceDoctor("duiba-server.properties"); ServiceDoctor serviceDoctor=new ServiceDoctor("duiba-server.properties");
......
...@@ -64,6 +64,8 @@ public class TestReport implements IReporter{ ...@@ -64,6 +64,8 @@ public class TestReport implements IReporter{
boolean noticeDD=Boolean.parseBoolean(System.getProperty("noticeDD")); boolean noticeDD=Boolean.parseBoolean(System.getProperty("noticeDD"));
boolean noticePerson=Boolean.parseBoolean(System.getProperty("noticePerson")); boolean noticePerson=Boolean.parseBoolean(System.getProperty("noticePerson"));
boolean sendPlatform=Boolean.parseBoolean(System.getProperty("sendPlatform")); boolean sendPlatform=Boolean.parseBoolean(System.getProperty("sendPlatform"));
boolean sendMiria = Boolean.parseBoolean(System.getProperty("sendMiria"));
Gson gson=new GsonBuilder().create(); Gson gson=new GsonBuilder().create();
...@@ -78,6 +80,7 @@ public class TestReport implements IReporter{ ...@@ -78,6 +80,7 @@ public class TestReport implements IReporter{
System.out.println("测试结果通知信息:"+gson.toJson(map)); System.out.println("测试结果通知信息:"+gson.toJson(map));
//触发回调结束服务构建互斥 //触发回调结束服务构建互斥
if(sendMiria){
Map<String,String> mapJob = new HashMap<>(); Map<String,String> mapJob = new HashMap<>();
try { try {
mapJob.put("jobName",ddResult.getJob()); mapJob.put("jobName",ddResult.getJob());
...@@ -85,6 +88,7 @@ public class TestReport implements IReporter{ ...@@ -85,6 +88,7 @@ public class TestReport implements IReporter{
e.printStackTrace(); e.printStackTrace();
} }
Postman.sendFinish(mapJob); Postman.sendFinish(mapJob);
}
//发送运行结果到自动化数据收集平台 //发送运行结果到自动化数据收集平台
if(sendPlatform) if(sendPlatform)
Postman.sendTestPlatform(map); Postman.sendTestPlatform(map);
......
package ui.cases; package ui.cases;
import base.DuibaBaseUi; import base.DuibaBaseUi;
import base.DuibaBases;
import base.DuibaLog; import base.DuibaLog;
import com.codeborne.selenide.WebDriverRunner; import com.codeborne.selenide.WebDriverRunner;
import com.codeborne.selenide.testng.ScreenShooter; import com.codeborne.selenide.testng.ScreenShooter;
...@@ -13,6 +14,7 @@ import org.testng.Assert; ...@@ -13,6 +14,7 @@ import org.testng.Assert;
import org.testng.ITestResult; import org.testng.ITestResult;
import org.testng.Reporter; import org.testng.Reporter;
import org.testng.annotations.AfterMethod; import org.testng.annotations.AfterMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners; import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import ui.common.ProxyFactory; import ui.common.ProxyFactory;
...@@ -35,72 +37,20 @@ import static com.codeborne.selenide.Selenide.open; ...@@ -35,72 +37,20 @@ import static com.codeborne.selenide.Selenide.open;
* Created by mabo on 2018/10/18 * Created by mabo on 2018/10/18
*/ */
//@Listeners({ ScreenShooter.class}) //@Listeners({ ScreenShooter.class})
public class test extends DuibaBaseUi { public class test extends DuibaBases {
// StatusCheckor checkor=new StatusCheckor(); @Test(dataProvider = "dp")
// WebDriver driver= WebDriverFactory.createWebDriver(WebDriverType.CHRMOE, ProxyFactory.createProxy()); // @Test(retryAnalyzer = MyRetryAnalyzer.class,dataProvider = "dp")
public void f(Integer n, String s) {
@Test System.out.println("ssssss:" + s);
Assert.assertFalse(true);
public void 中文() throws IOException {
ScreenShooter.captureSuccessfulTests = true;
//StatusCheckor checkor=new StatusCheckor();
// ProxyFactory.addCheckor(checkor);
// WebDriverRunner.setWebDriver(driver);
open("https://www.baidu.com");
Reporter.log("----------------------");
screenshot();
Reporter.log("----------------------");
$(By.id("kw")).setValue("selenium");
Assert.assertEquals(1,2);
// SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); //转换时间格式
// String time = dateFormat.format(Calendar.getInstance().getTime()); //获取当前时间
} }
@Test
public void test1() throws SQLException {
Map<String,Object> map = jdbc.findSimpleResult("select * from act_com_conf.tb_bet_group_relation where bet_id = 1232");
@DataProvider
public Object[][] dp() {
return new Object[][] { new Object[] { 1, "a" }, new Object[] { 2, "b" },new Object[] { 3, "c" },new Object[] { 4, "d" } };
} }
@Test
public void test2(){
Reporter.log("rererfddfdfdfdfdfdf");
Reporter.log("rererfddfdfdfdfdfdf");
Reporter.log("rererfddfdfdfdfdfdf");
Reporter.log("rererfddfdfdfdfdfdf");
Reporter.log("rererfddfdfdfdfdfdf");
Reporter.log("rererfddfdfdfdfdfdf");
Assert.assertEquals(1,2);
}
// @AfterMethod(alwaysRun = true)
// public void afterMethod(ITestResult result) throws Exception {
// if (!result.isSuccess())
// catchExceptions(result);
// }
// public void catchExceptions(ITestResult result) throws IOException {
// File file = new File("C:/image");
// Reporter.setCurrentTestResult(result);
// Reporter.log(file.getAbsolutePath());
// String time = String.valueOf(System.currentTimeMillis());
// Reporter.log("<img src='" + "http://172.16.80.106" + "/" + result.getName() +"_"+time+ ".jpg' hight='600' width='600'/>");
// File srcFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); //执行屏幕截取
// FileUtils.copyFile(srcFile, new File(file.getAbsolutePath() + "/" + result.getName() +"_"+time+ ".jpg"));
//
// }
//
// public static void main(String[] args) {
// System.out.println(System.currentTimeMillis());
// System.out.println(Calendar.getInstance().getTimeInMillis());
// System.out.println(new Date().getTime());
// }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment