Discussion:
[Cucumber] [Cucumber-jvm][JUnit] Event Handling
Add Reply
Jaysef
2017-11-26 09:32:27 UTC
Reply
Permalink
Raw Message
Hi everyone,

Does anyone know how events work ? How do I handle them ?

The new version of cucumber came out with new event model (
https://cucumber.io/blog/2017/08/29/announcing-cucumber-jvm-2-0-0 ) and
different types of events (
https://github.com/cucumber/cucumber-jvm/tree/master/core/src/main/java/cucumber/api/event
).

I read the event protocol ( https://docs.cucumber.io/event-protocol/ ), but
i still don't understand how to implement any handler (or listener ?).

With a previous version of cucumber, someone implements his CustomCucumber
class adding his CustomListener in that class (
). So I try the same
with the new version of Cucumber, and I see that in the listener i can
override methods like "testRunStarted" or "testRunFinished" which has the
same name of some of the events, but there are no other methods
corresponding the rest of the new events.

I'm sure i'm doing things wrong, so any help is appreciated, thanks
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
MP Korstanje
2017-11-30 19:28:24 UTC
Reply
Permalink
Raw Message
JUnit events are not the same as the cucumber events and I would not
recommend following the listener approach from the Youtube video. While the
Cucumber class is part of the public API is hasn't been designed for
extension. The the possibility to extend the junit runner might be
deprecated and eventually removed all together in the future.

The recommended way to observe the cucumber process is by using a plugin.
And you can handle events by writing a custom plugin that implements
Formatter. You can then activate this plugin by using the `--plugin
com.example.package.of.MyCustomFormatter`. For an example see the
JSONFormatter.
<https://github.com/cucumber/cucumber-jvm/blob/master/core/src/main/java/cucumber/runtime/formatter/JSONFormatter.java>

Goodluck,
RIen


On Wednesday, November 29, 2017 at 10:48:38 AM UTC+1, Jaysef wrote:
Hi everyone,


Does anyone know how events work ? How do I handle them ?


The new version of cucumber came out with new event model (
https://cucumber.io/blog/2017/08/29/announcing-cucumber-jvm-2-0-0 ) and
different types of events (
https://github.com/cucumber/cucumber-jvm/tree/master/core/src/main/java/cucumber/api/event
).


I read the event protocol ( https://docs.cucumber.io/event-protocol/ ), but
i still don't understand how to implement any handler (or listener ?).


With a previous version of cucumber, someone implements his CustomCucumber
class adding his CustomListener in that class (
http://youtu.be/iudFtypIMF0 ). So I try the same
with the new version of Cucumber, and I see that in the listener i can
override methods like "testRunStarted" or "testRunFinished" which has the
same name of some of the events, but there are no other methods
corresponding the rest of the new events.


I'm sure i'm doing things wrong, so any help is appreciated, thanks
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...