Skip to content

Fix specifications locator to find feature files - #1239

Closed
milkovsky wants to merge 1 commit into
Behat:masterfrom
milkovsky:master
Closed

Fix specifications locator to find feature files#1239
milkovsky wants to merge 1 commit into
Behat:masterfrom
milkovsky:master

Conversation

@milkovsky

Copy link
Copy Markdown

This is my fix for the #1076 issue.
Looks like feature files were not discovered properly. I have extended the locator and iterator for this.

Before:

./bin/behat features/migrate/articles.feature
...
No specifications found at path(s) `features/migrate/articles.feature`. This might be because of incorrect paths configuration in your `suites`.

After:

./bin/behat features/migrate/articles.feature
...
1 scenario (1 passed)
2 steps (2 passed)

P.S. Tests\Behat\Gherkin\Loader\GherkinFileLoaderTest shows no errors.

@milkovsky

Copy link
Copy Markdown
Author

Patch for your composers:
behat-run-single-feature.patch.txt

@milkovsky

Copy link
Copy Markdown
Author

image
Yeeeeiii

* @param FeatureNode[] $features
*/
public function __construct(Suite $suite, Gherkin $gherkin, array $paths, array $filters = array())
public function __construct(Suite $suite, Gherkin $gherkin, array $paths, array $filters = array(), $features = array())

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

missing the type array

$features = array();
foreach ($this->findFeatureFiles($locator) as $featureFile) {
// Collect all the feature specification files.
$features = array_merge($features, $this->gherkin->load($featureFile, $filters));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

i imagine this to be quite slow for big projects. wondering if we can improve it somehow.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Not sure. In my case the $locator is an exact feature file path. In this case foreach will loop only 1 time.
In addiition I guess it will be as "slow" as the next foreach block in this file below.

@jakzal

jakzal commented Sep 25, 2019

Copy link
Copy Markdown
Contributor

Tests are failing. This patch seems to be duplicating features in some cases.

@jakzal

jakzal commented Sep 26, 2019

Copy link
Copy Markdown
Contributor

I don't think this is the right approach. It should be possible to fix this bug without changing the existing interfaces.

Before 08802b7 it all worked fine, so I expect the issue is related to normalising the path, rather than changing the logic of finding features.

@milkovsky

milkovsky commented Sep 27, 2019

Copy link
Copy Markdown
Author

It should be possible to fix this bug without changing the existing interfaces.

Thank you for the feedback. I simply did not find another way to set the features property. I guess we can just add setFeatures() method or smth similar to the FeatureIterator.php.

Before 08802b7 it all worked fine

Good to know. I've just installed behat a few days ago, I am not very familiar with the previous versions. That was a quick workaround from my side to get the tests working. Feel free to close this PR if you preffer a different approach.

@pfrenssen

Copy link
Copy Markdown
Contributor

Behat/Gherkin#129 is the fix for this, already since 2017

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.

5 participants