use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class FormatterMissingLifecycleMethods method handles_formatters_missing_startOfScenarioLifeCycle_endOfScenarioLifeCycle.
@Test
public void handles_formatters_missing_startOfScenarioLifeCycle_endOfScenarioLifeCycle() throws Throwable {
CucumberFeature feature = TestHelper.feature("path/test.feature", "" + "Feature: feature name\n" + " Scenario: scenario name\n" + " Given step\n");
FormatterSpy formatterSpy = new FormatterSpy();
RuntimeOptions runtimeOptions = new RuntimeOptions("");
runtimeOptions.addPlugin(new FormatterMissingLifecycleMethods());
runtimeOptions.addPlugin(formatterSpy);
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
TestHelper.runFeatureWithFormatter(feature, new HashMap<String, String>(), runtimeOptions.formatter(classLoader), runtimeOptions.reporter(classLoader));
assertEquals("" + "uri\n" + "feature\n" + " startOfScenarioLifeCycle\n" + " scenario\n" + " step\n" + " match\n" + " result\n" + " endOfScenarioLifeCycle\n" + "eof\n" + "done\n" + "close\n", formatterSpy.toString());
}
use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class FormatterMissingLifecycleMethods method applies_line_filters_only_to_own_feature.
@Test
public void applies_line_filters_only_to_own_feature() throws Exception {
String featurePath1 = "path/bar.feature";
String feature1 = "" + "Feature: bar\n" + " Scenario: scenario_1_1\n" + " * step\n" + " Scenario: scenario_1_2\n" + " * step\n";
String featurePath2 = "path/foo.feature";
String feature2 = "" + "Feature: foo\n" + " Scenario: scenario_2_1\n" + " * step\n" + " Scenario: scenario_2_2\n" + " * step\n";
ResourceLoader resourceLoader = mock(ResourceLoader.class);
mockResource(resourceLoader, featurePath1, feature1);
mockResource(resourceLoader, featurePath2, feature2);
RuntimeOptions options = new RuntimeOptions(featurePath1 + ":2 " + featurePath2 + ":4");
List<CucumberFeature> features = options.cucumberFeatures(resourceLoader);
assertEquals(2, features.size());
assertOnlyScenarioName(features.get(0), "scenario_1_1");
assertOnlyScenarioName(features.get(1), "scenario_2_2");
}
use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class Runtime method run.
/**
* This is the main entry point. Used from CLI, but not from JUnit.
*/
public void run() throws IOException {
// Make sure all features parse before initialising any reporters/formatters
List<CucumberFeature> features = runtimeOptions.cucumberFeatures(resourceLoader);
// TODO: This is duplicated in cucumber.api.android.CucumberInstrumentationCore - refactor or keep uptodate
Formatter formatter = runtimeOptions.formatter(classLoader);
Reporter reporter = runtimeOptions.reporter(classLoader);
StepDefinitionReporter stepDefinitionReporter = runtimeOptions.stepDefinitionReporter(classLoader);
glue.reportStepDefinitions(stepDefinitionReporter);
for (CucumberFeature cucumberFeature : features) {
cucumberFeature.run(formatter, reporter, this);
}
formatter.done();
formatter.close();
printSummary();
}
use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class ExecutionUnitRunnerTest method shouldAssignUnequalDescriptionsToDifferentOccurrencesOfSameStepInAScenario.
@Test
public void shouldAssignUnequalDescriptionsToDifferentOccurrencesOfSameStepInAScenario() throws Exception {
List<CucumberFeature> features = CucumberFeature.load(new ClasspathResourceLoader(this.getClass().getClassLoader()), asList("cucumber/runtime/junit/fb.feature"), Collections.emptyList());
ExecutionUnitRunner runner = new ExecutionUnitRunner(null, (CucumberScenario) features.get(0).getFeatureElements().get(0), createStandardJUnitReporter());
// fish out the two occurrences of the same step and check whether we really got them
Step stepOccurrence1 = runner.getChildren().get(0);
Step stepOccurrence2 = runner.getChildren().get(2);
assertEquals(stepOccurrence1.getName(), stepOccurrence2.getName());
// then check that the descriptions are unequal
Description runnerDescription = runner.getDescription();
Description stepDescription1 = runnerDescription.getChildren().get(0);
Description stepDescription2 = runnerDescription.getChildren().get(2);
assertFalse("Descriptions must not be equal.", stepDescription1.equals(stepDescription2));
}
use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class ExecutionUnitRunnerTest method shouldConvertTextFromFeatureFileForNamesWithFilenameCompatibleNameOption.
@Test
public void shouldConvertTextFromFeatureFileForNamesWithFilenameCompatibleNameOption() throws Exception {
CucumberFeature cucumberFeature = TestFeatureBuilder.feature("featurePath", "" + "Feature: feature name\n" + " Scenario: scenario name\n" + " Then it works\n");
ExecutionUnitRunner runner = new ExecutionUnitRunner(null, (CucumberScenario) cucumberFeature.getFeatureElements().get(0), createJUnitReporterWithOption("--filename-compatible-names"));
assertEquals("Scenario__scenario_name", runner.getName());
assertEquals("Then_it_works", runner.getDescription().getChildren().get(0).getMethodName());
}
Aggregations