-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
custom formatter #309
custom formatter #309
Conversation
Remove docs dir, since that's not how project documentation seems to be done.
ping @jbpros |
👍 |
So, who are we waiting for? |
Just waiting on some eyes from @jbpros |
My one note of caution with this is the experience I've had with having 3rd party code depending on the Ruby Cucumber's original formatter API, which was very, very complex. I can't see from this PR what the formatter API is, but just bear in mind that once it's out in the wild you'll find it much harder to change it. So make sure you're happy with it now. |
heh yeah it is not exactly "simple" to use right now... but..... we can follow semver when we change it so it should not be such a big issue. |
This is great stuff! Thanks @samccone. Also, thanks @mattwynne for the note of caution, it makes sense. 3rd-parties should rely on the listener API, based on events, that allows for pretty good decoupling between the internals of Cucumber and formatters/listeners. I think this PR lacks two things:
|
Could 1&2 not be combined @jbpros? i.e. use the Gherkin scenario as the documentation? Crazy talk, I know... |
@samccone Can I help with the docs or gherkin? |
@samccone this looks pretty good as is but is still missing documentation and feature tests. I can help with those if you are okay with me pushing to your branch. |
@@ -35,30 +35,25 @@ describe("Cucumber.Cli", function () { | |||
describe("when the help is requested", function () { | |||
beforeEach(function () { | |||
configuration.isHelpRequested.andReturn(true); | |||
cli.run(callback); |
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.
Please revert the changes to this file as they are unrelated
I second @charlierudolph on scenarios and docs for this. |
@charlierudolph @jbpros I added documentation to Do we need to expand these, or add other documentation elsewhere? |
The documentation I'm talking about is how to build a formatter.
|
Sounds so obvious when you say it. 😞 Is there a single point of reference for options, or do we need to infer them from the code, e.g. formatter.js, summary_formatter.js and the other listeners? The API seems to be handlers for the set of events emitted during execution, specified in events.js. All of the stock formatters seem to provide methods like |
The options for the constructor come from here. The coffeescript snippets option needs to go away. I think we probably want to suggest inheriting from Cucumber.Listener.Formatter. Might be good to just give people a skeleton for a formatter. function MyFormatter(options) {
var Cucumber = require('cucumber');
if (!options)
options = {};
var self = Cucumber.Listener.Formatter(options);
self.handleBeforeFeaturesEvent = function handleBeforeFeaturesEvent(event, callback) {
var features = event.getPayloadItem('features');
callback();
};
self.handleBeforeFeatureEvent = function handleBeforeFeatureEvent(event, callback) {
var feature = event.getPayloadItem('feature');
callback();
};
self.handleBeforeScenarioEvent = function handleBeforeScenarioEvent(event, callback) {
var scenario = event.getPayloadItem('scenario');
callback();
};
self.handleBeforeStepEvent = function handleBeforeStepEvent(event, callback) {
var stepResult = event.getPayloadItem('step');
callback();
};
self.handleStepResultEvent = function handleStepResultEvent(event, callback) {
var stepResult = event.getPayloadItem('stepResult');
callback();
};
self.handleAfterStepEvent = function handleAfterStepEvent(event, callback) {
var step = event.getPayloadItem('step');
callback();
};
self.handleAfterScenarioEvent = function handleAfterScenarioEvent(event, callback) {
var scenario = event.getPayloadItem('scenario');
callback();
};
self.handleAfterFeatureEvent = function handleAfterFeatureEvent(event, callback) {
var feature = event.getPayloadItem('feature');
callback();
};
self.handleAfterFeaturesEvent = function handleAfterFeaturesEvent(event, callback) {
var features = event.getPayloadItem('features');
self.finish(callback);
};
return self;
}
module.exports = MyFormatter; Right now the objects are based on the internals of cucumber and probably need to be wrapped up somewhere so we can offer a more consistent interface as the internals are changing in a big way when we update to gherkin3. Probably need something similar to the wrapper around a scenario that is passed to hooks, for each of the objects. @jbpros what are your thoughts? |
I agree. Event objects shouldn't be exposed to the outside world (the same holds true for event listeners in userland, btw). I'm thinking we could use the simpler emitter API for listeners: function MyFormatter(suite) {
// suite is an emitter instance injected by Cucumber
suite.on('beforeFeature', function (feature) {
// do your stuff
});
suite.on('beforeScenario', function (scenario) {
});
suite.on('afterScenario', function (scenario, result) {
// receives the hypothetical result object
});
suite.on('beforeStep', function (step) {})
suite.on('step', function (step, result) {})
suite.on('afterStep', function (step) {})
// etc.
} This is only a listener. Shouldn't we use the name "listener" instead of "formatter" in this new API? Getting back to the "payload" objects, with such an emitter, each event is accompanied with one or more things and doesn't need a I'm also tempted to rename the events to something like |
FWIW, we've got with |
Any updates on this? |
when will this be working!?!? |
👍 |
@mattwynne any time expectations around this? I need to create TeamCity and AppVeyor formatters for CI. |
What are the next steps @jbpros? Do we still need some docs? Maybe you could help with that @a11smiles? |
@mattwynne I'm available to do so...indeed, what are the next steps @jbpros ? |
@jbpros: Is there any update on this ? Is this available to use ? I see there have been some conflicts. I would like to use this, if this is good to (or as and when) use, please provide link to some finalized documentation. Thanks. |
@kchokhawala this isn't ready. I'm working on some sizable changes to the formatters. Once those are done we can circle back to custom formatters. I'm going to go ahead and close this due to its age. Issue held in #516 |
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. |
Here we are, custom formatters! rebased on top of master, tests passing and docs. Lets ship this sucker!
Via #90
Via #188
Via #215
Via #257