Behat: "No specifications found at path" error when launching the tests not from project root

Created on 30 Sep 2017  路  11Comments  路  Source: Behat/Behat

Hi,

This happened to me with 3.4.1 version:

If I launch the test from the project root (/var/www/project/) like this:
vagrant@dev-server:**/var/www/project**$ /var/www/project/vendor/bin/behat /var/www/project/features/api/brand/full_rest.feature --config /var/www/project/behat.yml works as usual

BUT if I run it from a different path like /var/www instead of /var/www/project
vagrant@dev-server:**/var/www**$ /var/www/project/vendor/bin/behat /var/www/project/features/api/brand/full_rest.feature --config /var/www/project/behat.yml

Then I get this error
No specifications found at path(s) /var/www/project/features/api/brand/full_rest.feature

I replaced the 3.4 version by the 3.0 and it works again. To me this was necessary because I was getting this error when trying to execute the tests from PHP Storm.

Most helpful comment

In case this helps someone using PHPStorm:

  1. Go to Run > Edit Configuration.
  2. In the Templates section, find Behat.
  3. In Custom working directory, select the root of the project.
  4. Delete any existing configurations in the Behat section, or update their custom working directory.

All new Behat runs will inherit config from the template.

Screen Shot 2019-08-14 at 10 52 29 AM

All 11 comments

Same here. Getting the same error when running the tests from within PhpStorm.

Any news?

This ceased to happen for me.

I don't recall making substantial changes to the IDE and I'm still using the latest version of Behat (3.4.1). IIRC, I ran composer dumpautoload at some point, among the many project's code changes, but I can't tell whether that was the cause of the issue resolution.

Same issue here. Works with 3.0.5, 3.4.1, not so much.

Did you both update the referenced version of behat within the IDE and ran composer dumpautoload?

I'm using the CLI. Haven't done dump autoload, I'll try it, but I can't imagine that being the issue.

My use case is a little different: I run behat from the project root, referencing a config file in a subdirectory. Both the path to the config and the feature file are relative, yet behat 3.4.1 only finds one of them. Without "paths" arguments, behat finds all the feature files just fine.

I tried the dumpautoload and same result. I'm using phpstorm and I copy pasted it the command phpsotrm uses. If I ran it from the project root works fine, if not I get the path errors. And anyway it has nothing to do with the IDE because as I say in the description it happens directly in the command line callen vendor/bin/behat from outside the project root

If you pin behat/gherkin to version 4.4.5 (composer update obviously) and delete your behat_gherkin_cache folder from your temp folder (mine on windows was in the user/myname/appdata/local/temp folder) it will work again, see:
https://github.com/Behat/Gherkin/issues/128 for more details.

Hope that helps someone.

Based on information in #1076 I dug a little deeper. PathsFilter gets a relative path from the FeatureNode which doesn't resolve if your working directory is not the same as %paths.base%, and so it filters all features. See my comment there for more specifics.

In case this helps someone using PHPStorm:

  1. Go to Run > Edit Configuration.
  2. In the Templates section, find Behat.
  3. In Custom working directory, select the root of the project.
  4. Delete any existing configurations in the Behat section, or update their custom working directory.

All new Behat runs will inherit config from the template.

Screen Shot 2019-08-14 at 10 52 29 AM

I got this error when not having added any *.feature file at all.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

diamondsea picture diamondsea  路  6Comments

redthor picture redthor  路  4Comments

DavidGarciaCat picture DavidGarciaCat  路  8Comments

legovaer picture legovaer  路  6Comments

acoulton picture acoulton  路  5Comments