use of cucumber.runtime.io.Resource in project cucumber-jvm by cucumber.
the class GroovyBackend method loadGlue.
@Override
public void loadGlue(Glue glue, List<String> gluePaths) {
this.glue = glue;
final Binding context = shell.getContext();
for (String gluePath : gluePaths) {
// Load sources
for (Resource resource : resourceLoader.resources(gluePath, ".groovy")) {
Script script = parse(resource);
runIfScript(context, script);
}
// Load compiled scripts
for (Class<? extends Script> glueClass : classFinder.getDescendants(Script.class, packageName(gluePath))) {
try {
Script script = glueClass.getConstructor(Binding.class).newInstance(context);
runIfScript(context, script);
} catch (Exception e) {
throw new CucumberException(e);
}
}
}
}
use of cucumber.runtime.io.Resource 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;
}
Aggregations