-
-
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
Add afterAll hooks #97
Comments
+1 |
1 similar comment
+1 |
What are all these strange patches that add a single line with a I'm not sure that implementation is complete! |
+1 |
3 similar comments
+1 |
+1 |
+1 |
Any progress on this in the past year? |
While this is not a definitive solution, the recently-added module.exports = function () {
this.registerHandler('AfterFeatures', function (event, callback) {
console.log("finished running scenarios", event);
// do your stuff
callback();
});
};
One potential issue I see (and tested) with this solution is that calling back with an error will not make Cucumber fail the run. @devpaul is that a bug in your opinion? |
@jbpros I believe it should be considered a bug. It doesn't follow convention. |
To me, it wouldn't make sense if an event handler can make the piece of code that triggered it throw an error, that's now how I expect events to work (they listen). Also, the handler does not get the world as a context as reported in #244. Again, from the perspective of it being an event, that makes sense to me. When using it as an AfterAll hook however, this is a serious shortcoming. |
@jbpros This does not help either since a handler registered this way is executed after every feature file. |
Furthermore, the README is completely misleading on the behavior of AfterFeatures:
No, it is not. It is executed after every set of features (=feature file) |
@djungowski no, |
Closing as registerHandler now has full support and the passed function can use any of the available interfaces that steps/hooks use and when passed an error it will throw it and kill the test run. |
In which version is that enhancement? I've tried it in 0.10.4 but it doesn't seem to respond to callback(new Error('foo')). |
In the future please see the changelog. Searching through it, it appears it was added in 1.1.0 |
@charlierudolph Could you tell me how I can use registerHandler using defineSupportCode?
|
Please see the docs for "Event Handlers". There is a link on the README |
Hate to pull this one out of the grave again, but per @charlierudolph's comment, can you clarify the expectation is that passing an error to the registerHandler callback should infact kill the entire test run? In my use case/need, I'd like to fail exclusively the scenario if an error is raised during the AfterScenario hook, but continue the suite after marking that scenario as failed (in the way I can during a step); is this achievable with 1.3.1+? My example usecase would be in the event of failing to tear down mocks generated during the scenario. e: after looking around for some different examples this comment seems to directly answer my question. |
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. |
From #84 (comment).
The text was updated successfully, but these errors were encountered: