Skip to content

Commit 7be8c2d

Browse files
committed
Allow ColorAware, StrictAware and EventListener as mixins Plugin
1 parent 56acfc3 commit 7be8c2d

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

Diff for: core/src/main/java/cucumber/api/Plugin.java

+8
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@
2929
* </ul>
3030
* <p>
3131
* To make the parameter optional the plugin must also have a public default constructor.
32+
* <p>
33+
* Plugins may also implement one of these interfaces:
34+
* <ul>
35+
* <li>{@link cucumber.api.formatter.ColorAware}</li>
36+
* <li>{@link cucumber.api.formatter.StrictAware}</li>
37+
* <li>{@link cucumber.api.event.EventListener}</li>
38+
* </ul>
39+
* <p>
3240
*/
3341
public interface Plugin {
3442
}

Diff for: core/src/main/java/cucumber/api/event/EventListener.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package cucumber.api.event;
22

33
/**
4-
* This is the interface you should implement if you want your own custom
5-
* formatter.
4+
* This is the interface you should implement if your plugin listens to cucumber execution events
65
*/
76
public interface EventListener {
87

Diff for: core/src/main/java/cucumber/runtime/DefaultSummaryPrinter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
import cucumber.api.SummaryPrinter;
44
import cucumber.api.event.EventHandler;
5+
import cucumber.api.event.EventListener;
56
import cucumber.api.event.EventPublisher;
67
import cucumber.api.event.TestRunFinished;
78
import cucumber.api.formatter.ColorAware;
8-
import cucumber.api.formatter.Formatter;
99
import cucumber.api.formatter.StrictAware;
1010

1111
import java.io.PrintStream;
1212
import java.util.List;
1313

14-
public class DefaultSummaryPrinter implements SummaryPrinter, ColorAware, StrictAware, Formatter {
14+
public class DefaultSummaryPrinter implements SummaryPrinter, ColorAware, StrictAware, EventListener {
1515

1616
private final Stats stats = new Stats();
1717
private final UndefinedStepsTracker undefinedStepsTracker = new UndefinedStepsTracker();

Diff for: core/src/main/java/cucumber/runtime/RuntimeOptions.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import cucumber.api.Plugin;
44
import cucumber.api.SnippetType;
55
import cucumber.api.StepDefinitionReporter;
6+
import cucumber.api.event.EventListener;
67
import io.cucumber.datatable.DataTable;
78
import cucumber.api.event.TestRunStarted;
89
import cucumber.api.formatter.ColorAware;
@@ -381,8 +382,8 @@ private void setStrictOnStrictAwarePlugins(Object plugin) {
381382
}
382383
}
383384

384-
private void setEventBusFormatterPlugins(Object plugin) {
385-
if (plugin instanceof Formatter && bus != null) {
385+
private void setEventBusOnEventListenerPlugins(Object plugin) {
386+
if (plugin instanceof EventListener && bus != null) {
386387
Formatter formatter = (Formatter) plugin;
387388
formatter.setEventPublisher(bus);
388389
}
@@ -408,7 +409,7 @@ public void addPlugin(Plugin plugin) {
408409
plugins.add(plugin);
409410
setMonochromeOnColorAwarePlugins(plugin);
410411
setStrictOnStrictAwarePlugins(plugin);
411-
setEventBusFormatterPlugins(plugin);
412+
setEventBusOnEventListenerPlugins(plugin);
412413
}
413414

414415
public List<Pattern> getNameFilters() {

0 commit comments

Comments
 (0)