cucumber.runtime.nashorn.NashornHookDefinition Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cucumber-nashorn Show documentation
Show all versions of cucumber-nashorn Show documentation
A backend for Cucumber JVM that uses Nashorn instead of Rhino
The newest version!
package cucumber.runtime.nashorn;
import static java.util.Arrays.asList;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import gherkin.TagExpression;
import gherkin.formatter.model.Tag;
import java.util.Collection;
import javax.script.Bindings;
import javax.script.ScriptEngine;
import cucumber.api.Scenario;
import cucumber.runtime.HookDefinition;
import cucumber.runtime.Timeout;
public class NashornHookDefinition implements HookDefinition {
private ScriptEngine engine;
private Bindings engineScope;
private Object fn;
private final TagExpression tagExpression;
private final int order;
private final long timeoutMillis;
private StackTraceElement location;
public NashornHookDefinition(ScriptEngine engine, Bindings engineScope, Object fn, String[] tagExpressions, int order, long timeoutMillis, StackTraceElement location) {
this.engine = engine;
this.engineScope = engineScope;
this.fn = fn;
this.tagExpression = new TagExpression(asList(tagExpressions));
this.order = order;
this.timeoutMillis = timeoutMillis;
this.location = location;
}
@Override
public String getLocation(boolean detail) {
return location.getFileName() + ":" + location.getLineNumber();
}
@Override
public void execute(Scenario scenario) throws Throwable {
final Object[] args = new Object[] { scenario };
Timeout.timeout(new Timeout.Callback
© 2015 - 2025 Weber Informatics LLC | Privacy Policy