com.github.siwenyan.superglue.FeatureFileEvaluator Maven / Gradle / Ivy
package com.github.siwenyan.superglue;
import com.github.siwenyan.common.IEvaluator;
import com.github.siwenyan.common.StringTools;
import com.github.siwenyan.common.WhiteBoard;
import com.github.siwenyan.pickle.PickleScenarioOutlineRunner;
import com.github.siwenyan.pickle.PickleScenarioRunner;
import cucumber.api.Scenario;
public class FeatureFileEvaluator extends AbstractStepSet implements IEvaluator {
private final String scenarioString;
private final String scenarioOutlineString;
private final int from;
private final int to;
private final String[] gluePackages;
public FeatureFileEvaluator(String[] gluePackages, Scenario scenario, String stringOrFile) {
super(scenario, null);
this.gluePackages = gluePackages;
this.scenarioString = StringTools.readOrReturn(stringOrFile);
this.scenarioOutlineString = null;
this.from = -1;
this.to = -1;
}
public FeatureFileEvaluator(String[] gluePackages, Scenario scenario, String stringOrFile, int from, int to) {
super(scenario, null);
this.gluePackages = gluePackages;
this.scenarioString = null;
this.scenarioOutlineString = StringTools.readOrReturn(stringOrFile);
this.from = from;
this.to = to;
}
@Override
public boolean evaluate() throws Exception {
boolean success = false;
try {
if (null != scenarioString) {
success = new PickleScenarioRunner().run(
getOwner(),
scenarioString,
this.getClass().getClassLoader(),
gluePackages,
scenario());
}
if (null != scenarioOutlineString) {
success = new PickleScenarioOutlineRunner().run(
getOwner(),
scenarioOutlineString,
from,
to,
this.getClass().getClassLoader(),
gluePackages,
true,
scenario());
}
} catch (Throwable throwable) {
success = false;
}
if (!success) {
return false;
} else {
WhiteBoard.getInstance().combineOwners(getOwner(), getOwner() + ".*");
}
return success;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy