use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class CucumberExecutor method execute.
/**
* Runs the cucumber scenarios with the specified arguments.
*/
public void execute() {
runtimeOptions.addPlugin(new AndroidInstrumentationReporter(runtime, instrumentation, getNumberOfConcreteScenarios()));
runtimeOptions.addPlugin(new AndroidLogcatReporter(runtime, TAG));
// TODO: This is duplicated in info.cucumber.Runtime.
final Reporter reporter = runtimeOptions.reporter(classLoader);
final Formatter formatter = runtimeOptions.formatter(classLoader);
final StepDefinitionReporter stepDefinitionReporter = runtimeOptions.stepDefinitionReporter(classLoader);
runtime.getGlue().reportStepDefinitions(stepDefinitionReporter);
for (final CucumberFeature cucumberFeature : cucumberFeatures) {
cucumberFeature.run(formatter, reporter, runtime);
}
formatter.done();
formatter.close();
}
use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class ScenarioCounterTest method createCucumberFeaturesWithScenarios.
private List<CucumberFeature> createCucumberFeaturesWithScenarios(final int numberOfCucumberFeatures, final int numberOfCucumberScenarios) {
final List<CucumberFeature> cucumberFeatures = new ArrayList<CucumberFeature>();
for (int f = 0; f < numberOfCucumberFeatures; f++) {
final CucumberFeature cucumberFeature = mock(CucumberFeature.class);
cucumberFeatures.add(cucumberFeature);
final List<CucumberTagStatement> cucumberTagStatements = new ArrayList<CucumberTagStatement>();
for (int s = 0; s < numberOfCucumberScenarios; s++) {
cucumberTagStatements.add(mock(CucumberScenario.class));
}
when(cucumberFeature.getFeatureElements()).thenReturn(cucumberTagStatements);
}
return cucumberFeatures;
}
use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class FeatureBuilderTest method ignores_duplicate_features.
@Test
public void ignores_duplicate_features() throws IOException {
List<CucumberFeature> features = new ArrayList<CucumberFeature>();
FeatureBuilder builder = new FeatureBuilder(features);
String featurePath = "foo.feature";
Resource resource1 = createResourceMock(featurePath);
Resource resource2 = createResourceMock(featurePath);
builder.parse(resource1, NO_FILTERS);
builder.parse(resource2, NO_FILTERS);
assertEquals(1, features.size());
}
use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class FeatureBuilderTest method converts_windows_path_to_forward_slash.
@Test
public void converts_windows_path_to_forward_slash() throws IOException {
char fileSeparatorChar = '\\';
String featurePath = "path" + fileSeparatorChar + "foo.feature";
Resource resource = createResourceMock(featurePath);
List<CucumberFeature> features = new ArrayList<CucumberFeature>();
FeatureBuilder builder = new FeatureBuilder(features, fileSeparatorChar);
builder.parse(resource, NO_FILTERS);
assertEquals(1, features.size());
assertEquals("path/foo.feature", features.get(0).getPath());
}
use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class RuntimeTest method runs_feature_with_json_formatter.
@Ignore
@Test
public void runs_feature_with_json_formatter() throws Exception {
CucumberFeature feature = feature("test.feature", "" + "Feature: feature name\n" + " Background: background name\n" + " Given b\n" + " Scenario: scenario name\n" + " When s\n");
StringBuilder out = new StringBuilder();
JSONFormatter jsonFormatter = new CucumberJSONFormatter(out);
List<Backend> backends = asList(mock(Backend.class));
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
RuntimeOptions runtimeOptions = new RuntimeOptions("");
Runtime runtime = new Runtime(new ClasspathResourceLoader(classLoader), classLoader, backends, runtimeOptions);
feature.run(jsonFormatter, jsonFormatter, runtime);
jsonFormatter.done();
String expected = "" + "[\n" + " {\n" + " \"id\": \"feature-name\",\n" + " \"description\": \"\",\n" + " \"name\": \"feature name\",\n" + " \"keyword\": \"Feature\",\n" + " \"line\": 1,\n" + " \"elements\": [\n" + " {\n" + " \"description\": \"\",\n" + " \"name\": \"background name\",\n" + " \"keyword\": \"Background\",\n" + " \"line\": 2,\n" + " \"steps\": [\n" + " {\n" + " \"result\": {\n" + " \"status\": \"undefined\"\n" + " },\n" + " \"name\": \"b\",\n" + " \"keyword\": \"Given \",\n" + " \"line\": 3,\n" + " \"match\": {}\n" + " }\n" + " ],\n" + " \"type\": \"background\"\n" + " },\n" + " {\n" + " \"id\": \"feature-name;scenario-name\",\n" + " \"description\": \"\",\n" + " \"name\": \"scenario name\",\n" + " \"keyword\": \"Scenario\",\n" + " \"line\": 4,\n" + " \"steps\": [\n" + " {\n" + " \"result\": {\n" + " \"status\": \"undefined\"\n" + " },\n" + " \"name\": \"s\",\n" + " \"keyword\": \"When \",\n" + " \"line\": 5,\n" + " \"match\": {}\n" + " }\n" + " ],\n" + " \"type\": \"scenario\"\n" + " }\n" + " ],\n" + " \"uri\": \"test.feature\"\n" + " }\n" + "]";
assertEquals(expected, out.toString());
}
Aggregations