
net.serenitybdd.screenplay.AnonymousPerformableFunction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of serenity-screenplay Show documentation
Show all versions of serenity-screenplay Show documentation
Support for the User Journey pattern in Serenity
package net.serenitybdd.screenplay;
import net.serenitybdd.markers.CanBeSilent;
import net.serenitybdd.annotations.Step;
import net.thucydides.core.steps.StepEventBus;
import net.thucydides.model.steps.ExecutedStepDescription;
import net.thucydides.model.steps.StepFailure;
import java.util.function.Consumer;
public class AnonymousPerformableFunction implements Performable, CanBeSilent {
private final String title;
private final Consumer actions;
private boolean isSilent = false;
public AnonymousPerformableFunction(String title, Consumer actions) {
this.title = title;
this.actions = actions;
}
@Override
@Step("!#title")
public void performAs(T actor) {
try {
actions.accept(actor);
} catch (Throwable e) {
StepEventBus.getEventBus().stepFailed(new StepFailure(ExecutedStepDescription.withTitle(e.getMessage()), e));
throw e;
}
}
@Override
public boolean isSilent() {
return isSilent;
}
public AnonymousPerformableFunction withNoReporting() {
this.isSilent = true;
return this;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy