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

Comment between tags and scenario is not allowed with v4.7.0 #187

Closed
phil-davis opened this issue Jan 25, 2021 · 4 comments
Closed

Comment between tags and scenario is not allowed with v4.7.0 #187

phil-davis opened this issue Jan 25, 2021 · 4 comments

Comments

@phil-davis
Copy link
Contributor

With v4.6.* I could have scenarios or scenario outlines like:

  @someTag
  # A comment about the scenario
  Scenario: the user should be able to do good things
  ...

  @someTag
  # A comment about the scenario outline
  Scenario Outline: the user should be able to do good things
  ...
  Examples:
    | filename |
    | easyname.txt |
    | name%with(annoying)characters.txt |

But in v4.7.0:

In Parser.php line 478:
                                                                                                                                                                                                
  [Behat\Gherkin\Exception\ParserException]                                                                                                                                                     
  Expected Step or Examples table, but got Scenario on line: 441 in file: /home/phil/git/owncloud/core/tests/acceptance/features/apiShareManagementBasicToRoot/createShareToRootFolder.feature  
                                                                                                                                                                                                

Exception trace:
  at /home/phil/git/owncloud/core/vendor-bin/behat/vendor/behat/gherkin/src/Behat/Gherkin/Parser.php:478
 Behat\Gherkin\Parser->parseOutline() at /home/phil/git/owncloud/core/vendor-bin/behat/vendor/behat/gherkin/src/Behat/Gherkin/Parser.php:194
 Behat\Gherkin\Parser->parseExpression() at /home/phil/git/owncloud/core/vendor-bin/behat/vendor/behat/gherkin/src/Behat/Gherkin/Parser.php:245
 Behat\Gherkin\Parser->parseFeature() at /home/phil/git/owncloud/core/vendor-bin/behat/vendor/behat/gherkin/src/Behat/Gherkin/Parser.php:188
 Behat\Gherkin\Parser->parseExpression() at /home/phil/git/owncloud/core/vendor-bin/behat/vendor/behat/gherkin/src/Behat/Gherkin/Parser.php:608
 Behat\Gherkin\Parser->parseTags() at /home/phil/git/owncloud/core/vendor-bin/behat/vendor/behat/gherkin/src/Behat/Gherkin/Parser.php:208
 Behat\Gherkin\Parser->parseExpression() at /home/phil/git/owncloud/core/vendor-bin/behat/vendor/behat/gherkin/src/Behat/Gherkin/Parser.php:83
 Behat\Gherkin\Parser->parse() at /home/phil/git/owncloud/core/vendor-bin/behat/vendor/behat/gherkin/src/Behat/Gherkin/Loader/GherkinFileLoader.php:97
 Behat\Gherkin\Loader\GherkinFileLoader->parseFeature() at /home/phil/git/owncloud/core/vendor-bin/behat/vendor/behat/gherkin/src/Behat/Gherkin/Loader/GherkinFileLoader.php:77
 Behat\Gherkin\Loader\GherkinFileLoader->load() at /home/phil/git/owncloud/core/vendor-bin/behat/vendor/behat/gherkin/src/Behat/Gherkin/Gherkin.php:110
 Behat\Gherkin\Gherkin->load() at /home/phil/git/owncloud/core/vendor-bin/behat/vendor/behat/behat/src/Behat/Behat/Gherkin/Specification/LazyFeatureIterator.php:205
 Behat\Behat\Gherkin\Specification\LazyFeatureIterator->parseFeature() at /home/phil/git/owncloud/core/vendor-bin/behat/vendor/behat/behat/src/Behat/Behat/Gherkin/Specification/LazyFeatureIterator.php:189
 Behat\Behat\Gherkin\Specification\LazyFeatureIterator->moveToNextAvailableFeature() at /home/phil/git/owncloud/core/vendor-bin/behat/vendor/behat/behat/src/Behat/Behat/Gherkin/Specification/LazyFeatureIterator.php:90
 Behat\Behat\Gherkin\Specification\LazyFeatureIterator->rewind() at /home/phil/git/owncloud/core/vendor-bin/behat/vendor/behat/behat/src/Behat/Testwork/Specification/GroupedSpecificationIterator.php:84
 Behat\Testwork\Specification\GroupedSpecificationIterator->rewind() at /home/phil/git/owncloud/core/vendor-bin/behat/vendor/behat/behat/src/Behat/Testwork/Tester/Runtime/RuntimeSuiteTester.php:60
 Behat\Testwork\Tester\Runtime\RuntimeSuiteTester->test() at /home/phil/git/owncloud/core/vendor-bin/behat/vendor/behat/behat/src/Behat/Testwork/Hook/Tester/HookableSuiteTester.php:73
 Behat\Testwork\Hook\Tester\HookableSuiteTester->test() at /home/phil/git/owncloud/core/vendor-bin/behat/vendor/behat/behat/src/Behat/Testwork/EventDispatcher/Tester/EventDispatchingSuiteTester.php:75
 Behat\Testwork\EventDispatcher\Tester\EventDispatchingSuiteTester->test() at /home/phil/git/owncloud/core/vendor-bin/behat/vendor/behat/behat/src/Behat/Testwork/Tester/Runtime/RuntimeExercise.php:71
 Behat\Testwork\Tester\Runtime\RuntimeExercise->test() at /home/phil/git/owncloud/core/vendor-bin/behat/vendor/behat/behat/src/Behat/Testwork/EventDispatcher/Tester/EventDispatchingExercise.php:73
 Behat\Testwork\EventDispatcher\Tester\EventDispatchingExercise->test() at /home/phil/git/owncloud/core/vendor-bin/behat/vendor/behat/behat/src/Behat/Testwork/Ordering/OrderedExercise.php:80
 Behat\Testwork\Ordering\OrderedExercise->test() at /home/phil/git/owncloud/core/vendor-bin/behat/vendor/behat/behat/src/Behat/Testwork/Tester/Cli/ExerciseController.php:149
 Behat\Testwork\Tester\Cli\ExerciseController->testSpecifications() at /home/phil/git/owncloud/core/vendor-bin/behat/vendor/behat/behat/src/Behat/Testwork/Tester/Cli/ExerciseController.php:108
 Behat\Testwork\Tester\Cli\ExerciseController->execute() at /home/phil/git/owncloud/core/vendor-bin/behat/vendor/behat/behat/src/Behat/Testwork/Cli/Command.php:63
 Behat\Testwork\Cli\Command->execute() at /home/phil/git/owncloud/core/vendor-bin/behat/vendor/symfony/console/Command/Command.php:255
 Symfony\Component\Console\Command\Command->run() at /home/phil/git/owncloud/core/vendor-bin/behat/vendor/symfony/console/Application.php:971
 Symfony\Component\Console\Application->doRunCommand() at /home/phil/git/owncloud/core/vendor-bin/behat/vendor/symfony/console/Application.php:290
 Symfony\Component\Console\Application->doRun() at /home/phil/git/owncloud/core/vendor-bin/behat/vendor/behat/behat/src/Behat/Testwork/Cli/Application.php:124
 Behat\Testwork\Cli\Application->doRun() at /home/phil/git/owncloud/core/vendor-bin/behat/vendor/symfony/console/Application.php:166
 Symfony\Component\Console\Application->run() at /home/phil/git/owncloud/core/vendor-bin/behat/vendor/behat/behat/bin/behat:34

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] [--snippets-for [SNIPPETS-FOR]] [--snippets-type SNIPPETS-TYPE] [--append-snippets] [--no-snippets] [--strict] [--order ORDER] [--rerun] [--stop-on-failure] [--step-through] [--dry-run] [--] [<paths>]

If I put the comment before the tags, then all is well. So there is an easy workaround.

But something accidentally happened that now requires no comment line between tags and the scenario. I will have a look and see if it is easily fixed. That will avoid anyone having to refactor existing feature files.

@phil-davis phil-davis changed the title Comment between tags and scenario is not allowwed with v4.7.0 Comment between tags and scenario is not allowed with v4.7.0 Jan 25, 2021
@ciaranmcnulty
Copy link
Contributor

Any ideas @dpakach ?

@phil-davis
Copy link
Contributor Author

phil-davis commented Jan 25, 2021

Note: the problem actually only happens when the Scenario or Scenario Outline follows a Scenario Outline. IMO the code that processes the Examples table (or tables) of the previous Scenario Outline seems to "jump over" the following combination of a line of tags followed by a comment line. And then it is hoping for some more examples (another section of the examples tables), but it finds a new Scenario or Scenario Outline.

I have a simple test case that I have added locally and made the unit tests fail. Now I am looking to see what little condition in the parser has missed this combination...

@phil-davis
Copy link
Contributor Author

phil-davis commented Jan 25, 2021

See PRs #188 and #189 - ready for review

@phil-davis
Copy link
Contributor Author

PR owncloud/core#38347 demonstrates a "live" run in owncloud/core with Behat/Gherkin 4.7.1 and the Behat tests all pass. They failled with 4.7.0.

So this issue is fixed.

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

No branches or pull requests

2 participants