Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running tests by specifying one or more line numbers returns no specifications found #731

Closed
rocketnova opened this issue Apr 28, 2015 · 17 comments
Labels

Comments

@rocketnova
Copy link

I recently updated to Behat v3.0.15 (from 2.5.3) and now when I try to run tests by specifying one or more line numbers, I get Behat\Testwork\Tester\Exception\WrongPathsException: No specifications found at path. When I add the --dry-run flag, it is able to find the scenario by line number just fine.

I think I've traced it to a problem in Behat\Testwork\Tester\Runtime\RuntimeSuiteTester.php:test() where the $iterator successfully runs through the foreach function when the --dry-run flag is on, but the foreach does not run without that flag. I think that means that the GroupedSpecificationIterator doesn't have any specs when it should...?

Please help. Not being able to run scenarios one at a time when debugging is going to really slow down development. Thanks!

@timiTao
Copy link

timiTao commented May 8, 2015

any more information? folder structure? config file?

@janipalsamaki
Copy link

Not being able to run scenarios one at a time

You could use tags to tag the scenario(s) you want to run and then just: behat --tags=mytag or run a scenario by it's name: behat --name "The name of my scenario".

@penyaskito
Copy link

I'm a big fan of this feature, thanks for the workaround @janipalsamaki.
However I hope it gets fixed.

@everzet everzet added the Bug label Dec 30, 2015
@aaa2000
Copy link
Contributor

aaa2000 commented Jan 5, 2016

I may have misunderstood the bug but "running tests by specifying one or more line numbers" works for me on Behat v3.0.15.

bin/behat -f progress features/append_snippets.feature:231                                                    1 ↵
.....

1 scénario (1 succès)
5 étapes (5 succès)
0m0.21s (12.40Mb)
bin/behat -f progress features/append_snippets.feature:231-405
..............

2 scénarios (2 succès)
14 étapes (14 succès)
0m0.41s (12.41Mb)

@everzet
Copy link
Member

everzet commented Jan 11, 2016

I'm closing this issue as it is seems to be very old and might as well have been fixed. Please reopen with updated stats if that's not the case!

@everzet everzet closed this as completed Jan 11, 2016
@frankcarey
Copy link

Actually, this is broken for me as well. Running it like this works fine..
bin/behat -c behat.docker.yml features/dataset.all.feature

But when I set line numbers it fails, I even tried a large range to see if I was off..
bin/behat -c behat.docker.yml features/dataset.all.feature:1-100

This gives error:

[Behat\Testwork\Tester\Exception\WrongPathsException]
  No specifications found at path(s) `features/dataset.all.feature:1-100`.

Here's a list of the versions I'm running..

php --version
PHP 5.6.16-2+deb.sury.org~precise+1 (cli)
composer version 1.0-dev (72cd6afdfce16f36a9fd786bc1b2f32b851e764f) 2015-12-28 17:35:19
$ composer show -i 

behat/behat                     dev-master 2059cbe Scenario-oriented BDD framework for PHP 5.3
behat/gherkin                   v4.4.0             Gherkin DSL parser for PHP 5.3
behat/mink                      v1.7.0             Browser controller/emulator abstraction for PHP
behat/mink-browserkit-driver    v1.3.0             Symfony2 BrowserKit driver for Mink framework
behat/mink-extension            v2.1.0             Mink extension for Behat
behat/mink-goutte-driver        v1.2.0             Goutte driver for Mink framework
behat/mink-selenium2-driver     v1.3.0             Selenium2 (WebDriver) driver for Mink framework
behat/transliterator            v1.1.0             String transliterator
devinci/devinci-behat-extension dev-master bf79d2c Provides extra behat goodies.
drupal/drupal-driver            v1.1.3             A collection of reusable Drupal drivers
drupal/drupal-extension         v3.1.2             Drupal extension for Behat
fabpot/goutte                   v3.1.2             A simple PHP Web Scraper
guzzlehttp/guzzle               6.1.0              Guzzle is a PHP HTTP client library
guzzlehttp/promises             1.0.3              Guzzle promises library
guzzlehttp/psr7                 1.2.1              PSR-7 message implementation
instaclick/php-webdriver        1.4.3              PHP WebDriver for Selenium 2
nucivic/dkanextension           dev-master c66e343 Provides base DKAN class for Drupal Extension
psr/http-message                1.0                Common interface for HTTP messages
symfony/browser-kit             v2.7.6             Symfony BrowserKit Component
symfony/class-loader            v2.7.6             Symfony ClassLoader Component
symfony/config                  v2.7.6             Symfony Config Component
symfony/console                 v2.7.6             Symfony Console Component
symfony/css-selector            v2.7.6             Symfony CssSelector Component
symfony/dependency-injection    v2.7.6             Symfony DependencyInjection Component
symfony/dom-crawler             v2.7.6             Symfony DomCrawler Component
symfony/event-dispatcher        v2.7.6             Symfony EventDispatcher Component
symfony/filesystem              v2.7.6             Symfony Filesystem Component
symfony/process                 v2.7.6             Symfony Process Component
symfony/translation             v2.7.6             Symfony Translation Component
symfony/yaml                    v2.7.6             Symfony Yaml Component

@aaa2000
Copy link
Contributor

aaa2000 commented Jan 15, 2016

Coule you try with gherkin cache disabled ?

BEHAT_PARAMS='{"gherkin" : {"cache" : null}}' bin/behat -c behat.docker.yml features/dataset.all.feature:1-100

@everzet everzet reopened this Jan 19, 2016
@frankcarey
Copy link

Still no dice .. Were does the line number processing happen? Tracing the code to Behat\Behat\Gherkin\Specification\Locator\ FilesystemFeatureLocator::findFeatureFiles() which is looking if the entire string is an actual file or directory.

Note that I'm using the dev-master branch of behat ( all my versions are posted above)

@dkinzer
Copy link

dkinzer commented Jan 21, 2016

I'm seeing this locally now as well. I can only run all tests at once by not specifying paths at all.

@frankcarey
Copy link

Note that this issue is specific to line numbers for us. We can run a specific file without any issue using our versions.

@slash3b
Copy link

slash3b commented Feb 11, 2016

I have the same problem with line number:

i.tribusean@webdev2 /v/w/h/b/bin> ./behat features/application.feature:13
No scenarios
No steps
0m0.29s (32.69Mb)


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


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] [--rerun] [--stop-on-failure] [--dry-run] [--] [<paths>]

i.tribusean@webdev2 /v/w/h/b/bin> ./behat features/application.feature
@api
Feature: Application submission

  Scenario: Authenticated user views "Vacation or day-off request" page # features/application.feature:5
    Given I am logged in as a user with the "authenticated user" role   # Drupal\DrupalExtension\Context\DrupalContext::assertAuthenticatedByRole()
    When I follow "My requests"                                         # Drupal\DrupalExtension\Context\MinkContext::clickLink()
    And I follow "Vacation"                                             # Drupal\DrupalExtension\Context\MinkContext::clickLink()
    And I follow "Create request"                                       # Drupal\DrupalExtension\Context\MinkContext::clickLink()
    And I follow "Vacation or day-off request"                          # Drupal\DrupalExtension\Context\MinkContext::clickLink()
    Then I should not see text matching "{{"                            # Drupal\DrupalExtension\Context\MinkContext::assertPageNotMatchesText()

  Scenario: Authenticated user views with assigned department "Vacation or day-off request" page # features/application.feature:13
    Given I am logged in as a user with the "authenticated user" role                            # Drupal\DrupalExtension\Context\DrupalContext::assertAuthenticatedByRole()
    When I follow "Edit"                                                                         # Drupal\DrupalExtension\Context\MinkContext::clickLink()
    And I follow "edit-field-department-und"                                                     # Drupal\DrupalExtension\Context\MinkContext::clickLink()
      Link with id|title|alt|text "edit-field-department-und" not found. (Behat\Mink\Exception\ElementNotFoundException)
    Then I break                                                                                 # Drupal\DrupalExtension\Context\DrupalContext::iPutABreakpoint()
    When I press "Save"                                                                          # Drupal\DrupalExtension\Context\MinkContext::pressButton()
    Then I break                                                                                 # Drupal\DrupalExtension\Context\DrupalContext::iPutABreakpoint()

--- Failed scenarios:

    features/application.feature:13

2 scenarios (1 passed, 1 failed)
12 steps (8 passed, 1 failed, 3 skipped)
0m14.01s (35.03Mb)

Thanks to @janipalsamaki for hint.

My components:

i.tribusean@webdev2 /v/w/h/bayer_tests> composer show -i
You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
behat/behat                  v3.0.15 Scenario-oriented BDD framework for PHP 5.3
behat/gherkin                v4.4.1  Gherkin DSL parser for PHP 5.3
behat/mink                   v1.7.0  Browser controller/emulator abstraction for PHP
behat/mink-browserkit-driver v1.3.1  Symfony2 BrowserKit driver for Mink framework
behat/mink-extension         v2.1.0  Mink extension for Behat
behat/mink-goutte-driver     v1.2.0  Goutte driver for Mink framework
behat/mink-selenium2-driver  v1.3.0  Selenium2 (WebDriver) driver for Mink framework
behat/transliterator         v1.1.0  String transliterator
drupal/drupal-driver         v1.1.5  A collection of reusable Drupal drivers
drupal/drupal-extension      v3.0.13 Drupal extension for Behat
fabpot/goutte                v3.1.2  A simple PHP Web Scraper
guzzlehttp/guzzle            6.1.1   Guzzle is a PHP HTTP client library
guzzlehttp/promises          1.0.3   Guzzle promises library
guzzlehttp/psr7              1.2.2   PSR-7 message implementation
instaclick/php-webdriver     1.4.3   PHP WebDriver for Selenium 2
psr/http-message             1.0     Common interface for HTTP messages
symfony/browser-kit          v3.0.2  Symfony BrowserKit Component
symfony/class-loader         v2.8.2  Symfony ClassLoader Component
symfony/config               v2.8.2  Symfony Config Component
symfony/console              v2.8.2  Symfony Console Component
symfony/css-selector         v2.8.2  Symfony CssSelector Component
symfony/dependency-injection v2.8.2  Symfony DependencyInjection Component
symfony/dom-crawler          v3.0.2  Symfony DomCrawler Component
symfony/event-dispatcher     v2.8.2  Symfony EventDispatcher Component
symfony/filesystem           v3.0.2  Symfony Filesystem Component
symfony/polyfill-mbstring    v1.1.0  Symfony polyfill for the Mbstring extension
symfony/process              v3.0.2  Symfony Process Component
symfony/translation          v2.8.2  Symfony Translation Component
symfony/yaml                 v2.8.2  Symfony Yaml Component

@ciaranmcnulty
Copy link
Contributor

I could be crazy but it looks like your Scenario is on line 12?

@slash3b
Copy link

slash3b commented Feb 11, 2016

@ciaranmcnulty thanks for notice. The scenario is indeed in line 12, but it still fails on the line 12.

@jakubzapletal
Copy link

@slash3b It says that the scenario defined on line 13 has failed and that is because of this step And I follow "edit-field-department-und" # Drupal\DrupalExtension\Context\MinkContext::clickLink() Link with id|title|alt|text "edit-field-department-und" not found. (Behat\Mink\Exception\ElementNotFoundException)
The report is OK, it explicitly says which scenario (with the line of scenario definition) has failed.

@stof
Copy link
Member

stof commented Feb 11, 2016

actually, according to the output you pasted, it is on line 13, not on line 12:

Scenario: Authenticated user views with assigned department "Vacation or day-off 
request" page # features/application.feature:13

(note that I hard-wrapped the output to make the snippet more readable)

@slash3b
Copy link

slash3b commented Feb 11, 2016

@jakubzapletal thank you, you are right the line with "And I follow "edit-field-department-und" is not correct. Ok, but the first scenario is fine and I did test it one more time (other scenarios were deleted) and still have the same .

ha, @stof is right, the scenario is on the 13-th line, on the first line of application.feature file I have # language: en, which is not visible in the output. Sorry, completely forgot about that.

@pfrenssen
Copy link
Contributor

Just answering this old question since I was also looking for this information while investigating a different issue and stumbled upon this issue. I hope this might help people searching for this information in the future.

Were does the line number processing happen? Tracing the code to Behat\Behat\Gherkin\Specification\Locator\ FilesystemFeatureLocator::findFeatureFiles() which is looking if the entire string is an actual file or directory.

The splitting of a locator like features/example/example.feature:10 is happening in Gherkin::load() which will split it into a path (features/example/example.feature) and adds a separate LineFilter which is passed the line number 10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests