Skip to content

Conversation

@marmichalski
Copy link
Contributor

Resolves #834.

This PR adds support for providing multiple paths to behat cli: behat one.feature two.feature nested/features/

There is a room for improvement to deduplicate the features, but I do not consider this a critical requirement, as this can be considered user error for now. The example of this would be: behat features/a/one.feature features/a

Copy link
Contributor

@acoulton acoulton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marmichalski this looks good to me, and very helpful, thanks.

I agree that it's probably not necessary to try and detect / warn about overlapping paths.

Only question is about the feature coverage - I think it would probably also be worth specifying behaviour when providing directories, and also when specifying specific scenarios e.g. features/feature1.feature:7? I had a quick look and I can't see existing features that cover these so it would be good to make sure we're not breaking anything.

I'd suggest restructuring from the current "everything in one .feature file" to the newer approach with a fixtures directory that @carlos-granados used in e.g. #1593 - that would make it easier to have more than 2 feature files in nested directories and reduce the verbosity of the setup in the .feature file itself.

Are you happy to take a look at that?

@marmichalski
Copy link
Contributor Author

@marmichalski this looks good to me, and very helpful, thanks.

Are you happy to take a look at that?

Yea, sure. I'll see what I can do

@marmichalski
Copy link
Contributor Author

@marmichalski this looks good to me, and very helpful, thanks.

Only question is about the feature coverage - I think it would probably also be worth specifying behaviour when providing directories, and also when specifying specific scenarios e.g. features/feature1.feature:7? I had a quick look and I can't see existing features that cover these so it would be good to make sure we're not breaking anything.

This has been covered, also covered directories filtering.

I'd suggest restructuring from the current "everything in one .feature file" to the newer approach with a fixtures directory that @carlos-granados used in e.g. #1593 - that would make it easier to have more than 2 feature files in nested directories and reduce the verbosity of the setup in the .feature file itself.

I've had a look at what you are proposing here, but all of the scenarios in this file require quite the same setup - we assert that the features were executed only from properly filtered paths I am not sure if it's worth splitting them out to separate feature files? I believe this setup adds more confidence in the filtering too, eg when you provide features/a as path that features/b is not picked up

@acoulton
Copy link
Contributor

acoulton commented May 7, 2025

@marmichalski thanks for this - it looks good to me. The test failures are due to #1635 - we'll get that figured out and then we will be able to see this green.

I'd suggest restructuring from the current "everything in one .feature file" to the newer approach with a fixtures directory...

I've had a look at what you are proposing here, but all of the scenarios in this file require quite the same setup...

I probably wasn't very clear. I was suggesting that instead of the current "Given a file named ..." in the background, you would have those as actual files in a structure like:

tests\Fixtures\PathFilters:
  - features
    - bootstrap
       - FeatureContext.php
    - a
      - feature1.feature
      - feature2.feature
    - b
      - feature1.feature

Then this feature would look more like:

  Background:
    Given I set the working directory to the "PathFilters" fixtures folder
    And I provide the following options for all behat invocations:
      | option      | value  |
      | --no-colors |        |
      | --f         | pretty |

  Scenario: First feature file only
    When  I run behat with the following additional options:
      | option                      | value   |
      | features/a/feature1.feature |         |

This makes it easier to see the actual directory structure of the files in the fixtures directory. It also reduces the noise from the top of the feature and the "when I run behat" steps (things like the FeatureContext implementation, or the -f pretty, all of which are required but not directly relevant to what we're testing here).

If you'd like to have a go at that that would be great, if not I'd be happy with this as-is and we can migrate it to the newer feature / fixtures approach in due course.

@marmichalski
Copy link
Contributor Author

@marmichalski thanks for this - it looks good to me. The test failures are due to #1635 - we'll get that figured out and then we will be able to see this green.

I'd suggest restructuring from the current "everything in one .feature file" to the newer approach with a fixtures directory...

I've had a look at what you are proposing here, but all of the scenarios in this file require quite the same setup...

...
I probably wasn't very clear. I was suggesting that instead of the current "Given a file named ..." in the background, you would have those as actual files in a structure like:
This makes it easier to see the actual directory structure of the files in the fixtures directory. It also reduces the noise from the top of the feature and the "when I run behat" steps (things like the FeatureContext implementation, or the -f pretty, all of which are required but not directly relevant to what we're testing here).
If you'd like to have a go at that that would be great, if not I'd be happy with this as-is and we can migrate it to the newer feature / fixtures approach in due course.

Ah sorry! Added fixtures.

The CI failure seems unrelated - the translations are different when you run the tests with latest dependencies 😢

Copy link
Contributor

@carlos-granados carlos-granados left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall the functionality seems correct and well tested, I just added a couple of small comments/questions

Copy link
Contributor

@carlos-granados carlos-granados left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job @marmichalski we'll let you know once we have been able to solve the failing test

Copy link
Contributor

@acoulton acoulton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've merged master into this to pick up the gherkin fix and it's now green. The PR looks good to me, thanks @marmichalski :-)

Copy link
Contributor

@carlos-granados carlos-granados left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me as well, thanks @marmichalski

@acoulton acoulton merged commit 4ae49a2 into Behat:master May 8, 2025
18 checks passed
@marmichalski marmichalski deleted the multiple-paths branch July 15, 2025 19:26
acoulton added a commit to acoulton/Behat that referenced this pull request Nov 11, 2025
Brings the history of the old abandoned 4.x branch into the current
master, ahead of creating a new 4.x branch. This will avoid us losing
the record of these contributions when we restart development for 4.0.

There are only very limited changes - there was only one functional PR
Behat#1397 that was merged into 4.x in 2023. The same feature was
subsequently implemented by a different contributor in Behat#1611, merged
into master and released in 3.23.0.

The solutions are essentially identical except for a change to
WrongPathsException which I have kept both because it is more correct
and in case anyone is already using the 4.x branch.
acoulton added a commit to acoulton/Behat that referenced this pull request Nov 20, 2025
Brings the history of the old abandoned 4.x branch into the current
master, ahead of creating a new 4.x branch. This will avoid us losing
the record of these contributions when we restart development for 4.0.

There are only very limited changes - there was only one functional PR
subsequently implemented by a different contributor in Behat#1611, merged
into master and released in 3.23.0.

The solutions are essentially identical except for a change to
WrongPathsException which I have kept both because it is more correct
and in case anyone is already using the 4.x branch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Running multiple *.feature files

3 participants