Search in sources :

Example 1 with Step

use of io.cucumber.plugin.event.Step 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 Step

use of io.cucumber.plugin.event.Step in project cucumber-jvm by cucumber.

the class TestCaseResultObserverTest method createPickleStepTestStep.

private PickleStepTestStep createPickleStepTestStep() {
    PickleStepTestStep testStep = mock(PickleStepTestStep.class);
    Step step = mock(Step.class);
    when(step.getLocation()).thenReturn(location);
    when(testStep.getStep()).thenReturn(step);
    when(testStep.getUri()).thenReturn(uri);
    return testStep;
}
Also used : PickleStepTestStep(io.cucumber.plugin.event.PickleStepTestStep) PickleStepTestStep(io.cucumber.plugin.event.PickleStepTestStep) Step(io.cucumber.plugin.event.Step)

Aggregations

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