use of io.cucumber.java.AfterStep in project syndesis-qe by syndesisio.
the class TestHooks method getLogs.
@AfterStep
public void getLogs(Scenario scenario) {
if (scenario.isFailed()) {
TestUtils.printPods(scenario);
log.warn("Scenario {} failed, saving integration logs to scenario", scenario.getName());
// There can be multiple integration pods for one test
List<Pod> integrationPods = OpenShiftUtils.getInstance().pods().list().getItems().stream().filter(p -> p.getMetadata().getName().startsWith("i-") && !p.getMetadata().getName().contains("deploy") && !p.getMetadata().getName().contains("build")).collect(Collectors.toList());
for (Pod integrationPod : integrationPods) {
try {
scenario.attach(OpenShiftUtils.getInstance().getPodLog(integrationPod).getBytes(), "text/plain", String.format("Integration %s log", integrationPod.getMetadata().getName()));
} catch (KubernetesClientException ex) {
// when the build failed, the integration pod is not ready (`ImagePullBackOff`) In that case, the pod doesn't contain log. That
// causes that OpenShiftUtils has thrown KubernetesClientException
}
}
log.info("Adding all failed build to the log");
List<Pod> failedBuilds = OpenShiftUtils.getInstance().pods().list().getItems().stream().filter(p -> p.getMetadata().getName().contains("build") && p.getStatus().getContainerStatuses().stream().anyMatch(c -> c.getState().getTerminated().getReason().equals("Error"))).collect(Collectors.toList());
for (Pod failedBuild : failedBuilds) {
scenario.attach(String.format("%s\n\n%s", failedBuild.getMetadata().getName(), OpenShiftUtils.getInstance().getPodLog(failedBuild)).getBytes(), "text/plain", "Log of failed build " + failedBuild.getMetadata().getName());
}
}
}
use of io.cucumber.java.AfterStep in project extentreports-cucumber6-adapter by grasshopper7.
the class ScreenShotStepDefinition method afterSite.
@AfterStep(value = "@website")
public void afterSite(Scenario scenario) {
System.out.println("AFTER SITE");
TakesScreenshot ts = (TakesScreenshot) driver;
byte[] screenshot = ts.getScreenshotAs(OutputType.BYTES);
scenario.log("this is my failure message……….");
scenario.attach(screenshot, "image/png", "");
driver.quit();
}
Aggregations