Search in sources :

Example 1 with FeatureBuilder

use of cucumber.runtime.model.FeatureBuilder in project page-factory-2 by sbtqa.

the class GherkinSerializer method reserializeFeatures.

/**
 * As soon as fragments are inserted, all features structure will unaligned by its file locations.
 * So we need to realign it by reserializing features sources.
 *
 * @param cucumberFeatures unaligned features
 * @return reserealized features
 */
public List<CucumberFeature> reserializeFeatures(List<CucumberFeature> cucumberFeatures) {
    FeatureBuilder featureBuilder = new FeatureBuilder();
    cucumberFeatures.forEach(cucumberFeature -> {
        builder = new StringBuilder();
        Feature feature = cucumberFeature.getGherkinFeature().getFeature();
        builder.append("#language: ").append(feature.getLanguage());
        nl(1);
        if (!feature.getTags().isEmpty()) {
            feature.getTags().forEach(tag -> builder.append(tag.getName()).append(SPACE));
            nl(1);
        }
        builder.append(feature.getKeyword()).append(":").append(SPACE).append(feature.getName());
        nl(1);
        if (feature.getDescription() != null) {
            tab(1);
            builder.append(feature.getDescription());
            nl(1);
        }
        nl(1);
        feature.getChildren().forEach(scenarioDefinition -> buildScenario(builder, scenarioDefinition));
        Resource gherkinResource = new GherkinResource(builder.toString(), cucumberFeature.getUri());
        featureBuilder.parse(gherkinResource);
    });
    return featureBuilder.build();
}
Also used : FeatureBuilder(cucumber.runtime.model.FeatureBuilder) Resource(cucumber.runtime.io.Resource) CucumberFeature(cucumber.runtime.model.CucumberFeature) Feature(gherkin.ast.Feature)

Aggregations

Resource (cucumber.runtime.io.Resource)1 CucumberFeature (cucumber.runtime.model.CucumberFeature)1 FeatureBuilder (cucumber.runtime.model.FeatureBuilder)1 Feature (gherkin.ast.Feature)1