Search in sources :

Example 36 with CucumberFeature

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();
}
Also used : CucumberFeature(cucumber.runtime.model.CucumberFeature) Formatter(gherkin.formatter.Formatter) Reporter(gherkin.formatter.Reporter) StepDefinitionReporter(cucumber.api.StepDefinitionReporter) StepDefinitionReporter(cucumber.api.StepDefinitionReporter)

Example 37 with CucumberFeature

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;
}
Also used : CucumberFeature(cucumber.runtime.model.CucumberFeature) ArrayList(java.util.ArrayList) CucumberScenario(cucumber.runtime.model.CucumberScenario) CucumberTagStatement(cucumber.runtime.model.CucumberTagStatement)

Example 38 with CucumberFeature

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());
}
Also used : CucumberFeature(cucumber.runtime.model.CucumberFeature) ArrayList(java.util.ArrayList) Resource(cucumber.runtime.io.Resource) Test(org.junit.Test)

Example 39 with CucumberFeature

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());
}
Also used : CucumberFeature(cucumber.runtime.model.CucumberFeature) Resource(cucumber.runtime.io.Resource) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 40 with CucumberFeature

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());
}
Also used : CucumberFeature(cucumber.runtime.model.CucumberFeature) JSONFormatter(gherkin.formatter.JSONFormatter) CucumberJSONFormatter(cucumber.runtime.formatter.CucumberJSONFormatter) ClasspathResourceLoader(cucumber.runtime.io.ClasspathResourceLoader) CucumberJSONFormatter(cucumber.runtime.formatter.CucumberJSONFormatter) Matchers.anyString(org.mockito.Matchers.anyString) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

CucumberFeature (cucumber.runtime.model.CucumberFeature)64 Test (org.junit.Test)53 HashMap (java.util.HashMap)33 Result (gherkin.formatter.model.Result)32 ArrayList (java.util.ArrayList)19 SimpleEntry (java.util.AbstractMap.SimpleEntry)10 ClasspathResourceLoader (cucumber.runtime.io.ClasspathResourceLoader)6 Resource (cucumber.runtime.io.Resource)6 Formatter (gherkin.formatter.Formatter)5 Reporter (gherkin.formatter.Reporter)5 StepDefinitionReporter (cucumber.api.StepDefinitionReporter)4 Step (gherkin.formatter.model.Step)4 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 Matchers.anyString (org.mockito.Matchers.anyString)4 CucumberJSONFormatter (cucumber.runtime.formatter.CucumberJSONFormatter)3 CucumberTagStatement (cucumber.runtime.model.CucumberTagStatement)3 JSONFormatter (gherkin.formatter.JSONFormatter)3 Tag (gherkin.formatter.model.Tag)3 Description (org.junit.runner.Description)3 Scenario (cucumber.api.Scenario)2