use of cucumber.runtime.StepDefinition in project cucumber-jvm by cucumber.
the class StepdefGenerator method generate.
public List<MetaStepdef> generate(Collection<StepDefinition> stepDefinitions, List<CucumberFeature> features) {
List<MetaStepdef> result = new ArrayList<MetaStepdef>();
List<StepDefinition> sortedStepdefs = new ArrayList<StepDefinition>();
sortedStepdefs.addAll(stepDefinitions);
Collections.sort(sortedStepdefs, STEP_DEFINITION_COMPARATOR);
for (StepDefinition stepDefinition : sortedStepdefs) {
MetaStepdef metaStepdef = new MetaStepdef();
metaStepdef.source = stepDefinition.getPattern();
// TODO = get the flags too
metaStepdef.flags = "";
for (CucumberFeature feature : features) {
List<CucumberTagStatement> cucumberTagStatements = feature.getFeatureElements();
for (CucumberTagStatement tagStatement : cucumberTagStatements) {
List<Step> steps = tagStatement.getSteps();
for (Step step : steps) {
List<Argument> arguments = stepDefinition.matchedArguments(step);
if (arguments != null) {
MetaStepdef.MetaStep ms = new MetaStepdef.MetaStep();
ms.name = step.getName();
for (Argument argument : arguments) {
MetaStepdef.MetaArgument ma = new MetaStepdef.MetaArgument();
ma.offset = argument.getOffset();
ma.val = argument.getVal();
ms.args.add(ma);
}
metaStepdef.steps.add(ms);
}
}
}
Collections.sort(cucumberTagStatements, CUCUMBER_TAG_STATEMENT_COMPARATOR);
}
result.add(metaStepdef);
}
return result;
}
use of cucumber.runtime.StepDefinition in project cucumber-jvm by cucumber.
the class FromDataTableTest method runStepDef.
private StepDefs runStepDef(Method method, List<DataTableRow> rows) throws Throwable {
StepDefs stepDefs = new StepDefs();
StepDefinition stepDefinition = new StubStepDefinition(stepDefs, method, "some pattern");
Step stepWithRows = new Step(NO_COMMENTS, "Given ", "something", 10, rows, null);
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
StepDefinitionMatch stepDefinitionMatch = new StepDefinitionMatch(NO_ARGS, stepDefinition, "some.feature", stepWithRows, new LocalizedXStreams(classLoader));
stepDefinitionMatch.runStep(new I18n("en"));
return stepDefs;
}
Aggregations