/** * Analyze if testcase FAILED or PASSED base on running results of all steps. * * @throws Exception */ public void logEnd() throws Exception { String rs = new String(); int a = oi.logList.toArray().length; for (String s : oi.logList) { if (!StringUtils.containsIgnoreCase(s, oi.logRunningTC + "," + init.logTcStart) && !StringUtils.containsIgnoreCase(s, oi.logRunningTC + "," + init.logTcEnd)) { if (!StringUtils.containsIgnoreCase(s, oi.logRunningTC + "," + "true")) { rs = "FALSE"; break; } } } String tmpStepLog = ""; tmpStepLog = "," + init.currentStep + " of " + init.sumStep; if (rs == "FALSE") { oi.logList.add(oi.logRunningTC + "," + init.logFailed + tmpStepLog); } else { oi.logList.add(oi.logRunningTC + "," + init.logPassed + tmpStepLog); } System.out.println("END of THIS TC: " + oi.logList.get(oi.logList.size() - 1)); oi.logList.add(oi.logRunningTC + "," + init.logTcEnd); // checkForVerificationErrors(); and insert a FAILED line into loglist logToFile(); }
/** * Verify strings. Using for comparing displayed text. * * @param exp * @param obs * @param pro * @return [boolean] * @throws Exception */ public boolean QVerify(String exp, String obs, int pro) throws Exception { /* * pro: * 0:Expected is Equal (e.g: return TRUE if a=a); * 1:Expected is NOT equal. (e.g: return TRUE if a=a) */ try { // handle logging text START String logExp, logObs; if (exp.length() > 50) { logExp = StringUtils.mid(exp, 0, 50) + "..."; } else { logExp = StringUtils.mid(exp, 0, exp.length()); } // Cut expected string for Reporting if (exp.length() > 50) { logObs = StringUtils.mid(obs, 0, 50) + "..."; } else { logObs = StringUtils.mid(obs, 0, obs.length()); } // Cut observed string for Reporting if (StringUtils.indexOf(logObs, "\n") > 0) { logObs = StringUtils.mid(logObs, 0, StringUtils.indexOf(obs, "\n")); } ; // Again cut observed string for Reporting // handle logging text END if (StringUtils.containsIgnoreCase(obs.trim(), exp.trim()) == true) { if (pro == 0) { logStep("", "TRUE", "Expectation: " + logExp + " , " + "Observation: " + logObs); return true; } else { logStep("", "FALSE", "Expectation: " + logExp + " , " + "Observation: " + logObs); return false; } } else { if (pro == 0) { logStep("", "FALSE", "Expectation: " + logExp + " , " + "Observation: " + logObs); return false; } else { logStep("", "TRUE", "Expectation: " + logExp + " , " + "Observation: " + logObs); return true; } } } catch (Exception e) { logStep("", "FALSE", "Expectation: " + exp.trim() + " , " + "Observation: " + obs.trim()); return false; } }