-
-
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
[Core] Add StepDefinedEvent #1634
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Bit light on the tests so far.
We do have a memory leak. Lambda step definitions internally have a reference to their closure via Java8StepDefinition.body
. Normally this would be GC'd when the world is disposed of. However because we now push these step definitions onto the event bus this is no longer guaranteed. For instance, the canonical order event bus will hold on to all of them.
Ideally when removing the scenario scoped step definitions from the glue, we also remove their reference to the world.
It would be okay to add extra methods to StepDefinition
, the interface is not part of the public API, but I would prefer deprecating isScenarioScoped
in favor of an ScenarioScoped
interface that implements a disposeScenarioScope
method.
Hmm; trying to see if I understand you correctly; You want to (for instance) add a I'll be off for a few days, so will only be able to pick this up on the weekend.. |
As for the test coverage; Agree it's "parse". Functionally the only new line is: |
I was thinking of an integration test that creates a backend with 2 steps. Then run two scenarios with those two steps and check that we see 3 events emitted. There is utility class that makes it relatively easy to setup. But I'll have to check.
Exactly. |
For testing this functionality you can find some examples in
|
@mpkorstanje Thanks for the hint on testing. I'm still having some trouble filling in the blank here: I've added ScenarioScoped changes in 81f2c98 , I hope that's what you intended! |
A mocked step definition will do. As long as it |
Hmm; Looked into it again, but really stuck on the |
I've pushed a commit. It's a bit of a hack job but should get the point across. |
I should look into making some proper test implementations of the components I just mocked. |
Awesome, thanks! Had been eyeing the |
Its good as is. But I am going to try and sneak in a redactor or two. There is an emerging pattern here that calls for some reusable test components. You know the ratchet mechanism bring and keep quality up. May take a bit of time. It's been busy since we last spoke. There is less time for OSS now. |
Ok thanks for helping out; If I can help in any way let me know; all the best there! Miss working together in Amsterdam.. :) |
Hi @timtebeek, Thanks for your making your first contribution to Cucumber, and welcome to the Cucumber committers team! You can now push directly to this repo and all other repos under the cucumber organization! 🍾 In return for this generous offer we hope you will:
On behalf of the Cucumber core team, |
Cheers. No worries! |
Awesome, great to see this merged! I'll update my unused steps plugin blog post to include these Java 8 steps. Should I start a PR to contribute that as well? It's small, has no dependencies and could be useful plus serve as example. |
Would not mind seeing it. Though the json format is problematic. Almost impossible to evolve on. Perhaps we can have a look at that. |
## Summary Adds a plugin to find and report on unused steps. ## Details As discussed in #1634 it uses the new StepDefinedEvent to locate all registered steps, and prints a summary of unused steps to the argument file. ## Motivation and Context Allows to easily find unused steps, which might be indicative of removed functionality or missed test coverage.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
Adds a
StepDefinedEvent
to replace theStepDefinitionReporter
plugin interface.Details
Publish an event from
Glue.addStepDefinition
, asRunner.reportStepDefinitions
is called before step definition classes are instantiated, which fails to pick up on lambda based steps.Motivation and Context
Provide an event to listen for steps being registered, so all steps registrations are available, instead of only the annotation based step definitions.
#1633
How Has This Been Tested?
Not yet; Change seems small.
Types of changes
Checklist: