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] onBeforeRunFeature not being called in a specific case #278

Open
youssef-t opened this issue Nov 30, 2022 · 3 comments
Open

[Bug] onBeforeRunFeature not being called in a specific case #278

youssef-t opened this issue Nov 30, 2022 · 3 comments

Comments

@youssef-t
Copy link

Version: 3.0.0-rc.17

Hello,

First of all, I would like to thank you for the package.

The issue is related to calling reporters before running a feature using the following method:

This method is called before running the first scenario, which is equivalent to calling it before the feature generally speaking.
But, what if the first scenario was ignored using a tag expression ?
In this case, the method onBeforeRunFeature will not be called.

The example using the integration_test package illustrates the issue:
For the first scenario, onBeforeRunFeature is called


But, for the second scenario, the method onBeforeRunFeature is not passed as an argument to it. As a consequence, onBeforeRunFeature cannot be called in any case.

It would be great to use another mechanism to detect the first scenario to run for a feature.

Thank you !

@AFASbart
Copy link
Collaborator

AFASbart commented Dec 7, 2022

This is interesting, we then have to keep track which scenario is the actual first scenario that is being ran. I will take a look at this,

@AFASbart
Copy link
Collaborator

AFASbart commented Dec 7, 2022

This is a bigger problem than I anticipated. We actually have 2 cases here, we have to check multiple things:

  1. Are there even scenario's that are being ran?
  2. If so, we can run the beforeFeature.
  3. Which scenario is the last scenario that is ran?
  4. The RunFeature function does not have any knowledge about any scenario's.

Bottom line, this is a bit more difficult to manage than I anticipated if I am honest.

@youssef-t
Copy link
Author

I have been thinking about a clean solution.
One way is to put the logic about the scenarios that will be run in the generated code gherkin_suite_test.g.dart. But, this will add some complexity. Furthermore , I don't know if it is not a bad practice to put some 'advanced logic' in the generated code.

The issue is also valid for the onAfterRunFeature method as it is run after the last scenario of a feature (which can be not run because of a tag expression).

If you think that this issue is worth fixing and adding some logic in the generated code to determine the scenarios that will be run is a clean solution, I can submit a PR in the near future.

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