-
-
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
Improve plugin and formatter structure #1253
Conversation
The following improvements have been made 1. All plugin interfaces (Formatter, StepDefinitionReporter, SummaryPrinter) now extend the Plugin interface. 2. Updated documentation to make it clear what each plugin does. 3. All plugins have been made final. They are not designed for extension. 4. Moved android formatters into formatter package to limit visibility of TestSourcesModel. 5. Classes in runtime/android have been made final and have had their visibility reduced. They are not designed for extension.
d32558a
to
d115e13
Compare
Hello @mpkorstanje , this PR breaks a whole lot of things with the Extend report plugin (https://github.com/sitture/cucumber-jvm-extentreport). I haven't taken an in depth look, since this is a library that I've only noticed yesterday, but it breaks here: because it's using the I've had a look at the current Formatters in this cucumber-jvm project (such as JSONFormatter.java, but they all seem to be using this At first sight it seems reasonable that one should be able to create a Formatter in a similar way that the 'standard' formatters are programmed? Any thoughts? Related issue on the Note: I'm not the developer of the mentioned formatter, so I don't know all the ins-and-outs. |
Hey Auke, it is generally speaking a bad practice to depend on the implementation details of another project. Anything outside of the For a longer term fix it might be a good strategy to add the AST-like features to Gherkin. |
Of course I understand that you should depend on api only, but I was confused by this TestSourcesModel which every formatter seem to use. Again, I'm not very familiar with the complete project, but it seemed sort of logical to me that knowing whether or not a step was a background step was included as part of the API. I.e. So my question was more or less in that direction, or thinking that TestSourcesModel should have been part of the API. Since most 'standard' formatters (those inside |
Cucumber has been abstracted away from from gherkin. It operates on pickles rather then steps. Background steps and other steps are all identical in cucumber. As a result any formatter that wants to work with gherkin has to match line numbers back to the AST. If you need this it might be useful to create a PR against the gherkin repository and add it in the line number lookup there. |
Another way to put it is that Things that are exported as part of the API are in Martin Fowler's terms "Published Interfaces". One of Martin Fowler's guidelines for Published Interfaces is "Publish as little as you can as late as you can". "As late as you can" so that you have had the time to refine the interface to be published. TestSourcesModel is far from being as refined to be part of a "Published Interface". Secondly as mentioned in previous comment, the proper place for a support library for lookup of Gherkin AST data, is most likely a sub-repo of https://github.com/cucumber/cucumber so it can be used by all Cucumber implementations and not only Cucumber-JVM (maybe rather the event-protocol sub-repo rather than the gherkin sub-repo). |
First off: just wanted to let you guys know that I appreciate the work you're doing here. This is not meant as pure criticism, but simply trying to (1) understand it, (2) give some (hopefully) constructive feedback.
It seems to me that this is valid mainly from the point of view of executing the steps. I understand that you don't really care about where it was coming from. However, judging from the fact that the formatters used in the creation of reports ( So I've read up a bit on the
Which makes perfect sense, but - assuming that you want to leverage this abstraction for your Basically I'm wondering
In general it would be nice for the 'native' formatters ( |
The pickles abstraction is designed for execution only. It is suitable for simple formatting where the format doesn't attempt to replicate the input format. For example, progress bar, counting success/failure etc. In the past the same data structure was used to represent the AST and the results. This led to very complicated internals, so we decided to split it. If you want to generate a report that reflects the input, you have to consume The The design is based on event sourcing, and by consuming relevant events you can construct a variety of output formats. The long term goal is to expose all of these events as a stream of ndjson and delegate formatting to a separate process. For example, there would be a We've yet to write any of those formatters. |
Thanks for taking the time to explain, this makes sense. I'm slightly sceptical about the out of process external reporting. I might very well misunderstand the exact details, but I do understand how this would lighten the burden over several languages. However I also expect Maven or Gradle users to just be able to have a single plugin that does everything. Having an out of process extra process during a Maven build seems difficult to achieve, but maybe I'm totally wrong there :-) Thanks. |
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
The following improvements have been made
All plugin interfaces (Formatter, StepDefinitionReporter,
SummaryPrinter) now extend the Plugin interface.
Updated documentation to make it clear what each plugin does.
All plugins have been made final. They are not designed for
extension.
Moved android formatters into formatter package to limit visibility
of TestSourcesModel.
Classes in runtime/android have been made final and have had their
visibility reduced. They are not designed for extension.
Motivation and Context
Discussion on Slack showed that TestSourcesModel was still available for use. TestSourcesModel is not part of the API so its use should be discouraged. While doing so the fact that none of the plugins actually implemented the plugin interface bugged me to no end.
How Has This Been Tested?
Ran the tests, fixed the tests.
Types of changes
The changes to the api should be backwards compatible as an interface has been added to the interfaces that were already used. It is possible that plugin used none of these interfaces, but such a plugin would have no effect.