gherkin.ast.Feature.getTags()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(12.8k)|赞(0)|评价(0)|浏览(79)

本文整理了Java中gherkin.ast.Feature.getTags()方法的一些代码示例,展示了Feature.getTags()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Feature.getTags()方法的具体详情如下:
包路径:gherkin.ast.Feature
类名称:Feature
方法名:getTags

Feature.getTags介绍

暂无

代码示例

代码示例来源: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 Map<String, Object> createFeatureMap(TestCase testCase) {
  Map<String, Object> featureMap = new HashMap<String, Object>();
  featureMap.put("uri", testCase.getUri());
  featureMap.put("elements", new ArrayList<Map<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() : "");
    featureMap.put("line", feature.getLocation().getLine());
    featureMap.put("id", TestSourcesModel.convertToId(feature.getName()));
    featureMap.put("tags", feature.getTags());
  }
  return featureMap;
}

代码示例来源:origin: cucumber/cucumber-jvm

private void printFeature(String path) {
  Feature feature = testSources.getFeature(path);
  printTags(feature.getTags());
  out.println(feature.getKeyword() + ": " + feature.getName());
  printDescription(feature.getDescription());
}

代码示例来源:origin: net.serenity-bdd/serenity-model

private List<Tag> tagsDefinedIn(Feature feature) {
  return feature.getTags();
}

代码示例来源:origin: io.qameta.allure/allure-cucumber2-jvm

protected boolean getStatusDetailByTag(final String tagName) {
  return scenario.getTags().stream()
      .anyMatch(tag -> tag.getName().equalsIgnoreCase(tagName))
      || feature.getTags().stream()
      .anyMatch(tag -> tag.getName().equalsIgnoreCase(tagName));
}

代码示例来源:origin: io.qameta.allure/allure-cucumber3-jvm

protected boolean getStatusDetailByTag(final String tagName) {
  return scenario.getTags().stream()
      .anyMatch(tag -> tag.getName().equalsIgnoreCase(tagName))
      || feature.getTags().stream()
      .anyMatch(tag -> tag.getName().equalsIgnoreCase(tagName));
}

代码示例来源:origin: net.serenity-bdd/serenity-cucumber

private Set<String> tagsFor(CucumberFeature feature, ScenarioDefinition scenarioDefinition) {
  return FluentIterable.concat(feature.getGherkinFeature().getFeature().getTags(), scenarioTags(scenarioDefinition)).stream().map(Tag::getName).collect(toSet());
}

代码示例来源:origin: serenity-bdd/serenity-cucumber

private Set<String> tagsFor(CucumberFeature feature, ScenarioDefinition scenarioDefinition) {
  return FluentIterable.concat(feature.getGherkinFeature().getFeature().getTags(), scenarioTags(scenarioDefinition)).stream().map(Tag::getName).collect(toSet());
}

代码示例来源: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 void handleTestSourceRead(TestSourceRead event) {
  testSources.addTestSourceReadEvent(event.uri, event);
  String featurePath = event.uri;
  Optional<Feature> possibleFeature = featureFrom(featurePath);
  possibleFeature.ifPresent(
      feature -> {
        featureTags = new ArrayList<>(feature.getTags());
        resetEventBusFor(featurePath);
        initialiseThucydidesListenersFor(featurePath);
        configureDriver(feature, featurePath);
        Story userStory = userStoryFrom(feature, relativeUriFrom(event.uri));
        getStepEventBus(event.uri).testSuiteStarted(userStory);
      }
  );
}

代码示例来源:origin: serenity-bdd/serenity-cucumber

private void configureDriver(Feature feature, String featurePath) {
  getStepEventBus(featurePath).setUniqueSession(systemConfiguration.shouldUseAUniqueBrowser());
  List<String> tags = getTagNamesFrom(feature.getTags());
  String requestedDriver = getDriverFrom(tags);
  String requestedDriverOptions = getDriverOptionsFrom(tags);
  if (isNotEmpty(requestedDriver)) {
    ThucydidesWebDriverSupport.useDefaultDriver(requestedDriver);
    ThucydidesWebDriverSupport.useDriverOptions(requestedDriverOptions);
  }
}

代码示例来源:origin: serenity-bdd/serenity-cucumber

private void handleTestSourceRead(TestSourceRead event) {
  testSources.addTestSourceReadEvent(event.uri, event);
  String featurePath = event.uri;
  Optional<Feature> possibleFeature = featureFrom(featurePath);
  possibleFeature.ifPresent(
      feature -> {
        featureTags = new ArrayList<>(feature.getTags());
        resetEventBusFor(featurePath);
        initialiseThucydidesListenersFor(featurePath);
        configureDriver(feature, featurePath);
        Story userStory = userStoryFrom(feature, relativeUriFrom(event.uri));
        getStepEventBus(event.uri).testSuiteStarted(userStory);
      }
  );
}

代码示例来源:origin: net.serenity-bdd/serenity-cucumber

private void configureDriver(Feature feature, String featurePath) {
  getStepEventBus(featurePath).setUniqueSession(systemConfiguration.shouldUseAUniqueBrowser());
  List<String> tags = getTagNamesFrom(feature.getTags());
  String requestedDriver = getDriverFrom(tags);
  String requestedDriverOptions = getDriverOptionsFrom(tags);
  if (isNotEmpty(requestedDriver)) {
    ThucydidesWebDriverSupport.useDefaultDriver(requestedDriver);
    ThucydidesWebDriverSupport.useDriverOptions(requestedDriverOptions);
  }
}

代码示例来源: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: 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: 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: serenity-bdd/serenity-cucumber

private void startScenario(Feature currentFeature, ScenarioDefinition scenarioDefinition, String scenarioName) {
  getStepEventBus(currentFeaturePath()).setTestSource(TestSourceType.TEST_SOURCE_CUCUMBER.getValue());
  getStepEventBus(currentFeaturePath()).testStarted(scenarioName,
      scenarioIdFrom(TestSourcesModel.convertToId(currentFeature.getName()), TestSourcesModel.convertToId(scenarioName)));
  getStepEventBus(currentFeaturePath()).addDescriptionToCurrentTest(scenarioDefinition.getDescription());
  getStepEventBus(currentFeaturePath()).addTagsToCurrentTest(convertCucumberTags(currentFeature.getTags()));
  if (isScenario(scenarioDefinition)) {
    getStepEventBus(currentFeaturePath()).addTagsToCurrentTest(convertCucumberTags(((Scenario) scenarioDefinition).getTags()));
  } else if (isScenarioOutline(scenarioDefinition)) {
    getStepEventBus(currentFeaturePath()).addTagsToCurrentTest(convertCucumberTags(((ScenarioOutline) scenarioDefinition).getTags()));
  }
  registerFeatureJiraIssues(currentFeature.getTags());
  List<Tag> tags = getTagsOfScenarioDefinition(scenarioDefinition);
  registerScenarioJiraIssues(tags);
  scenarioTags = tagsForScenario(scenarioDefinition);
  updateResultFromTags(scenarioTags);
}

代码示例来源:origin: net.serenity-bdd/serenity-cucumber

private void startScenario(Feature currentFeature, ScenarioDefinition scenarioDefinition, String scenarioName) {
  getStepEventBus(currentFeaturePath()).setTestSource(TestSourceType.TEST_SOURCE_CUCUMBER.getValue());
  getStepEventBus(currentFeaturePath()).testStarted(scenarioName,
      scenarioIdFrom(TestSourcesModel.convertToId(currentFeature.getName()), TestSourcesModel.convertToId(scenarioName)));
  getStepEventBus(currentFeaturePath()).addDescriptionToCurrentTest(scenarioDefinition.getDescription());
  getStepEventBus(currentFeaturePath()).addTagsToCurrentTest(convertCucumberTags(currentFeature.getTags()));
  if (isScenario(scenarioDefinition)) {
    getStepEventBus(currentFeaturePath()).addTagsToCurrentTest(convertCucumberTags(((Scenario) scenarioDefinition).getTags()));
  } else if (isScenarioOutline(scenarioDefinition)) {
    getStepEventBus(currentFeaturePath()).addTagsToCurrentTest(convertCucumberTags(((ScenarioOutline) scenarioDefinition).getTags()));
  }
  registerFeatureJiraIssues(currentFeature.getTags());
  List<Tag> tags = getTagsOfScenarioDefinition(scenarioDefinition);
  registerScenarioJiraIssues(tags);
  scenarioTags = tagsForScenario(scenarioDefinition);
  updateResultFromTags(scenarioTags);
}

代码示例来源: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);
      }
    }
  }
}

相关文章