use of io.cucumber.core.gherkin.Feature in project cucumber-jvm by cucumber.
the class FeatureRunnerTest method should_not_issue_notification_for_steps_by_default_two_scenarios_with_background.
@Test
void should_not_issue_notification_for_steps_by_default_two_scenarios_with_background() {
Feature feature = TestPickleBuilder.parseFeature("path/test.feature", "" + "Feature: feature name\n" + " Background: background\n" + " Given step #1\n" + " Scenario: scenario_1 name\n" + " When step #2\n" + " Then step #3\n" + " Scenario: scenario_2 name\n" + " Then step #2\n");
RunNotifier notifier = runFeatureWithNotifier(feature, new JUnitOptions());
InOrder order = inOrder(notifier);
order.verify(notifier).fireTestStarted(argThat(new DescriptionMatcher("scenario_1 name(feature name)")));
order.verify(notifier, times(1)).fireTestFailure(argThat(new FailureMatcher("scenario_1 name(feature name)")));
order.verify(notifier).fireTestFinished(argThat(new DescriptionMatcher("scenario_1 name(feature name)")));
order.verify(notifier).fireTestStarted(argThat(new DescriptionMatcher("scenario_2 name(feature name)")));
order.verify(notifier, times(1)).fireTestFailure(argThat(new FailureMatcher("scenario_2 name(feature name)")));
order.verify(notifier).fireTestFinished(argThat(new DescriptionMatcher("scenario_2 name(feature name)")));
}
use of io.cucumber.core.gherkin.Feature in project cucumber-jvm by cucumber.
the class JavaSnippetTest method createStep.
private Step createStep(String stepText) {
String source = "" + "Feature: Test feature\n" + " Scenario: Test Scenario\n" + " Given " + stepText + "\n";
Feature feature = TestFeatureParser.parse(source);
return feature.getPickles().get(0).getSteps().get(0);
}
use of io.cucumber.core.gherkin.Feature in project cucumber-jvm by cucumber.
the class FeaturePathFeatureSupplier method loadFeatures.
private List<Feature> loadFeatures(List<URI> featurePaths) {
log.debug(() -> "Loading features from " + featurePaths.stream().map(URI::toString).collect(joining(", ")));
final FeatureBuilder builder = new FeatureBuilder();
for (URI featurePath : featurePaths) {
List<Feature> found = featureScanner.scanForResourcesUri(featurePath);
if (found.isEmpty() && isFeature(featurePath)) {
throw new IllegalArgumentException("Feature not found: " + featurePath);
}
found.forEach(builder::addUnique);
}
return builder.build();
}
use of io.cucumber.core.gherkin.Feature in project cucumber-jvm by cucumber.
the class FeatureParserTest method feature_file_without_pickles_is_parsed_produces_empty_feature.
@Test
void feature_file_without_pickles_is_parsed_produces_empty_feature() throws IOException {
URI uri = URI.create("classpath:com/example.feature");
String source = new String(readAllBytes(Paths.get("src/test/resources/io/cucumber/core/gherkin/messages/no-pickles.feature")));
Optional<Feature> feature = parser.parse(uri, source, UUID::randomUUID);
assertTrue(feature.isPresent());
assertEquals(0, feature.get().getPickles().size());
}
use of io.cucumber.core.gherkin.Feature in project cucumber-jvm by cucumber.
the class FeatureParserTest method unnamed_elements_return_empty_strings_as_name.
@Test
void unnamed_elements_return_empty_strings_as_name() throws IOException {
URI uri = URI.create("classpath:com/example.feature");
String source = new String(readAllBytes(Paths.get("src/test/resources/io/cucumber/core/gherkin/messages/unnamed.feature")));
Feature feature = parser.parse(uri, source, UUID::randomUUID).get();
assertEquals(Optional.empty(), feature.getName());
Node.Rule rule = (Node.Rule) feature.elements().iterator().next();
assertEquals(Optional.empty(), rule.getName());
assertEquals(Optional.of("Rule"), rule.getKeyword());
Iterator<Node> ruleElements = rule.elements().iterator();
Node.Scenario scenario = (Node.Scenario) ruleElements.next();
assertEquals(Optional.empty(), scenario.getName());
assertEquals(Optional.of("Scenario"), scenario.getKeyword());
Node.ScenarioOutline scenarioOutline = (Node.ScenarioOutline) ruleElements.next();
assertEquals(Optional.empty(), scenarioOutline.getName());
assertEquals(Optional.of("Scenario Outline"), scenarioOutline.getKeyword());
Node.Examples examples = scenarioOutline.elements().iterator().next();
assertEquals(Optional.empty(), examples.getName());
assertEquals(Optional.of("Examples"), examples.getKeyword());
Node.Example example = examples.elements().iterator().next();
// Example is the exception.
assertEquals(Optional.of("Example #1"), example.getName());
assertEquals(Optional.empty(), example.getKeyword());
}
Aggregations