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

[BUG] Teardown methods call setup functions #5

Open
appaji2020 opened this issue May 31, 2024 · 1 comment
Open

[BUG] Teardown methods call setup functions #5

appaji2020 opened this issue May 31, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@appaji2020
Copy link

Describe the bug
I am trying to use gherkin parser. I observed that when i define Suite Teardown/Test Teardown, it calls setup method instead.

To Reproduce
Steps to reproduce the behavior:

  1. Define hooks.resource as and https://github.com/robotcodedev/robotframework-gherkin-parser/blob/main/examples/simple/features/steps/hooks.resource and refer in https://github.com/robotcodedev/robotframework-gherkin-parser/blob/main/examples/simple/features/__init__.robot
  2. run a demo test
  3. In results I see SuiteTeardown called immediately after setup.
  4. Test Teardown calls the test setup method

gherkin parser error

If possible add some example source code like:

***Settings***
Library  Collections

***Test Cases***
a simple test
    do something    # this should shown something

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots/ Videos
If applicable, add screenshots or videos to help explain your problem.

Logs
Copy the messages from VSCode "Output" view for RobotCode and RobotCode Language Server for the specific folder/workspace.

Desktop (please complete the following information):

  • VS Code Version :1.88
  • RobotCode Version: 0.83
  • OS: Windows
  • Python Version: 3.11.7
  • RobotFramework Version :7.0
  • Additional tools like none

Additional context
Add any other context about the problem here.

@appaji2020 appaji2020 added the bug Something isn't working label May 31, 2024
@psa-jbeaumont
Copy link

A way to fix the behaviour is to patch GherkinParser/Library.py and introduce an event type switch (before- for setup, after- for teardown):

  • def yield_hooks(self, event_type: str, events: Union[str, Tuple[str, ...]], *args: Any, **kwargs: Any) -> Iterator[str]: and replace line 60 with hook_tags = [tag for tag in kw.tags if tag.startswith(self.prefix + event_type)] to filter events by event_type for example only hook:before-
  • update _create_setup_and_teardown function on line 78 : for name in self.yield_hooks('before-',events) and line 102 : for name in self.yield_hooks('after-',events): to process only before- events for setup and after- events for teardown
  • update start_suite function on line 123: self._create_setup_and_teardown(data, ("before-suite", "before-feature", "after-suite", "after-feature")) to list all suite events/hook keyword tags
  • update start_test function on line 126: self._create_setup_and_teardown(data, ("before-test", "after-test")) to list all test events/hook keyword tags

wvanmourik-uwv added a commit to wvanmourik-uwv/robotframework-gherkin-parser that referenced this issue Nov 20, 2024
PR created based on fix written in issue comment by psa-jbeaumont.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants