use of io.cucumber.core.gherkin.Pickle in project cucumber-jvm by cucumber.
the class PickleRunnerWithStepDescriptionsTest method shouldAssignUnequalDescriptionsToDifferentOccurrencesOfSameStepInAScenario.
@Test
void shouldAssignUnequalDescriptionsToDifferentOccurrencesOfSameStepInAScenario() {
List<Pickle> pickles = picklesFromFeature("path/test.feature", "" + "Feature: FB\n" + "# Scenario with same step occurring twice\n" + "\n" + " Scenario: SB\n" + " When foo\n" + " Then bar\n" + "\n" + " When foo\n" + " Then baz\n");
WithStepDescriptions runner = (WithStepDescriptions) PickleRunners.withStepDescriptions(context, pickles.get(0), null, createJunitOptions());
// 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.getText(), stepOccurrence2.getText());
// then check that the descriptions are unequal
Description runnerDescription = runner.getDescription();
Description stepDescription1 = runnerDescription.getChildren().get(0);
Description stepDescription2 = runnerDescription.getChildren().get(2);
assertNotEquals(stepDescription1, stepDescription2);
}
use of io.cucumber.core.gherkin.Pickle in project cucumber-jvm by cucumber.
the class PickleRunnerWithNoStepDescriptionsTest method shouldConvertTextFromFeatureFileWithRussianLanguage.
@Test
void shouldConvertTextFromFeatureFileWithRussianLanguage() {
List<Pickle> pickles = TestPickleBuilder.picklesFromFeature("featurePath", "" + "#language:ru\n" + "Функция: имя функции\n" + " Сценарий: имя сценария\n" + " Тогда он работает\n");
PickleRunner runner = PickleRunners.withNoStepDescriptions("имя функции", context, pickles.get(0), null, createFileNameCompatibleJUnitOptions());
assertThat(runner.getDescription().getDisplayName(), is(equalTo("____________(___________)")));
}
use of io.cucumber.core.gherkin.Pickle in project cucumber-jvm by cucumber.
the class PickleRunnerWithNoStepDescriptionsTest method shouldUseScenarioNameWithFeatureNameAsClassNameForDisplayName.
@Test
void shouldUseScenarioNameWithFeatureNameAsClassNameForDisplayName() {
List<Pickle> pickles = TestPickleBuilder.picklesFromFeature("featurePath", "" + "Feature: feature name\n" + " Scenario: scenario name\n" + " Then it works\n");
PickleRunner runner = PickleRunners.withNoStepDescriptions("feature name", context, pickles.get(0), null, createJunitOptions());
assertThat(runner.getDescription().getDisplayName(), is(equalTo("scenario name(feature name)")));
}
use of io.cucumber.core.gherkin.Pickle in project cucumber-jvm by cucumber.
the class TestNGCucumberRunner method runScenario.
public void runScenario(io.cucumber.testng.Pickle pickle) {
context.runTestCase(runner -> {
try (TestCaseResultObserver observer = observe(runner.getBus())) {
Pickle cucumberPickle = pickle.getPickle();
runner.runPickle(cucumberPickle);
observer.assertTestCasePassed();
}
});
}
use of io.cucumber.core.gherkin.Pickle in project cucumber-jvm by cucumber.
the class RunnerTest method steps_are_skipped_after_failure.
@Test
void steps_are_skipped_after_failure() {
StubStepDefinition stepDefinition = spy(new StubStepDefinition("some step"));
Pickle pickleMatchingStepDefinitions = createPickleMatchingStepDefinitions(stepDefinition);
final HookDefinition failingBeforeHook = createHook();
doThrow(new RuntimeException("Boom")).when(failingBeforeHook).execute(ArgumentMatchers.any());
TestRunnerSupplier runnerSupplier = new TestRunnerSupplier(bus, runtimeOptions) {
@Override
public void loadGlue(Glue glue, List<URI> gluePaths) {
glue.addBeforeHook(failingBeforeHook);
glue.addStepDefinition(stepDefinition);
}
};
runnerSupplier.get().runPickle(pickleMatchingStepDefinitions);
InOrder inOrder = inOrder(failingBeforeHook, stepDefinition);
inOrder.verify(failingBeforeHook).execute(any(TestCaseState.class));
inOrder.verify(stepDefinition, never()).execute(any(Object[].class));
}
Aggregations