Search in sources :

Example 1 with WithStepDescriptions

use of io.cucumber.junit.PickleRunners.WithStepDescriptions 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);
}
Also used : Pickle(io.cucumber.core.gherkin.Pickle) Description(org.junit.runner.Description) WithStepDescriptions(io.cucumber.junit.PickleRunners.WithStepDescriptions) Step(io.cucumber.plugin.event.Step) Test(org.junit.jupiter.api.Test)

Example 2 with WithStepDescriptions

use of io.cucumber.junit.PickleRunners.WithStepDescriptions in project cucumber-jvm by cucumber.

the class PickleRunnerWithStepDescriptionsTest method shouldAssignUnequalDescriptionsToDifferentStepsInAScenarioOutline.

@Test
void shouldAssignUnequalDescriptionsToDifferentStepsInAScenarioOutline() {
    Feature features = TestPickleBuilder.parseFeature("path/test.feature", "" + "Feature: FB\n" + "  Scenario Outline: SO\n" + "    When <action>\n" + "    Then <result>\n" + "    Examples:\n" + "    | action | result |\n" + "    |   a1   |   r1   |\n");
    WithStepDescriptions runner = (WithStepDescriptions) PickleRunners.withStepDescriptions(context, features.getPickles().get(0), null, createJunitOptions());
    Description runnerDescription = runner.getDescription();
    Description stepDescription1 = runnerDescription.getChildren().get(0);
    Description stepDescription2 = runnerDescription.getChildren().get(1);
    assertNotEquals(stepDescription1, stepDescription2);
}
Also used : Description(org.junit.runner.Description) WithStepDescriptions(io.cucumber.junit.PickleRunners.WithStepDescriptions) Feature(io.cucumber.core.gherkin.Feature) TestPickleBuilder.picklesFromFeature(io.cucumber.junit.TestPickleBuilder.picklesFromFeature) Test(org.junit.jupiter.api.Test)

Aggregations

WithStepDescriptions (io.cucumber.junit.PickleRunners.WithStepDescriptions)2 Test (org.junit.jupiter.api.Test)2 Description (org.junit.runner.Description)2 Feature (io.cucumber.core.gherkin.Feature)1 Pickle (io.cucumber.core.gherkin.Pickle)1 TestPickleBuilder.picklesFromFeature (io.cucumber.junit.TestPickleBuilder.picklesFromFeature)1 Step (io.cucumber.plugin.event.Step)1