diff --git a/Engine/src/main/java/com/ing/engine/constants/AppResourcePath.java b/Engine/src/main/java/com/ing/engine/constants/AppResourcePath.java index 8ab7b76..2bd02b2 100644 --- a/Engine/src/main/java/com/ing/engine/constants/AppResourcePath.java +++ b/Engine/src/main/java/com/ing/engine/constants/AppResourcePath.java @@ -1,4 +1,3 @@ - package com.ing.engine.constants; import com.ing.engine.core.RunManager; @@ -32,6 +31,7 @@ public class AppResourcePath { private final static String DETAILED_HTML = "detailed.html"; private final static String PERF_HTML = "perfReport.html"; private final static String REPORT_HISTORY_HTML = "ReportHistory.html"; + private final static String VIDEO_HTML = "videoReport.html"; private final static String REPORT_DATA = "data.js"; private final static String REPORT_HISTORY_DATA = "reportHistory.js"; @@ -53,7 +53,7 @@ public class AppResourcePath { private static String date; private static String time; - public static String getAppRoot(){ + public static String getAppRoot() { try { // return System.getProperty("user.dir"); return new File(System.getProperty("user.dir")).getCanonicalPath(); @@ -62,7 +62,6 @@ public static String getAppRoot(){ } return null; } - public static String getExternalCommandsConfig() { return getLibPath() + File.separator + EXTERNAL_COMMANDS_CONFIG; @@ -123,7 +122,7 @@ public static String getEncFile() { public static String getSummaryHTMLPath() { return getReportTemplatePath() + File.separator + SUMMARY_HTML; } - + public static String getDetailedHTMLPath() { return getReportTemplatePath() + File.separator + DETAILED_HTML; } @@ -161,17 +160,17 @@ public static String getCurrentResultsPath() { public static String getCurrentResultsLocation() { return getResultsPath() + getResultPath(); } - + public static String getCurrentTestCaseLogsLocation() { - return getCurrentResultsLocation() + File.separator + date + " " + time+ File.separator + "logs"; + return getCurrentResultsLocation() + File.separator + date + " " + time + File.separator + "logs"; } - + public static String getCurrentTestCaseAccessibilityLocation() { - return getCurrentResultsLocation() + File.separator + date + " " + time+ File.separator + "aXe"; + return getCurrentResultsLocation() + File.separator + date + " " + time + File.separator + "aXe"; } - + public static String getCurrentTestCaseVideosLocation() { - return getCurrentResultsLocation() + File.separator + date + " " + time+ File.separator + "videos"; + return getCurrentResultsLocation() + File.separator + date + " " + time + File.separator + "videos"; } public static String getLatestResultsLocation() { @@ -185,15 +184,15 @@ public static String getCurrentDetailedHTMLPath() { public static String getCurrentExtentReportPath() { return getCurrentResultsPath() + File.separator + EXTENT_HTML; } - + public static String getCurrentAzureReportPath() { return getCurrentResultsPath() + File.separator + AZURE_XML; } - + public static String getCurrentExtentPDFReportPath() { return getCurrentResultsPath() + File.separator + EXTENT_PDF; } - + public static String getCurrentSummaryHTMLPath() { return getCurrentResultsPath() + File.separator + SUMMARY_HTML; } @@ -283,4 +282,12 @@ public static String getPerfReportHTMLPath() { public static String getCurrentPerfReportHTMLPath() { return getCurrentResultsPath() + File.separator + PERF_HTML; } + + public static String getVideoReportHTMLPath() { + return getReportTemplatePath() + File.separator + VIDEO_HTML; + } + + public static String getCurrentVideoReportHTMLPath() { + return getCurrentResultsPath() + File.separator + VIDEO_HTML; + } } diff --git a/Engine/src/main/java/com/ing/engine/reporting/impl/excel/ExcelSummaryHandler.java b/Engine/src/main/java/com/ing/engine/reporting/impl/excel/ExcelSummaryHandler.java index 9d05f18..345bb55 100644 --- a/Engine/src/main/java/com/ing/engine/reporting/impl/excel/ExcelSummaryHandler.java +++ b/Engine/src/main/java/com/ing/engine/reporting/impl/excel/ExcelSummaryHandler.java @@ -1,4 +1,3 @@ - package com.ing.engine.reporting.impl.excel; import com.ing.engine.constants.AppResourcePath; @@ -53,418 +52,418 @@ @SuppressWarnings("rawtypes") public class ExcelSummaryHandler extends SummaryHandler implements PrimaryHandler { - private static final Logger LOGGER = Logger.getLogger(ExcelSummaryHandler.class.getName()); - - static ArrayList objectsarray = new ArrayList(); - - JSONObject testSetData = new JSONObject(); - JSONArray executions = new JSONArray(); - public boolean RunComplete = false; - int FailedTestCases = 0; - int PassedTestCases = 0; - int noTests = 0; - DateTimeUtils RunTime; - public PerformanceReport perf; - - public ExcelSummaryHandler(SummaryReport report) { - super(report); - - } - - @Override - public void addHar(Har h, TestCaseReport report, String pageName) { - if (perf != null) { - perf.addHar(h, report, pageName); - } - } - - /** - * initialize the report data file. - * - * @param runTime - * @param size - */ - @SuppressWarnings("unchecked") - @Override - public synchronized void createReport(String runTime, int size) { - - try { - ReportUtils.loadDefaultTheme(testSetData); - RunTime = new DateTimeUtils(); - new File(FilePath.getCurrentResultsPath()).mkdirs(); - testSetData.put(RDS.TestSet.PROJECT_NAME, RunManager.getGlobalSettings().getProjectName()); - testSetData.put(RDS.TestSet.RELEASE_NAME, RunManager.getGlobalSettings().getRelease()); - testSetData.put(RDS.TestSet.TESTSET_NAME, RunManager.getGlobalSettings().getTestSet()); - testSetData.put(RDS.TestSet.ITERATION_MODE, - Control.exe.getExecSettings().getRunSettings().getIterationMode()); - testSetData.put(RDS.TestSet.RUN_CONFIG, Control.exe.getExecSettings().getRunSettings().getExecutionMode()); - testSetData.put(RDS.TestSet.MAX_THREADS, Control.exe.getExecSettings().getRunSettings().getThreadCount()); - testSetData.put(RDS.TestSet.BDD_STYLE, Control.exe.getExecSettings().getRunSettings().isBddReportEnabled()); - testSetData.put(RDS.TestSet.PERF_REPORT, - Control.exe.getExecSettings().getRunSettings().isPerformanceLogEnabled()); - testSetData.put(RDS.TestSet.START_TIME, runTime); - testSetData.put(RDS.TestSet.TEST_RUN, RunManager.getGlobalSettings().isTestRun()); - testSetData.put(RDS.TestSet.NO_OF_TESTS, size); - - } catch (Exception ex) { - LOGGER.log(Level.SEVERE, ex.getMessage(), ex); - } - } - - /** - * update the result of each test case result - * - * @param runContext - * @param report - * @param state - * @param executionTime - */ - @SuppressWarnings("unchecked") - @Override - public synchronized void updateTestCaseResults(RunContext runContext, TestCaseReport report, Status state, - String executionTime) { - - executions.add(report.getData()); - String status; - if (state.equals(Status.PASS)) { - status = "Passed"; - PassedTestCases++; - } else { - FailedTestCases++; - status = "Failed"; - } - ReportUtils.updateStatus(status, runContext); - - if (perf != null) { - perf.updateTestCase(report.Scenario, report.TestCase); - } - updateResults(); - } - - /** - * update the test set details to the json data file and write the data file - */ - @SuppressWarnings("unchecked") - public synchronized void updateResults() { - String exeTime = RunTime.timeRun(); - String endTime = DateTimeUtils.DateTimeNow(); - - try { - if (RunComplete) { - testSetData.put(RDS.TestSet.EXECUTIONS, executions); - testSetData.put(RDS.TestSet.END_TIME, endTime); - testSetData.put(RDS.TestSet.EXE_TIME, exeTime); - - testSetData.put(RDS.TestSet.NO_OF_FAIL_TESTS, String.valueOf(FailedTestCases)); - testSetData.put(RDS.TestSet.NO_OF_PASS_TESTS, String.valueOf(PassedTestCases)); - RDS.writeToDataJS(FilePath.getCurrentReportDataPath(), testSetData); - } else { - - } - } catch (Exception ex) { - LOGGER.log(Level.SEVERE, ex.getMessage(), ex); - } - - } - - /** - * finalize the summary report creation - */ - @Override - public synchronized void finalizeReport() { - RunComplete = true; - updateResults(); - - try { - - createExcel(); - - } catch (Exception ex) { - LOGGER.log(Level.SEVERE, ex.getMessage(), ex); - } - - } - - private void createExcel() throws Exception { - - if (!RunManager.getGlobalSettings().isTestRun()) { - - String current_release = RunManager.getGlobalSettings().getRelease(); - - String current_testset = RunManager.getGlobalSettings().getTestSet(); - - String case_check = Control.getCurrentProject().getProjectSettings() - .getExecSettings(current_release, current_testset).getRunSettings().getProperty("excelReport"); - - if (case_check != null && case_check.equalsIgnoreCase("true")) { + private static final Logger LOGGER = Logger.getLogger(ExcelSummaryHandler.class.getName()); + + static ArrayList objectsarray = new ArrayList(); + + JSONObject testSetData = new JSONObject(); + JSONArray executions = new JSONArray(); + public boolean RunComplete = false; + int FailedTestCases = 0; + int PassedTestCases = 0; + int noTests = 0; + DateTimeUtils RunTime; + public PerformanceReport perf; + + public ExcelSummaryHandler(SummaryReport report) { + super(report); + + } + + @Override + public void addHar(Har h, TestCaseReport report, String pageName) { + if (perf != null) { + perf.addHar(h, report, pageName); + } + } + + /** + * initialize the report data file. + * + * @param runTime + * @param size + */ + @SuppressWarnings("unchecked") + @Override + public synchronized void createReport(String runTime, int size) { + + try { + ReportUtils.loadDefaultTheme(testSetData); + RunTime = new DateTimeUtils(); + new File(FilePath.getCurrentResultsPath()).mkdirs(); + testSetData.put(RDS.TestSet.PROJECT_NAME, RunManager.getGlobalSettings().getProjectName()); + testSetData.put(RDS.TestSet.RELEASE_NAME, RunManager.getGlobalSettings().getRelease()); + testSetData.put(RDS.TestSet.TESTSET_NAME, RunManager.getGlobalSettings().getTestSet()); + testSetData.put(RDS.TestSet.ITERATION_MODE, + Control.exe.getExecSettings().getRunSettings().getIterationMode()); + testSetData.put(RDS.TestSet.RUN_CONFIG, Control.exe.getExecSettings().getRunSettings().getExecutionMode()); + testSetData.put(RDS.TestSet.MAX_THREADS, Control.exe.getExecSettings().getRunSettings().getThreadCount()); + testSetData.put(RDS.TestSet.BDD_STYLE, Control.exe.getExecSettings().getRunSettings().isBddReportEnabled()); + testSetData.put(RDS.TestSet.PERF_REPORT, + Control.exe.getExecSettings().getRunSettings().isPerformanceLogEnabled()); + testSetData.put(RDS.TestSet.START_TIME, runTime); + testSetData.put(RDS.TestSet.TEST_RUN, RunManager.getGlobalSettings().isTestRun()); + testSetData.put(RDS.TestSet.NO_OF_TESTS, size); + testSetData.put(RDS.TestSet.VIDEO_REPORT, Control.exe.getExecSettings().getRunSettings().isVideoEnabled()); + + } catch (Exception ex) { + LOGGER.log(Level.SEVERE, ex.getMessage(), ex); + } + } + + /** + * update the result of each test case result + * + * @param runContext + * @param report + * @param state + * @param executionTime + */ + @SuppressWarnings("unchecked") + @Override + public synchronized void updateTestCaseResults(RunContext runContext, TestCaseReport report, Status state, + String executionTime) { + + executions.add(report.getData()); + String status; + if (state.equals(Status.PASS)) { + status = "Passed"; + PassedTestCases++; + } else { + FailedTestCases++; + status = "Failed"; + } + ReportUtils.updateStatus(status, runContext); + + if (perf != null) { + perf.updateTestCase(report.Scenario, report.TestCase); + } + updateResults(); + } + + /** + * update the test set details to the json data file and write the data file + */ + @SuppressWarnings("unchecked") + public synchronized void updateResults() { + String exeTime = RunTime.timeRun(); + String endTime = DateTimeUtils.DateTimeNow(); + + try { + if (RunComplete) { + testSetData.put(RDS.TestSet.EXECUTIONS, executions); + testSetData.put(RDS.TestSet.END_TIME, endTime); + testSetData.put(RDS.TestSet.EXE_TIME, exeTime); + + testSetData.put(RDS.TestSet.NO_OF_FAIL_TESTS, String.valueOf(FailedTestCases)); + testSetData.put(RDS.TestSet.NO_OF_PASS_TESTS, String.valueOf(PassedTestCases)); + RDS.writeToDataJS(FilePath.getCurrentReportDataPath(), testSetData); + } else { + + } + } catch (Exception ex) { + LOGGER.log(Level.SEVERE, ex.getMessage(), ex); + } + + } + + /** + * finalize the summary report creation + */ + @Override + public synchronized void finalizeReport() { + RunComplete = true; + updateResults(); + + try { + + createExcel(); + + } catch (Exception ex) { + LOGGER.log(Level.SEVERE, ex.getMessage(), ex); + } + + } + + private void createExcel() throws Exception { + + if (!RunManager.getGlobalSettings().isTestRun()) { + + String current_release = RunManager.getGlobalSettings().getRelease(); + + String current_testset = RunManager.getGlobalSettings().getTestSet(); + + String case_check = Control.getCurrentProject().getProjectSettings() + .getExecSettings(current_release, current_testset).getRunSettings().getProperty("excelReport"); - String OS = null; - OS = System.getProperty("os.name"); + if (case_check != null && case_check.equalsIgnoreCase("true")) { - String datajspath = FilePath.getLatestResultsLocation() + File.separator + "data.js"; + String OS = null; + OS = System.getProperty("os.name"); - try { + String datajspath = FilePath.getLatestResultsLocation() + File.separator + "data.js"; - File file = new File(datajspath); - String jstr = FileUtils.readFileToString(file).replaceFirst("var DATA=", ""); - String jsonString = jstr.substring(0, jstr.length() - 1); + try { - String template = AppResourcePath.getConfigurationPath() - + "\\ReportTemplate\\excel\\excelreporttemplate.xlsx"; + File file = new File(datajspath); + String jstr = FileUtils.readFileToString(file).replaceFirst("var DATA=", ""); + String jsonString = jstr.substring(0, jstr.length() - 1); - String excelreport = FilePath.getLatestResultsLocation() + File.separator - + "SummaryExcelReport.xlsx"; - String excelreport_tm = FilePath.getCurrentResultsPath() + File.separator - + "SummaryExcelReport.xlsx"; + String template = AppResourcePath.getConfigurationPath() + + "\\ReportTemplate\\excel\\excelreporttemplate.xlsx"; - File file1 = new File(template); - File file2 = new File(excelreport); + String excelreport = FilePath.getLatestResultsLocation() + File.separator + + "SummaryExcelReport.xlsx"; + String excelreport_tm = FilePath.getCurrentResultsPath() + File.separator + + "SummaryExcelReport.xlsx"; - if (!file2.exists()) { - FileUtils.copyFile(file1, file2); - } + File file1 = new File(template); + File file2 = new File(excelreport); - FileInputStream excelFile = new FileInputStream(new File(excelreport)); - XSSFWorkbook workbook = new XSSFWorkbook(excelFile); + if (!file2.exists()) { + FileUtils.copyFile(file1, file2); + } - ArrayList> listOLists = new ArrayList>(); + FileInputStream excelFile = new FileInputStream(new File(excelreport)); + XSSFWorkbook workbook = new XSSFWorkbook(excelFile); - AtomicInteger sheetnumber = new AtomicInteger(1); + ArrayList> listOLists = new ArrayList>(); - for (int i = 0; i < executions.size(); i++) { - XSSFFont font = workbook.createFont(); - font.setBold(true); - XSSFCellStyle style = workbook.createCellStyle(); - style.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex()); - style.setFillPattern(FillPatternType.SOLID_FOREGROUND); - style.setFont(font); + AtomicInteger sheetnumber = new AtomicInteger(1); - ArrayList singleList = new ArrayList(); + for (int i = 0; i < executions.size(); i++) { + XSSFFont font = workbook.createFont(); + font.setBold(true); + XSSFCellStyle style = workbook.createCellStyle(); + style.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex()); + style.setFillPattern(FillPatternType.SOLID_FOREGROUND); + style.setFont(font); - JSONObject eachexecution = (JSONObject) executions.get(i); + ArrayList singleList = new ArrayList(); - //System.out.println("exec details" + eachexecution.toString()); - String sheetname = sheetnumber.getAndIncrement() + "_" + eachexecution.get("testcaseName"); + JSONObject eachexecution = (JSONObject) executions.get(i); - XSSFSheet sheet = workbook.createSheet(sheetname); - // TITLE FOR EVERY SHEET - XSSFRow title = sheet.createRow(0); + //System.out.println("exec details" + eachexecution.toString()); + String sheetname = sheetnumber.getAndIncrement() + "_" + eachexecution.get("testcaseName"); - XSSFCell cell = title.createCell(0); + XSSFSheet sheet = workbook.createSheet(sheetname); + // TITLE FOR EVERY SHEET + XSSFRow title = sheet.createRow(0); - cell.setCellValue(eachexecution.get("scenarioName") + "_" + eachexecution.get("iterationType") - + "_" + eachexecution.get("testcaseName") + "_" + eachexecution.get("browser")); + XSSFCell cell = title.createCell(0); - XSSFCellStyle styletitile = workbook.createCellStyle(); - styletitile.setFont(font); - cell.setCellStyle(styletitile); + cell.setCellValue(eachexecution.get("scenarioName") + "_" + eachexecution.get("iterationType") + + "_" + eachexecution.get("testcaseName") + "_" + eachexecution.get("browser")); - sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 14)); - CellUtil.setAlignment(cell, HorizontalAlignment.CENTER); + XSSFCellStyle styletitile = workbook.createCellStyle(); + styletitile.setFont(font); + cell.setCellStyle(styletitile); - XSSFRow row_header = sheet.createRow(1); + sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 14)); + CellUtil.setAlignment(cell, HorizontalAlignment.CENTER); - row_header.createCell(1).setCellValue("Step No"); - row_header.createCell(2).setCellValue("Step Name"); - row_header.createCell(3).setCellValue("Action"); - row_header.createCell(4).setCellValue("Description"); - row_header.createCell(5).setCellValue("Status"); - row_header.createCell(6).setCellValue("Time Stamp"); + XSSFRow row_header = sheet.createRow(1); - row_header.getCell(1).setCellStyle(style); - row_header.getCell(2).setCellStyle(style); - row_header.getCell(3).setCellStyle(style); - row_header.getCell(4).setCellStyle(style); - row_header.getCell(5).setCellStyle(style); - row_header.getCell(6).setCellStyle(style); + row_header.createCell(1).setCellValue("Step No"); + row_header.createCell(2).setCellValue("Step Name"); + row_header.createCell(3).setCellValue("Action"); + row_header.createCell(4).setCellValue("Description"); + row_header.createCell(5).setCellValue("Status"); + row_header.createCell(6).setCellValue("Time Stamp"); - AtomicInteger atomicInteger = new AtomicInteger(2); + row_header.getCell(1).setCellStyle(style); + row_header.getCell(2).setCellStyle(style); + row_header.getCell(3).setCellStyle(style); + row_header.getCell(4).setCellStyle(style); + row_header.getCell(5).setCellStyle(style); + row_header.getCell(6).setCellStyle(style); - JSONArray steparray = (JSONArray) eachexecution.get("STEPS"); + AtomicInteger atomicInteger = new AtomicInteger(2); - JSONObject stepsobject = (JSONObject) steparray.get(0); - JSONArray steps = (JSONArray) stepsobject.get("data"); + JSONArray steparray = (JSONArray) eachexecution.get("STEPS"); - for (int j = 0; j < steps.size(); j++) { - JSONObject step = (JSONObject) steps.get(j); - Object detail = step.get("data"); - parsearray(detail); + JSONObject stepsobject = (JSONObject) steparray.get(0); + JSONArray steps = (JSONArray) stepsobject.get("data"); - } + for (int j = 0; j < steps.size(); j++) { + JSONObject step = (JSONObject) steps.get(j); + Object detail = step.get("data"); + parsearray(detail); - for (int j = 0; j < objectsarray.size(); j++) { + } - int index = atomicInteger.getAndIncrement(); - Object data = null; + for (int j = 0; j < objectsarray.size(); j++) { - XSSFRow roww1 = sheet.createRow(index); + int index = atomicInteger.getAndIncrement(); + Object data = null; - roww1.createCell(1).setCellValue(Integer.toString((int) objectsarray.get(j).get("stepno"))); - roww1.createCell(2).setCellValue((String) objectsarray.get(j).get("stepName")); - roww1.createCell(3).setCellValue((String) objectsarray.get(j).get("action")); - roww1.createCell(4).setCellValue((String) objectsarray.get(j).get("description")); - roww1.createCell(5).setCellValue((String) objectsarray.get(j).get("status")); - roww1.createCell(6).setCellValue((String) objectsarray.get(j).get("tStamp")); - - } + XSSFRow roww1 = sheet.createRow(index); - clearObjectArray(); - - for (int j = 0; j < objectsarray.size(); j++) { - //System.out.println("step number" + objectsarray.get(j).get("stepno")); - //System.out.println("step name " + objectsarray.get(j).get("tStamp")); - //System.out.println("number" + j); - } - - // ----------------------- - - singleList.add((String) eachexecution.get("scenarioName")); - singleList.add((String) eachexecution.get("testcaseName")); - singleList.add((String) eachexecution.get("browser")); - singleList.add((String) eachexecution.get("exeTime")); - singleList.add((String) eachexecution.get("status")); - singleList.add((String) eachexecution.get("platform")); - singleList.add((String) eachexecution.get("iterationType")); - singleList.add((String) eachexecution.get("bversion")); - listOLists.add(singleList); - - } - - XSSFSheet sheet = workbook.getSheetAt(0); - - XSSFRow header = sheet.getRow(0); - XSSFCell cellvalue = header.getCell(0); - if (cellvalue.getStringCellValue().equalsIgnoreCase("ReleaseName-Testsetname")) { - cellvalue.setCellValue(RunManager.getGlobalSettings().getRelease() + " - " - + RunManager.getGlobalSettings().getTestSet()); - } - - Iterator> iterator = listOLists.iterator(); - int row = 2; - while (iterator.hasNext()) { - ArrayList singleList = iterator.next(); - Iterator childiter = singleList.iterator(); - int i = 1; - XSSFRow roww = sheet.createRow(row); - while (childiter.hasNext()) { - String s = childiter.next(); - - roww.createCell(i).setCellValue(s); - i++; - } - row++; - - } - - // Write content to excel files - FileOutputStream outputStream = new FileOutputStream(excelreport); - workbook.write(outputStream); - - Iterator sheetIterator = workbook.sheetIterator(); - DataFormatter dataFormatter = new DataFormatter(); - - FileOutputStream outputStreamrp = new FileOutputStream(excelreport_tm); - workbook.write(outputStreamrp); - workbook.close(); - System.out.println("Latest Excel Report Path " + FilePath.getLatestResultsLocation()); - - System.out.println("-----------------------------------------------------"); - System.out.println("EXCEL REPORT CREATED SUCCESSFULLY"); - System.out.println("-----------------------------------------------------"); - - // launch excel sheet in case of Windows OS - if (OS.contains("Windows")) { - launchexcel(); - } - } catch (IOException e) { - System.err.println("IOException caught: " + e.getMessage()); - } - - } - - } - - } - - private static void parsearray(Object stepsdetails) { - if (stepsdetails instanceof JSONArray) { - int size = ((JSONArray) stepsdetails).size(); - for (int i = 0; i < size; i++) { - JSONObject s = (JSONObject) ((JSONArray) stepsdetails).get(i); - Object obj = s.get("data"); - if (obj instanceof JSONObject) { - objectsarray.add((JSONObject) s.get("data")); - } else { - parsearray(s.get("data")); - } - } - } - if (stepsdetails instanceof JSONObject) { - objectsarray.add((JSONObject) stepsdetails); - } - } - - private static void clearObjectArray() { - objectsarray.clear(); - } - - private void launchexcel() throws IOException { - String excelreport = FilePath.getCurrentResultsPath() + "\\SummaryExcelReport.xlsx"; - try { - - LOGGER.info("Trying To Open Excel"); - Runtime.getRuntime().exec("cmd /c start excel \"" + excelreport + "\""); - LOGGER.info("Opened Excel Report Successfully"); - } catch (Exception E) { - System.out.println("Make sure Excel location is added to system path" + E.getMessage()); - LOGGER.info("Unable To Open Report, Please Check If Excel location is added to System Path"); - - } - - } - - /** - * update the result when any error in execution - * - * @param testScenario - * @param testCase - * @param Iteration - * @param testDescription - * @param executionTime - * @param fileName - * @param state - * @param Browser - */ - @Override - public void updateTestCaseResults(String testScenario, String testCase, String Iteration, String testDescription, - String executionTime, String fileName, Status state, String Browser) { - - System.out.println("--------------->[UPDATING SUMMARY]"); - if (state.equals(Status.PASS)) { - PassedTestCases++; - } else { - FailedTestCases++; - } - } - - @Override - public Object getData() { - return testSetData; - } - - @Override - public File getFile() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Status getCurrentStatus() { - if (FailedTestCases > 0 || PassedTestCases == 0) { - return Status.FAIL; - } else { - return Status.PASS; - } - } + roww1.createCell(1).setCellValue(Integer.toString((int) objectsarray.get(j).get("stepno"))); + roww1.createCell(2).setCellValue((String) objectsarray.get(j).get("stepName")); + roww1.createCell(3).setCellValue((String) objectsarray.get(j).get("action")); + roww1.createCell(4).setCellValue((String) objectsarray.get(j).get("description")); + roww1.createCell(5).setCellValue((String) objectsarray.get(j).get("status")); + roww1.createCell(6).setCellValue((String) objectsarray.get(j).get("tStamp")); + + } + + clearObjectArray(); + + for (int j = 0; j < objectsarray.size(); j++) { + //System.out.println("step number" + objectsarray.get(j).get("stepno")); + //System.out.println("step name " + objectsarray.get(j).get("tStamp")); + //System.out.println("number" + j); + } + + // ----------------------- + singleList.add((String) eachexecution.get("scenarioName")); + singleList.add((String) eachexecution.get("testcaseName")); + singleList.add((String) eachexecution.get("browser")); + singleList.add((String) eachexecution.get("exeTime")); + singleList.add((String) eachexecution.get("status")); + singleList.add((String) eachexecution.get("platform")); + singleList.add((String) eachexecution.get("iterationType")); + singleList.add((String) eachexecution.get("bversion")); + listOLists.add(singleList); + + } + + XSSFSheet sheet = workbook.getSheetAt(0); + + XSSFRow header = sheet.getRow(0); + XSSFCell cellvalue = header.getCell(0); + if (cellvalue.getStringCellValue().equalsIgnoreCase("ReleaseName-Testsetname")) { + cellvalue.setCellValue(RunManager.getGlobalSettings().getRelease() + " - " + + RunManager.getGlobalSettings().getTestSet()); + } + + Iterator> iterator = listOLists.iterator(); + int row = 2; + while (iterator.hasNext()) { + ArrayList singleList = iterator.next(); + Iterator childiter = singleList.iterator(); + int i = 1; + XSSFRow roww = sheet.createRow(row); + while (childiter.hasNext()) { + String s = childiter.next(); + + roww.createCell(i).setCellValue(s); + i++; + } + row++; + + } + + // Write content to excel files + FileOutputStream outputStream = new FileOutputStream(excelreport); + workbook.write(outputStream); + + Iterator sheetIterator = workbook.sheetIterator(); + DataFormatter dataFormatter = new DataFormatter(); + + FileOutputStream outputStreamrp = new FileOutputStream(excelreport_tm); + workbook.write(outputStreamrp); + workbook.close(); + System.out.println("Latest Excel Report Path " + FilePath.getLatestResultsLocation()); + + System.out.println("-----------------------------------------------------"); + System.out.println("EXCEL REPORT CREATED SUCCESSFULLY"); + System.out.println("-----------------------------------------------------"); + + // launch excel sheet in case of Windows OS + if (OS.contains("Windows")) { + launchexcel(); + } + } catch (IOException e) { + System.err.println("IOException caught: " + e.getMessage()); + } + + } + + } + + } + + private static void parsearray(Object stepsdetails) { + if (stepsdetails instanceof JSONArray) { + int size = ((JSONArray) stepsdetails).size(); + for (int i = 0; i < size; i++) { + JSONObject s = (JSONObject) ((JSONArray) stepsdetails).get(i); + Object obj = s.get("data"); + if (obj instanceof JSONObject) { + objectsarray.add((JSONObject) s.get("data")); + } else { + parsearray(s.get("data")); + } + } + } + if (stepsdetails instanceof JSONObject) { + objectsarray.add((JSONObject) stepsdetails); + } + } + + private static void clearObjectArray() { + objectsarray.clear(); + } + + private void launchexcel() throws IOException { + String excelreport = FilePath.getCurrentResultsPath() + "\\SummaryExcelReport.xlsx"; + try { + + LOGGER.info("Trying To Open Excel"); + Runtime.getRuntime().exec("cmd /c start excel \"" + excelreport + "\""); + LOGGER.info("Opened Excel Report Successfully"); + } catch (Exception E) { + System.out.println("Make sure Excel location is added to system path" + E.getMessage()); + LOGGER.info("Unable To Open Report, Please Check If Excel location is added to System Path"); + + } + + } + + /** + * update the result when any error in execution + * + * @param testScenario + * @param testCase + * @param Iteration + * @param testDescription + * @param executionTime + * @param fileName + * @param state + * @param Browser + */ + @Override + public void updateTestCaseResults(String testScenario, String testCase, String Iteration, String testDescription, + String executionTime, String fileName, Status state, String Browser) { + + System.out.println("--------------->[UPDATING SUMMARY]"); + if (state.equals(Status.PASS)) { + PassedTestCases++; + } else { + FailedTestCases++; + } + } + + @Override + public Object getData() { + return testSetData; + } + + @Override + public File getFile() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Status getCurrentStatus() { + if (FailedTestCases > 0 || PassedTestCases == 0) { + return Status.FAIL; + } else { + return Status.PASS; + } + } } diff --git a/Engine/src/main/java/com/ing/engine/reporting/impl/html/HtmlSummaryHandler.java b/Engine/src/main/java/com/ing/engine/reporting/impl/html/HtmlSummaryHandler.java index 66e7402..d6a700b 100644 --- a/Engine/src/main/java/com/ing/engine/reporting/impl/html/HtmlSummaryHandler.java +++ b/Engine/src/main/java/com/ing/engine/reporting/impl/html/HtmlSummaryHandler.java @@ -1,4 +1,3 @@ - package com.ing.engine.reporting.impl.html; import com.ing.engine.constants.FilePath; @@ -56,7 +55,7 @@ public HtmlSummaryHandler(SummaryReport report) { perf = new PerformanceReport(); } createReportIfNotExists(FilePath.getResultsPath()); - + } @Override @@ -65,7 +64,6 @@ public void addHar(Har h, TestCaseReport report, String pageNam perf.addHar(h, report, pageName); } } - private void createReportIfNotExists(String path) { File file = new File(path + File.separator + "media"); @@ -154,7 +152,7 @@ public synchronized void updateResults() { testSetData.put(RDS.TestSet.EXECUTIONS, executions); testSetData.put(RDS.TestSet.END_TIME, endTime); testSetData.put(RDS.TestSet.EXE_TIME, exeTime); - + testSetData.put(RDS.TestSet.NO_OF_FAIL_TESTS, String.valueOf(FailedTestCases)); testSetData.put(RDS.TestSet.NO_OF_PASS_TESTS, String.valueOf(PassedTestCases)); RDS.writeToDataJS(FilePath.getCurrentReportDataPath(), testSetData); @@ -183,7 +181,7 @@ public synchronized void finalizeReport() { } else { createHtmls(); } - + createBddReport(); } catch (Exception ex) { LOGGER.log(Level.SEVERE, ex.getMessage(), ex); @@ -203,6 +201,10 @@ private void createHtmls() throws IOException { FileUtils.copyFileToDirectory(new File(FilePath.getPerfReportHTMLPath()), new File(FilePath.getCurrentResultsPath())); } + if (Control.exe.getExecSettings().getRunSettings().isVideoEnabled()) { + FileUtils.copyFileToDirectory(new File(FilePath.getVideoReportHTMLPath()), + new File(FilePath.getCurrentResultsPath())); + } } private void createStandaloneHtmls() throws IOException { @@ -261,14 +263,15 @@ public boolean isExtentEnabled() { return Control.getCurrentProject().getProjectSettings() .getExecSettings(RunManager.getGlobalSettings().getRelease(), RunManager.getGlobalSettings().getTestSet()).getRunSettings().isExtentReport(); } - + return false; } + /** * open the summary report when execution is finished */ public synchronized void launchResultSummary() { - if (!isExtentEnabled()){ + if (!isExtentEnabled()) { if (SystemDefaults.canLaunchSummary()) { DesktopApi.open(new File(FilePath.getCurrentSummaryHTMLPath())); } diff --git a/Engine/src/main/java/com/ing/engine/reporting/impl/html/HtmlTestCaseHandler.java b/Engine/src/main/java/com/ing/engine/reporting/impl/html/HtmlTestCaseHandler.java index 1b999ba..4564d15 100644 --- a/Engine/src/main/java/com/ing/engine/reporting/impl/html/HtmlTestCaseHandler.java +++ b/Engine/src/main/java/com/ing/engine/reporting/impl/html/HtmlTestCaseHandler.java @@ -1,4 +1,3 @@ - package com.ing.engine.reporting.impl.html; import com.ing.datalib.util.data.FileScanner; @@ -96,21 +95,19 @@ public void updateTestLog(String stepName, String stepDescription, Status state, data.put(RDS.Step.Data.DESCRIPTION, ReportUtils.resolveDesc(stepDescription)); data.put(RDS.Step.Data.TIME_STAMP, time); data.put(RDS.Step.Data.STATUS, state.toString()); - - String payloadfiles=""; - String filename=""; + + String payloadfiles = ""; + String filename = ""; if (link != null) { - payloadfiles = testCaseData.get(TestCase.SCENARIO_NAME) - + "_" - + testCaseData.get(TestCase.TESTCASE_NAME) - + "_Step-" - + getStepCount() - + "_"; - filename=AppResourcePath.getCurrentResultsPath()+link+File.separator+payloadfiles; + payloadfiles = testCaseData.get(TestCase.SCENARIO_NAME) + + "_" + + testCaseData.get(TestCase.TESTCASE_NAME) + + "_Step-" + + getStepCount() + + "_"; + filename = AppResourcePath.getCurrentResultsPath() + link + File.separator + payloadfiles; data.put(RDS.Step.Data.LINK, filename); } - - /*if (link != null) { data.put(RDS.Step.Data.LINK, link); }*/ @@ -120,12 +117,18 @@ public void updateTestLog(String stepName, String stepDescription, Status state, } else { ((JSONArray) reusable.get(RDS.Step.DATA)).add(step); } + if (Control.exe.getExecSettings().getRunSettings().isVideoEnabled()) { + if (isIteration) { + iteration.put(RDS.TestSet.VIDEO_REPORT_DIR, getDriver().page.video().path().toString()); + } else { + reusable.put(RDS.TestSet.VIDEO_REPORT_DIR, getDriver().page.video().path().toString()); + } + } } catch (Exception ex) { LOG.log(Level.SEVERE, ex.getMessage(), ex); } } - - + /** * creates new iteration object * @@ -188,7 +191,7 @@ public void endIteration(int CurrentTestCaseIteration) { } private void onSetpDone() { - DoneSteps++; + DoneSteps++; if (reusable != null && reusable.get(TestCase.STATUS).equals("")) { reusable.put(TestCase.STATUS, "PASS"); } @@ -233,7 +236,7 @@ private void putStatus(Status state, List optional, String optionalLink, case FAILNS: onSetpFailed(); break; - case COMPLETE: + case COMPLETE: break; } diff --git a/Engine/src/main/java/com/ing/engine/reporting/util/RDS.java b/Engine/src/main/java/com/ing/engine/reporting/util/RDS.java index 02b5608..de54e5e 100644 --- a/Engine/src/main/java/com/ing/engine/reporting/util/RDS.java +++ b/Engine/src/main/java/com/ing/engine/reporting/util/RDS.java @@ -1,4 +1,3 @@ - package com.ing.engine.reporting.util; import java.io.BufferedWriter; @@ -11,7 +10,7 @@ /** * - * + * */ @SuppressWarnings("unchecked") public class RDS { @@ -80,6 +79,8 @@ public class TestSet { public static final String BDD_STYLE = "bddReport"; public static final String AXE_REPORT = "axeReport"; public static final String PERF_REPORT = "perfReport"; + public static final String VIDEO_REPORT = "videoReport"; + public static final String VIDEO_REPORT_DIR = "videoReportDir"; } public class TestCase { diff --git a/Resources/Configuration/ReportTemplate/html/detailed.html b/Resources/Configuration/ReportTemplate/html/detailed.html index d4b95fc..5cdb0ac 100644 --- a/Resources/Configuration/ReportTemplate/html/detailed.html +++ b/Resources/Configuration/ReportTemplate/html/detailed.html @@ -169,6 +169,7 @@
Comparison map
+ +
+
+ + +
+ + + + + + +
+ + Video Recordings not found. + + +
+
+ + diff --git a/Resources/Configuration/ReportTemplate/media/css/report.css b/Resources/Configuration/ReportTemplate/media/css/report.css index 7a7c16b..8994e06 100644 --- a/Resources/Configuration/ReportTemplate/media/css/report.css +++ b/Resources/Configuration/ReportTemplate/media/css/report.css @@ -271,6 +271,20 @@ div.dataTables_wrapper { background-image:url("../../media/images/poll.svg"); } +.footer-icons>.footer-video{ + background-image:url("../../media/images/video.png"); + background-size: 80%; + } + +.noVideoFound{ + background-color: #f0ad4e; + margin: 8px; + position: absolute; + font-size: 13px; + font-weight: 500; + padding: 4px 12px; + } + .dataTables_filter{ position: relative; } diff --git a/Resources/Configuration/ReportTemplate/media/images/video.png b/Resources/Configuration/ReportTemplate/media/images/video.png new file mode 100644 index 0000000..f9fdcf1 Binary files /dev/null and b/Resources/Configuration/ReportTemplate/media/images/video.png differ diff --git a/Resources/Configuration/ReportTemplate/media/js/detailed.js b/Resources/Configuration/ReportTemplate/media/js/detailed.js index bded3d8..00a05ef 100644 --- a/Resources/Configuration/ReportTemplate/media/js/detailed.js +++ b/Resources/Configuration/ReportTemplate/media/js/detailed.js @@ -203,6 +203,9 @@ var isTCMatched = function(exe) { // onResized(); } }); + $scope.videoReport = DATA.videoReport; + $scope.steps = $scope.Details[$scope.view].STEPS; + $scope.myLink = $scope.steps.length == 1 ? $scope.steps[0].videoReportDir : 'videoReport.html?SC='+ $scope.Details[$scope.view].scenarioName +'&TC='+ $scope.Details[$scope.view].testcaseName; }]); })(); var setCImage = function(url) { diff --git a/Resources/Configuration/ReportTemplate/media/js/video.js b/Resources/Configuration/ReportTemplate/media/js/video.js new file mode 100644 index 0000000..6247424 --- /dev/null +++ b/Resources/Configuration/ReportTemplate/media/js/video.js @@ -0,0 +1,76 @@ +/*Added by: Chester Luzon 02/16/2024*/ +var isTCMatched = function(exe) { + return (exe[ID.scname] === Params.SC) && (exe[ID.name] === Params.TC); +}; + +function getBroUID(row, sep) { + return row[ID.browser] + sep + row[ID.bversion] + sep + row[ID.platform] + sep + row[ID.iType]; +}; +var checkandPush = function(array, val) { + if (!contains(array, val)) + array.push(val); + return array; +}; +var Util = { + "contains": contains, + "checkandPush": checkandPush +}; +var contains = function(array, val) { + return array.indexOf(val) !== -1; +}; + +var ID = {"scname": "scenarioName", "name": "testcaseName", "stime": "startTime", "etime": "endTime", + "stat": "status", "exetime": "exeTime", "browser": "browser", "iterations": "iterations", + "bversion": "bversion", "platform": "platform", "iType": "iterationType", "emode": "runConfiguration", + "STEP": {"no": "stepno", "name": "stepName", "action": "action", "desc": "description", "status": "status", "time": "tStamp", "res": "result", "link": "link", "objects": "objects", "actual": "actual", "expected": "expected", "comparison": "comparison"}}; +var Params; +var broID; + +(window.onpopstate = function () { + var match, + pl = /\+/g, + search = /([^&=]+)=?([^&]*)/g, + decode = function (s) { + return decodeURIComponent(s.replace(pl, " ")); + }, + query = ''; + var regex = /^\?[^#]*$/; + var searchString = window.location.search; + if (regex.test(searchString)) { + query = searchString.substring(1); + } + Params = {}; + while (match = search.exec(query)) + Params[decode(match[1])] = decode(match[2]); + +})(); + +var app = angular.module('videoReport', []); + +app.controller('videoCtrl', ['$scope', function ($scope) { + $scope.Details = getExeData(); + $scope.view = broID; + $scope.steps = $scope.Details[$scope.view].STEPS; + }]); + + +$.regex = $.regex || {}; +$.regex.search = {all: /^(|[>|<]?=?(-1|0|\d{1,6})|(-1|0|\d{1,6})\-(0|\d{1,6}))$/, + between: /^(-1|0|\d{1,6})\-(0|\d{1,6})$/, + gt_lt: /^[>|<]=?(-1|0|\d{1,6})$/ +}; + +var getExeData = function() { + var det = {}; + var eList = DATA.EXECUTIONS; + try { + eList.forEach(function(exe) { + if (isTCMatched(exe)) { + broID = getBroUID(exe, " "); + det[broID] = exe; + } + }); + } catch (ex) { + } + return det; +}; \ No newline at end of file