Skip to content

Behat suggests a snippet that already exists #1653

@danon

Description

@danon

Given I have a feature file like this:

Feature: Plan workers for project segments
  Scenario: Extend project segment to Saturday
    When the planner extends the project segment for "Excavation" to include "2025-08-02"
    Then "2025-08-02" (Saturday) is available for planning on project "Excavation"

When I run behat command, it suggests I create a step:

--- FeatureContext has missing steps. Define them with these snippets:

    #[When('the planner extends the project segment for :arg1 to include :arg2')]
    public function thePlannerExtendsTheProjectSegmentForToInclude($arg1, $arg2): void
    {
        throw new PendingException();
    }

--- Don't forget these 2 use statements:

    use Behat\Behat\Tester\Exception\PendingException;
    use Behat\Step\When;

If that step already exists, and I run the test again, then behat suggests that I add this snippet again - the same snippet.

When I do that, then it says:

Feature: Plan workers for project segments

  Scenario: Extend project segment to Saturday                                            # features\Acceptance\Planning\PlanWorkersForProjectSegments.feature:2
    When the planner extends the project segment for "Excavation" to include "2025-08-02"
      Step "the planner extends the project segment for :arg1 to include :arg2" is already defined in FeatureContext::thePlannerExtendsTheProjectSegmentForToInclude()

      FeatureContext::thePlannerExtendsTheProjectSegmentForToInclude()
      FeatureContext::thePlannerExtendsTheProjectSegmentForToInclude2()
    Then "2025-08-02" (Saturday) is available for planning on project "Excavation"
      Step "the planner extends the project segment for :arg1 to include :arg2" is already defined in FeatureContext::thePlannerExtendsTheProjectSegmentForToInclude()

      FeatureContext::thePlannerExtendsTheProjectSegmentForToInclude()
      FeatureContext::thePlannerExtendsTheProjectSegmentForToInclude2()

--- Failed scenarios:

    features\Acceptance\Planning\PlanWorkersForProjectSegments.feature:2

If I remove parenthesis from the steps in feature file, the problem goes away.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions