-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Make it possible to use Scenario
without a hook
#2903
Comments
Scenario.attach
without a hookScenario
without a hook
A wrapper/proxy class at runtime for the desired class ? |
I'm not sure how that would work, or provide a solution. But if you want to try something out, do have a look at |
Hi every one. I'm also in need of this solution. I have a suggestion of how it could be. What if the method signature could be optionally like this:
So PickleStepDefinitionMatch.java could allow cucumber-jvm/cucumber-core/src/main/java/io/cucumber/core/runner/PickleStepDefinitionMatch.java Line 40 in d64310f
In such cases, we would add the Scenario to the
Please let me know your thoughts. |
🤔 What's the problem you're trying to solve?
Currently when using a
Scenario
to attach file or log information to a report it is necessary to use a before hook to get the scenario object:This is quite cumbersome.
✨ What's your proposed solution?
When executing a step definition, Cucumber knows what the currently active scenario is. So we can in theory use something like
Or with a static import.
Cucumber would internally use a
ThreadLocal
to store the current active test case. This does come with the problem that it may be invoked on a different thread by accident (e.g. when using Awaitility) but with a clear error message I reckon the worst of this can be avoided.⛏ Have you considered any alternatives or workarounds?
No response
📚 Any additional context?
This will be required once cucumber/compatibility-kit#83 is resolved to pass the acceptance test (or some filtering to ignore these extra messages).
The text was updated successfully, but these errors were encountered: