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

ScenarioTagTrait is not intuitive to use #509

Closed
pfrenssen opened this issue Oct 1, 2018 · 0 comments
Closed

ScenarioTagTrait is not intuitive to use #509

pfrenssen opened this issue Oct 1, 2018 · 0 comments

Comments

@pfrenssen
Copy link
Collaborator

pfrenssen commented Oct 1, 2018

I have a step definition that depends on the @email tag being present and I tried retrieving this using the ScenarioTagTrait. It appears this trait will only retrieve the tags for both the scenario and the feature inside a @beforeStep hook, it won't work in any other hooks or step definitions. ::getCurrentScenarioTags() expects a StepScope to be passed, this is only available in @beforeStep hooks. It looks this is the case because this has been written specifically for MinkContext::beforeJavascriptStep(). It seems it should be possible to make this more universally usable by making a few modifications.

  • It would be handy to always return the tags for the scenarios as well as the features. To make it clear this works not only for scenario tags I would rename this from ScenarioTagTrait to just TagTrait.
  • In addition to ::registerScenario() we can implement a ::registerFeature() method that keeps track of the current feature, and a ::getFeature() method to return it.
  • ::getCurrentScenarioTags() could be renamed to ::getTags() and doesn't need a StepScope passed into it any more. It can instead call ::getFeature().
  • Since most of the time the developer would be interested whether a particular tag is present, it would be a nice addition to add a ::hasTag(string $tag): bool method.
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

1 participant