Search in sources :

Example 1 with FeatureBuilder

use of cucumber.runtime.FeatureBuilder in project cucumber-jvm by cucumber.

the class CucumberFeature method load.

public static List<CucumberFeature> load(ResourceLoader resourceLoader, List<String> featurePaths, final List<Object> filters) {
    final List<CucumberFeature> cucumberFeatures = new ArrayList<CucumberFeature>();
    final FeatureBuilder builder = new FeatureBuilder(cucumberFeatures);
    for (String featurePath : featurePaths) {
        if (featurePath.startsWith("@")) {
            loadFromRerunFile(builder, resourceLoader, featurePath.substring(1), filters);
        } else {
            loadFromFeaturePath(builder, resourceLoader, featurePath, filters, false);
        }
    }
    Collections.sort(cucumberFeatures, new CucumberFeatureUriComparator());
    return cucumberFeatures;
}
Also used : FeatureBuilder(cucumber.runtime.FeatureBuilder) ArrayList(java.util.ArrayList)

Example 2 with FeatureBuilder

use of cucumber.runtime.FeatureBuilder in project cucumber-jvm by cucumber.

the class TestFeatureBuilder method feature.

static CucumberFeature feature(final String path, final String source) throws IOException {
    ArrayList<CucumberFeature> cucumberFeatures = new ArrayList<CucumberFeature>();
    FeatureBuilder featureBuilder = new FeatureBuilder(cucumberFeatures);
    featureBuilder.parse(new Resource() {

        @Override
        public String getPath() {
            return path;
        }

        @Override
        public String getAbsolutePath() {
            throw new UnsupportedOperationException();
        }

        @Override
        public InputStream getInputStream() {
            try {
                return new ByteArrayInputStream(source.getBytes("UTF-8"));
            } catch (UnsupportedEncodingException e) {
                throw new RuntimeException(e);
            }
        }

        @Override
        public String getClassName(String extension) {
            throw new UnsupportedOperationException();
        }
    }, new ArrayList<Object>());
    featureBuilder.close();
    return cucumberFeatures.get(0);
}
Also used : FeatureBuilder(cucumber.runtime.FeatureBuilder) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) Resource(cucumber.runtime.io.Resource) UnsupportedEncodingException(java.io.UnsupportedEncodingException) CucumberFeature(cucumber.runtime.model.CucumberFeature) ByteArrayInputStream(java.io.ByteArrayInputStream)

Example 3 with FeatureBuilder

use of cucumber.runtime.FeatureBuilder in project cucumber-jvm by cucumber.

the class StepdefGeneratorTest method features.

private List<CucumberFeature> features() throws IOException {
    List<CucumberFeature> features = new ArrayList<CucumberFeature>();
    FeatureBuilder fb = new FeatureBuilder(features);
    fb.parse(new Resource() {

        @Override
        public String getPath() {
            return "test.feature";
        }

        @Override
        public String getAbsolutePath() {
            throw new UnsupportedOperationException();
        }

        @Override
        public InputStream getInputStream() {
            try {
                return new ByteArrayInputStream(("" + "Feature: Test\n" + "  Scenario: Test\n" + "    Given I have 4 cukes in my belly\n" + "    And I have 3 bananas in my basket\n" + "    Given I have 42 cukes in my belly\n").getBytes("UTF-8"));
            } catch (UnsupportedEncodingException e) {
                throw new RuntimeException(e);
            }
        }

        @Override
        public String getClassName(String extension) {
            throw new UnsupportedOperationException();
        }
    }, emptyList());
    return features;
}
Also used : FeatureBuilder(cucumber.runtime.FeatureBuilder) CucumberFeature(cucumber.runtime.model.CucumberFeature) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) Resource(cucumber.runtime.io.Resource) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Aggregations

FeatureBuilder (cucumber.runtime.FeatureBuilder)3 ArrayList (java.util.ArrayList)3 Resource (cucumber.runtime.io.Resource)2 CucumberFeature (cucumber.runtime.model.CucumberFeature)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStream (java.io.InputStream)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2