@Test(enabled = false, groups = "p2") // 目前测试环境没有该功能代码 public void category_and_query() { long d = System.currentTimeMillis(); DBAction dba = new DBAction(); dba.setFuncCondition("module = 'q_and_c'"); dba.setFvpCondition("fvp_id = 29"); List<FuncCatePath> categorys = dba.getFuncCatePath(); List<FuncVP> fvps = dba.getFVP(); String subject = "【搜索后台自动化测试】基础功能回归测试结果"; StringBuffer content = new StringBuffer(); content.append( "<html><head><meta http-equiv=Content-Type content='text/html; charset=utf-8'></head><body><table border=1 cellspacing=0 cellpadding=0><tr><th>功能模块</th><th>通过category</th><th>失败category</th><th>跳过category</th><th>总计</th><th>耗时</th></tr>"); for (FuncVP fvp : fvps) { int passed = 0, failed = 0, skiped = 0; for (FuncCatePath category : categorys) { int rt = doQuery(category, fvp); switch (rt) { case 0: passed += 1; break; case -1: failed += 1; break; case -2: skiped += 1; break; default: failed += 1; break; } } logger.fatal( String.format( " - [LOG_SUMMARY] - vp: %s, passed: %s, failed: %s, skiped: %s", fvp.getFvpname(), passed, failed, skiped)); long d2 = System.currentTimeMillis(); int d4 = (int) ((d2 - d) / 60000 + 1); logger.fatal("总耗时:" + d4 + "分钟"); String d3 = String.valueOf(d4) + "分钟"; content.append( String.format( "<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>", fvp.getFvpname(), passed, failed, skiped, passed + failed + skiped, d3)); } content.append("</table></body></html>"); Utils.sendMail(subject, content.toString(), "HTML"); }
// 分类直达黑名单 @Test(enabled = true) public void CategoryDirectBlacklist() { long d = System.currentTimeMillis(); logger.info(Long.toString(d)); DBAction dba = new DBAction(); dba.setFuncCondition("id < 100"); // 727 List<FuncQuery> list = dba.getFuncQuery(); int pass = 0, fail = 0; String subject = "【搜索后台自动化测试】基础功能回归测试结果"; StringBuffer content = new StringBuffer(); content.append( "<html><head><meta http-equiv=Content-Type content='text/html; charset=utf-8'></head><body><table border=1 cellspacing=0 cellpadding=0><tr><th>功能模块</th><th>通过query</th><th>失败query</th><th>跳过query</th><th>总计</th><th>耗时</th></tr>"); for (FuncQuery query : list) { try { if (CategoryDirectBlacklistVerifier.Verify(query)) { logger.info(" - [PASSED] - " + "CategoryDirect Blacklist for:" + query.getFquery()); pass++; } else { logger.info(" - [FAILED] - " + "CategoryDirect Blacklist for:" + query.getFquery()); fail++; } } catch (Exception e) { ByteArrayOutputStream buf = new ByteArrayOutputStream(); e.printStackTrace(new PrintWriter(buf, true)); String expMessage = buf.toString(); logger.error(" - [LOG_EXCEPTION] - " + expMessage); logger.error(" - [FAILED] - " + "CategoryDirect Blacklist for:" + query.getFquery()); e.printStackTrace(); fail++; } } long d2 = System.currentTimeMillis(); String d3 = (int) ((d2 - d) / 60000 + 1) + "分钟"; content.append( String.format( "<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>", "CategoryDirect Blacklist", pass, fail, 0, pass + fail + 0, d3)); logger.info("Result #### Passed Count:" + pass + " Failed Count:" + fail); double pr = Double.valueOf(pass) / (pass + fail) * 100; double fr = Double.valueOf(fail) / (fail + pass) * 100; logger.info( "Result #### Passed Rate:" + Math.round(pr) + "% Failed Rate:" + Math.round(fr) + "%"); content.append("</table></body></html>"); Utils.sendMail(subject, content.toString(), "HTML"); logger.info(Double.toString((d2 - d) / 1000.0)); }