Search code examples
pythonpython-behave

Behave Runner in PyCharm Error-ing Out Due to some Feature Structure Problem - behave.parser.ParserError:


Question: This Suddenly stopped working in PyCharm and There was only minor change to functions behind the natural language code. The Behave Runner is Error-ing Out - Please help if you have run into this issue and fixed it. I have coded the entire repo and don't see what the issue is. Maybe I'm missing something, never had this issue earlier running the same tests

Feature: Opportunity End Point in AWS ~ DEV, SIT - ENVIRONMENT'S
  Generate an Opportunity Response


  Scenario Outline: Generate an Opportunity Payload for AWS-DEV
    Given we have an opportunity request payload in <AWS-ENVIRONMENT>
    When we submit the post call for the opportunity response <AWS-ENVIRONMENT>
    Examples:
    | AWS-ENVIRONMENT |
    |     AWS_DEV     |


  Scenario Outline: Generate an Opportunity Payload for AWS-DEV and Extract Div Names and Opportunity Count by Divs
    Given we have an opportunity request payload with subset of all accounts in <AWS-ENVIRONMENT>
    When we post the string payload with subset of all accounts in nutrien for AWS-DEV
    Then we extract the rationle embedded within the returned opportunity json
    And we extract unique Divisions within the opportunity response rationale
    And verify the number of occurances of division title in the opportunities Response Payload
    And we extract the opportunity Ids and unique occurances
    Examples:
     | AWS-ENVIRONMENT |
     |   AWS_DEV_ALL   |

Error Stack Trace:

Testing started at 1:18 PM ... Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pycharm/behave_runner.py", line 327, in _BehaveRunner(my_config, base_dir, use_old_runner).run() File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pycharm/_bdd_utils.py", line 102, in run number_of_tests = self._get_number_of_tests() File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pycharm/_bdd_utils.py", line 221, in _get_number_of_tests for feature in self._get_features_to_run(): File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pycharm/behave_runner.py", line 235, in _get_features_to_run self.__real_runner.run() File "lib/python3.8/site-packages/behave/runner.py", line 804, in run return self.run_with_paths() File "lib/python3.8/site-packages/behave/runner.py", line 818, in run_with_paths features = parse_features(feature_locations, language=self.config.lang) File "lib/python3.8/site-packages/behave/runner_util.py", line 326, in parse_features feature = parser.parse_file(filename, language=language) File "lib/python3.8/site-packages/behave/parser.py", line 18, in parse_file return parse_feature(data, language, filename) File "/lib/python3.8/site-packages/behave/parser.py", line 26, in parse_feature result = Parser(language).parse(data, filename) File "/lib/python3.8/site-packages/behave/parser.py", line 148, in parse self.action(line) File "/lib/python3.8/site-packages/behave/parser.py", line 282, in action raise ParserError(msg, self.line, self.filename, line) behave.parser.ParserError: Failed to parse "/tests/aws/features/xxxxx.feature":

Parser in unknown state features; at line 8: "When we submit the post call for the opportunity response "

Process finished with exit code 1


Solution

  • Somehow the Virtual Env that was pointed at the Gherkin/ Behave Runner got corrupted Basically if you see this error, re install the VLENV with the requirements.txt and the Runner should start working.

    So in steps

    • destroy vlenv
    • recreate vlenv with relevant dependencies
    • configure the vlenv to the python interpreter settings in PyCharm
    • re run the behave runner