/*** * Utility method to generate System properties attachment for the Allure report * * @return a formatted String of the Mule system properties of the given instance. */ @Attachment(value = "Properties") public String attachProperties() { return MapUtils.toString(properties, true).replaceAll("(?<=\\.password=)(.*)", "****"); }
/*** * Utility method to generate Runtime server log attachment for the Allure report * * @return a ByteArray representation of the log. */ @Attachment(value = "Server log ", type = "text/plain", fileExtension = ".log") public byte[] attachServerLog() { try { return Files.readAllBytes(mule.getLog().toPath()); } catch (IOException ignored) { } return null; }
/*** * Utility method to generate Application log attachment for the Allure report * * @param appName the application name * @return a ByteArray representation of the log. */ @Attachment(value = "Application {appName} log", type = "text/plain", fileExtension = ".log") public byte[] attachAppLog(String appName) { try { return Files.readAllBytes(mule.getLog(appName).toPath()); } catch (IOException ignored) { } return null; }
@Attachment(value = "Video on Failure", type = "video/mp4") private byte[] getVideo(URL videoCaptureURL) { try { return urlFetcher.fetchWithRetry(videoCaptureURL, 4); } catch (TimeoutException e) { logger.error("Failed fetching URL {}.", videoCaptureURL); return null; } }
@Attachment(value = "Screenshot on failure", type = "image/png") private byte[] writeScreenshotToFile(TakesScreenshot driver, Path screenshot) { try (OutputStream screenshotStream = Files.newOutputStream(screenshot)) { byte[] bytes = driver.getScreenshotAs(OutputType.BYTES); screenshotStream.write(bytes); screenshotStream.close(); return bytes; } catch (IOException e) { logger.error("Unable to write " + screenshot, e); } catch (WebDriverException e) { logger.error("Unable to take screenshot.", e); } return null; }
@Attachment @Step("Make screen shot of results page") public byte[] makeScreenShot() { return ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES); }