本文整理了Java中gherkin.ast.Feature
类的一些代码示例,展示了Feature
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Feature
类的具体详情如下:
包路径:gherkin.ast.Feature
类名称:Feature
暂无
代码示例来源:origin: cucumber/cucumber-jvm
static Background getBackgroundForTestCase(AstNode astNode) {
Feature feature = getFeatureForTestCase(astNode);
ScenarioDefinition backgound = feature.getChildren().get(0);
if (backgound instanceof Background) {
return (Background) backgound;
} else {
return null;
}
}
代码示例来源:origin: cucumber/cucumber-jvm
private Map<String, Object> createFeature(TestCase testCase) {
Map<String, Object> featureMap = new HashMap<String, Object>();
Feature feature = testSources.getFeature(testCase.getUri());
if (feature != null) {
featureMap.put("keyword", feature.getKeyword());
featureMap.put("name", feature.getName());
featureMap.put("description", feature.getDescription() != null ? feature.getDescription() : "");
if (!feature.getTags().isEmpty()) {
featureMap.put("tags", createTagList(feature.getTags()));
}
}
return featureMap;
}
代码示例来源:origin: cucumber/cucumber-jvm
private void createFeatureStepMap(String path) {
if (!pathToSourceMap.containsKey(path)) {
return;
}
Parser<GherkinDocument> parser = new Parser<GherkinDocument>(new AstBuilder());
TokenMatcher matcher = new TokenMatcher();
try {
GherkinDocument gherkinDocument = parser.parse(pathToSourceMap.get(path), matcher);
Map<Integer, StepNode> stepMap = new HashMap<Integer, StepNode>();
StepNode initialPreviousNode = null;
for (ScenarioDefinition child : gherkinDocument.getFeature().getChildren()) {
StepNode lastStepNode = processScenarioDefinition(stepMap, initialPreviousNode, child);
if (child instanceof Background) {
initialPreviousNode = lastStepNode;
}
}
pathToStepMap.put(path, new FeatureStepMap(new GherkinDialectProvider(gherkinDocument.getFeature().getLanguage()).getDefaultDialect(), stepMap));
} catch (ParserException e) {
// Ignore exceptions
}
}
代码示例来源:origin: cucumber/cucumber-jvm
@Override
public String getName() {
Feature feature = cucumberFeature.getGherkinFeature().getFeature();
return feature.getKeyword() + ": " + feature.getName();
}
代码示例来源:origin: net.serenity-bdd/serenity-cucumber
private Feature featureWithDefaultName(Feature feature, String defaultName) {
return new Feature(feature.getTags(),
feature.getLocation(),
feature.getLanguage(),
feature.getKeyword(),
defaultName,
feature.getDescription(),
feature.getChildren());
}
代码示例来源:origin: cucumber/cucumber-jvm
String getFeatureName(String uri) {
Feature feature = getFeature(uri);
if (feature != null) {
return feature.getName();
}
return "";
}
代码示例来源:origin: trivago/cucable-plugin
String featureName = feature.getKeyword() + ": " + feature.getName();
String featureLanguage = feature.getLanguage();
String featureDescription = feature.getDescription();
List<String> featureTags =
gherkinToCucableConverter.convertGherkinTagsToCucableTags(feature.getTags());
List<ScenarioDefinition> scenarioDefinitions = feature.getChildren();
for (ScenarioDefinition scenarioDefinition : scenarioDefinitions) {
String scenarioName = scenarioDefinition.getKeyword() + ": " + scenarioDefinition.getName();
代码示例来源:origin: net.serenity-bdd/serenity-model
public Optional<Narrative> loadFeatureNarrative(File narrativeFile) {
Optional<Feature> loadedFeature = loadFeature(narrativeFile);
if (!loadedFeature.isPresent()) {
return Optional.empty();
}
Feature feature = loadedFeature.get();
String cardNumber = findCardNumberInTags(tagsDefinedIn(feature));
List<String> versionNumbers = findVersionNumberInTags(tagsDefinedIn(feature));
String title = feature.getName();
String text = descriptionWithScenarioReferencesFrom(feature);
String id = getIdFromName(title);
List<TestTag> tags = feature.getTags().stream().map(tag -> TestTag.withValue(tag.getName())).collect(Collectors.toList());
tags.add(TestTag.withName(title).andType("feature"));
return Optional.of(new Narrative(Optional.ofNullable(title),
Optional.ofNullable(id),
Optional.ofNullable(cardNumber),
versionNumbers,
"feature",
text != null ? text : "",
tags));
}
代码示例来源:origin: mauriciotogneri/green-coffee
public List<Pickle> compile(GherkinDocument gherkinDocument) {
List<Pickle> pickles = new ArrayList<>();
Feature feature = gherkinDocument.getFeature();
if (feature == null) {
return pickles;
}
List<Tag> featureTags = feature.getTags();
List<PickleStep> backgroundSteps = new ArrayList<>();
for (ScenarioDefinition scenarioDefinition : feature.getChildren()) {
if (scenarioDefinition instanceof Background) {
backgroundSteps = pickleSteps(scenarioDefinition);
} else if (scenarioDefinition instanceof Scenario) {
compileScenario(pickles, backgroundSteps, (Scenario) scenarioDefinition, featureTags);
} else {
compileScenarioOutline(pickles, backgroundSteps, (ScenarioOutline) scenarioDefinition, featureTags);
}
}
return pickles;
}
代码示例来源:origin: net.serenity-bdd/serenity-cucumber
private Story userStoryFrom(Feature feature, String featureFileUri) {
Story userStory = Story.withIdAndPath(TestSourcesModel.convertToId(feature.getName()), feature.getName(), featureFileUri).asFeature();
if (!isEmpty(feature.getDescription())) {
userStory = userStory.withNarrative(feature.getDescription());
}
return userStory;
}
代码示例来源:origin: net.serenity-bdd/serenity-cucumber
private Function<CucumberFeature, List<WeightedCucumberScenario>> getScenarios() {
return cucumberFeature -> {
try {
return (cucumberFeature.getGherkinFeature().getFeature() == null) ? Collections.emptyList() : cucumberFeature.getGherkinFeature().getFeature().getChildren()
.stream()
.filter(child -> asList(ScenarioOutline.class, Scenario.class).contains(child.getClass()))
.map(scenarioDefinition -> new WeightedCucumberScenario(
new File(cucumberFeature.getUri()).getName(),
cucumberFeature.getGherkinFeature().getFeature().getName(),
scenarioDefinition.getName(),
scenarioWeightFor(cucumberFeature, scenarioDefinition),
tagsFor(cucumberFeature, scenarioDefinition),
scenarioCountFor(scenarioDefinition)))
.collect(toList());
} catch (Exception e) {
throw new IllegalStateException(String.format("Could not extract scenarios from %s", cucumberFeature.getUri()), e);
}
};
}
代码示例来源:origin: net.serenity-bdd/serenity-model
private List<Tag> tagsDefinedIn(Feature feature) {
return feature.getTags();
}
代码示例来源:origin: cucumber/cucumber-jvm
String getKeywordFromSource(String uri, int stepLine) {
Feature feature = getFeature(uri);
if (feature != null) {
TestSourceRead event = getTestSourceReadEvent(uri);
String trimmedSourceLine = event.source.split("\n")[stepLine - 1].trim();
GherkinDialect dialect = new GherkinDialectProvider(feature.getLanguage()).getDefaultDialect();
for (String keyword : dialect.getStepKeywords()) {
if (trimmedSourceLine.startsWith(keyword)) {
return keyword;
}
}
}
return "";
}
代码示例来源:origin: net.serenity-bdd/serenity-model
private String descriptionWithScenarioReferencesFrom(Feature feature) {
if (feature.getDescription() == null) { return ""; }
return stream(feature.getDescription().split("\\r?\\n"))
.map(line -> DescriptionWithScenarioReferences.from(feature).forText(line))
.collect(Collectors.joining(lineSeparator()));
}
代码示例来源:origin: mauriciotogneri/green-coffee
String language = featureLine.matchedGherkinDialect.getLanguage();
return new Feature(tags, getLocation(featureLine, 0), language, featureLine.matchedKeyword, featureLine.matchedText, description, scenarioDefinitions);
代码示例来源:origin: serenity-bdd/serenity-cucumber
private Feature featureWithDefaultName(Feature feature, String defaultName) {
return new Feature(feature.getTags(),
feature.getLocation(),
feature.getLanguage(),
feature.getKeyword(),
defaultName,
feature.getDescription(),
feature.getChildren());
}
代码示例来源:origin: cucumber/cucumber-jvm
public String getName() {
return gherkinDocument.getFeature().getName();
}
代码示例来源:origin: net.serenity-bdd/serenity-cucumber
private void examples(Feature currentFeature, List<Tag> scenarioOutlineTags, String id, List<Examples> examplesList) {
String featureName = currentFeature.getName();
List<Tag> currentFeatureTags = currentFeature.getTags();
addingScenarioOutlineSteps = false;
initializeExamples();
for (Examples examples : examplesList) {
if (examplesAreNotExcludedByTags(examples, scenarioOutlineTags, currentFeatureTags) && examplesAreNotExcludedByLinesFilter(examples)) {
List<TableRow> examplesTableRows = examples.getTableBody().stream().filter(
tableRow -> tableRowIsNotExcludedByLinesFilter(tableRow)).collect(Collectors.toList());
List<String> headers = getHeadersFrom(examples.getTableHeader());
List<Map<String, String>> rows = getValuesFrom(examplesTableRows, headers);
for (int i = 0; i < examplesTableRows.size(); i++) {
addRow(exampleRows(), headers, examplesTableRows.get(i));
if (examples.getTags() != null) {
exampleTags().put(examplesTableRows.get(i).getLocation().getLine(), examples.getTags());
}
}
String scenarioId = scenarioIdFrom(featureName, id);
boolean newScenario = !scenarioId.equals(currentScenarioId);
table = (newScenario) ?
thucydidesTableFrom(SCENARIO_OUTLINE_NOT_KNOWN_YET, headers, rows, trim(examples.getName()), trim(examples.getDescription()))
: addTableRowsTo(table, headers, rows, trim(examples.getName()), trim(examples.getDescription()));
table.addTagsToLatestDataSet(examples.getTags().stream().map(tag -> TestTag.withValue(tag.getName().substring(1))).collect(Collectors.toList()));
exampleCount = table.getSize();
currentScenarioId = scenarioId;
}
}
}
代码示例来源:origin: ru.sbtqa.tag.pagefactory/page-factory-core
public void replaceDataPlaceholders(List<CucumberFeature> cucumberFeatures) throws DataException, IllegalAccessException {
for (CucumberFeature cucumberFeature : cucumberFeatures) {
featureDataTagValue = "$" + Props.get("data.initial.collection");
GherkinDocument gherkinDocument = cucumberFeature.getGherkinFeature();
Feature feature = gherkinDocument.getFeature();
setFeatureDataTag(parseTags(feature.getTags()));
List<ScenarioDefinition> featureChildren = feature.getChildren();
for (ScenarioDefinition scenarioDefinition : featureChildren) {
List<Tag> currentScenarioTags = getScenarioTags(scenarioDefinition);
setCurrentScenarioTag(parseTags(currentScenarioTags));
List<Step> steps = scenarioDefinition.getSteps();
if (scenarioDefinition instanceof ScenarioOutline) {
List<Examples> examples = ((ScenarioOutline) scenarioDefinition).getExamples();
FieldUtils.writeField(scenarioDefinition, "examples", replaceExamplesPlaceholders(examples), true);
}
for (Step step : steps) {
FieldUtils.writeField(step, "argument", replaceArgumentPlaceholders(step.getArgument()), true);
FieldUtils.writeField(step, "text", replaceDataPlaceholders(step.getText()), true);
}
}
}
}
代码示例来源:origin: serenity-bdd/serenity-cucumber
private Story userStoryFrom(Feature feature, String featureFileUri) {
Story userStory = Story.withIdAndPath(TestSourcesModel.convertToId(feature.getName()), feature.getName(), featureFileUri).asFeature();
if (!isEmpty(feature.getDescription())) {
userStory = userStory.withNarrative(feature.getDescription());
}
return userStory;
}
内容来源于网络,如有侵权,请联系作者删除!