Repository navigation
Register and filter glue classes - #3120
Conversation
b03dd28 to
c3ddc6f
Compare
31fe2f4 to
be1b4dd
Compare
|
Regarding ChatGPT divination: I would not buy the list and frequency as-is, of course. We all know that the provided patterns and frequencies are invented, but it's a plausible answer, potentially correct, but potentially wrong. |
|
Ah. I see. I was hoping you'd have a codebase you could grep through for glue class names. Or really anything that contains |
|
I built a Python script to build the frequency based on GitHub Search results (with GitHub Copilot help). These are the results: So to summarize:
Note that these figures are sorted the same as the "hallucinated" ChatGPT answer. Maybe by chance? (or is this a confirmation biais?) Limitations:
See source code When working on the repos from Cucumber user only, the results are a bit different: To pass the 1000 result limit, Copilot suggests to aggregate the result on a list of reference repos (which also guarantee the result quality). But then which repos need to be chosen? So in the end, you end up with true number (not hallucinations), but still biased by the repos that are selected by you or by GitHub Search.... Thus I don't know whether we are in a better position or not to decide...😅 |
Ideally? The ones you contribute to. Don't you have work repo's you can query? 😄 |
I think in the end one should choose whats reasonable / workable ... trying to fit everyone's need will likely fail and it is the projects privilege to decide and users can either adapt to such common standard or simply reconfigure. I would more go the opposite: What should we choose that likely not matches something else, so |
I'm certainly not going to be able to make everyone happy. I know that there is no perfect solution. But before picking a good enough default (if any) I'd like to have a better idea of what people call their step definition classes in the real world in projects they use. Thinking about the problem, I'd like to do is come up with a set of conventional suffixes that cover nearly all use cases and then one extra suffix to catch everything else. For example We can then inform users that they can either configure the property or rename their classes to follow the conventional names.
Good point. |
|
What about defining a single standard like |
That's a good possibility too. |
656f5f6 to
441888e
Compare
|
Having thought about the default include pattern problem. Ideally when starting Cucumber JVM, all step definitions, hooks, ect would have been places in classes with a well known suffix. Unfortunately that ship sailed 14 years ago. Setting a default filter now would require that users either rename all their glue code to match the pattern or working out what the pattern should be. Renaming the glue code might be difficult. There seems to be a tendency for people to package step definitions rather APIs into libraries - I don't understand why, but here we are. Likewise working out what all the glue classes are will be difficult as it can be anything on the classpath. Then keeping in mind that v8 will require Java 17+ I don't want to increase the migration burden any more than strictly necessary. Another angle to consider is the typical user of Cucumber JVM. While I reckon most people who've commented on this issue know their way around this isn't the case for every one using Cucumber. So it is sensible to ensure Cucumber works out of the box. Even if this is a little bit slower. |
🤔 What's changed?
Adds supports for registering individual glue classes via the
cucumber.glue.classesproperty or the--glue-classesCLI option.Additionally, supports filtering glue classes by name when scanning the class-path via the
cucumber.glue.{included,excluded}-class-name-patternproperties and--glue-{included,excluded}-class-name-patternCLI options.Only classes that are included by one of the include patterns and not excluded by any of the exclude patterns will be loaded during classpath scanning. This should speed up Cucumber significantly. The filters are not applied against classes that registered explicitly.
No include pattern is configured by default. Cucumber-JVM has been around for 14 years now and it would be quite complicated for existing implementations to either rename their glue classes to fit the existing pattern, or work out a pattern that matches existing classes.
To facilitate registering and filtering glue classes the
Backendnow has a newloadGlue(Glue glue, GlueDiscoveryRequest request)method. With theGlueDiscoveryRequestcontaining a collection of what exactly should be discovered. Currently only classes and URIs are supported but this can be trivially expanded to include packages, modules, ect.⚡️ What's your motivation?
Closes: #3118
Closes: #3137
🏷️ What kind of change is this?
📋 Checklist: