use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class ExecutionUnitRunnerTest method shouldPopulateRunnerStepsWithStepsUsedInStepDescriptions.
@Test
public void shouldPopulateRunnerStepsWithStepsUsedInStepDescriptions() throws Exception {
CucumberFeature cucumberFeature = TestFeatureBuilder.feature("featurePath", "" + "Feature: feature name\n" + " Background:\n" + " Given background step\n" + " Scenario:\n" + " Then scenario name\n");
ExecutionUnitRunner runner = new ExecutionUnitRunner(null, (CucumberScenario) cucumberFeature.getFeatureElements().get(0), createStandardJUnitReporter());
// fish out the data from runner
Description runnerDescription = runner.getDescription();
Description backgroundStepDescription = runnerDescription.getChildren().get(0);
Description scenarioStepDescription = runnerDescription.getChildren().get(1);
Step runnerBackgroundStep = runner.getRunnerSteps().get(0);
Step runnerScenarioStep = runner.getRunnerSteps().get(1);
assertDescriptionHasStepAsUniqueId(backgroundStepDescription, runnerBackgroundStep);
assertDescriptionHasStepAsUniqueId(scenarioStepDescription, runnerScenarioStep);
}
use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class FeatureRunnerTest method should_call_formatter_for_scenario_outline_with_two_examples_table_and_background.
@Test
public void should_call_formatter_for_scenario_outline_with_two_examples_table_and_background() throws Throwable {
CucumberFeature feature = TestFeatureBuilder.feature("path/test.feature", "" + "Feature: feature name\n" + " Background: background\n" + " Given first step\n" + " Scenario Outline: scenario outline name\n" + " When <x> step\n" + " Then <y> step\n" + " Examples: examples 1 name\n" + " | x | y |\n" + " | second | third |\n" + " | second | third |\n" + " Examples: examples 2 name\n" + " | x | y |\n" + " | second | third |\n");
String formatterOutput = runFeatureWithFormatterSpy(feature);
assertEquals("" + "uri\n" + "feature\n" + " scenarioOutline\n" + " step\n" + " step\n" + " examples\n" + " startOfScenarioLifeCycle\n" + " background\n" + " step\n" + " match\n" + " result\n" + " scenario\n" + " step\n" + " step\n" + " match\n" + " result\n" + " match\n" + " result\n" + " endOfScenarioLifeCycle\n" + " startOfScenarioLifeCycle\n" + " background\n" + " step\n" + " match\n" + " result\n" + " scenario\n" + " step\n" + " step\n" + " match\n" + " result\n" + " match\n" + " result\n" + " endOfScenarioLifeCycle\n" + " examples\n" + " startOfScenarioLifeCycle\n" + " background\n" + " step\n" + " match\n" + " result\n" + " scenario\n" + " step\n" + " step\n" + " match\n" + " result\n" + " match\n" + " result\n" + " endOfScenarioLifeCycle\n" + "eof\n", formatterOutput);
}
use of cucumber.runtime.model.CucumberFeature 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;
}
use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class CucumberPrettyFormatterTest method should_align_the_indentation_of_location_strings.
@Test
public void should_align_the_indentation_of_location_strings() throws Throwable {
CucumberFeature feature = feature("path/test.feature", "Feature: feature name\n" + " Scenario: scenario name\n" + " Given first step\n" + " When second step\n" + " Then third step\n");
Map<String, String> stepsToLocation = new HashMap<String, String>();
stepsToLocation.put("first step", "path/step_definitions.java:3");
stepsToLocation.put("second step", "path/step_definitions.java:7");
stepsToLocation.put("third step", "path/step_definitions.java:11");
String formatterOutput = runFeatureWithPrettyFormatter(feature, stepsToLocation);
assertThat(formatterOutput, containsString(" Scenario: scenario name # path/test.feature:2\n" + " Given first step # path/step_definitions.java:3\n" + " When second step # path/step_definitions.java:7\n" + " Then third step # path/step_definitions.java:11\n"));
}
use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class TestHelper method runFeaturesWithFormatter.
private static void runFeaturesWithFormatter(final List<CucumberFeature> features, final Map<String, Result> stepsToResult, final Map<String, String> stepsToLocation, final List<SimpleEntry<String, Result>> hooks, final long stepHookDuration, final Formatter formatter, final Reporter reporter) throws Throwable {
final RuntimeOptions runtimeOptions = new RuntimeOptions("");
final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
final ClasspathResourceLoader resourceLoader = new ClasspathResourceLoader(classLoader);
final RuntimeGlue glue = createMockedRuntimeGlueThatMatchesTheSteps(stepsToResult, stepsToLocation, hooks);
final Runtime runtime = new Runtime(resourceLoader, classLoader, asList(mock(Backend.class)), runtimeOptions, new StopWatch.Stub(stepHookDuration), glue);
for (CucumberFeature feature : features) {
feature.run(formatter, reporter, runtime);
}
formatter.done();
formatter.close();
}
Aggregations