Aleks G
Aleks G

Reputation: 57346

No specifications found at path for a valid feature file

I am setting up automated testing with behat (note: I am using behat 3). I have the following directory structure:

project/
    test/
        features/
            web/
                login.feature
            bootstrap/
                Web/
                    LoginContext.php
        behat.yml

This is the initial test of the whole approach. I'm explicitly keeping it simple.

My behat.yml contains the following (that's all there is in it - everything else will come later).

default:
  suites:
    web:
      paths: [%paths.base%/features/web]
      contexts: [Web\LoginContext]

My sole feature file contains the following:

Feature: Login to MedNav
  In order to use MedNav application
  As a user
  I need to be able to login

  Scenario: Valid login credentials
    Given I am on the login page
     When I enter invalid credentials
      And I hit log in button
     Then I should see "Loading, please wait..."
      And I should navigate to Emergency List page

After I executed behat --init, it created file Web\LoginContext, into which I added the stubs for the steps.

Yet, when I try to execute it, nothing happens:

$ bin/behat
No scenarios
No steps
0m0.01s (13.16Mb)

If I specify the feature to execute, it tells me that No specifications found at path(s) 'features/web/login.feature'

$ bin/behat features/web/login.feature 
No scenarios
No steps
0m0.01s (13.16Mb)


  [Behat\Testwork\Tester\Exception\WrongPathsException]             
  No specifications found at path(s) `features/web/login.feature`.  


behat [-s|--suite SUITE] [-f|--format FORMAT] [-o|--out OUT] [--format-settings FORMAT-SETTINGS] [--init] [--lang LANG] [--name NAME] [--tags TAGS] [--role ROLE] [--story-syntax] [-d|--definitions DEFINITIONS] [--append-snippets] [--no-snippets] [--strict] [--order ORDER] [--rerun] [--stop-on-failure] [--dry-run] [--] [<paths>]

I've tried moving things around, removing custom directories, suites, etc. - nothing works.

How can I get behat to recognise the feature file?

Upvotes: 3

Views: 3017

Answers (2)

Aleks G
Aleks G

Reputation: 57346

The answer turned out to be much simpler.

Notice this in the behat.yml:

filters:
    tags: web

Because the corresponding context didn't have this tag, the feature didn't execute. I removed the tags for now - and the feature is now run.

Upvotes: 3

Kamil Adryjanek
Kamil Adryjanek

Reputation: 3338

Please check again your paths - in your case it should be something similar to:

default:
  suites:
    web:
      paths: [ %paths.base%/test/features/web ]

And move behat.yml file to project root directory. I think calling now bin/behat Behat know nothing about behat.yml file.

I assume that you are running bin/behat from project/ path.

This is related to: http://docs.behat.org/en/v3.0/user_guide/configuration.html#custom-autoloading

Upvotes: 0

Related Questions