From f40bcc6371bf4a3b97a5f46b0695866847c32fcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Rasmusson?= Date: Fri, 24 Jul 2026 20:41:22 +0200 Subject: [PATCH 1/4] The Formatter::HTML should not inherit from the MessageBuilder * The Runtime creates the MessageBuilder to always output the envelope it creates from event to the event bus. Therefore a formatter only need to listen to the :envelope events on the event bus. --- features/docs/formatters/html.feature | 4 ++++ lib/cucumber/formatter/html.rb | 10 ++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/features/docs/formatters/html.feature b/features/docs/formatters/html.feature index aa4f4fe9a6..16308966cf 100644 --- a/features/docs/formatters/html.feature +++ b/features/docs/formatters/html.feature @@ -19,3 +19,7 @@ Feature: html formatter When I run `cucumber features/my_feature.feature --format html` Then it should fail And output should be html with title "Cucumber" + And the output should contain: + """ + Scenario Outline: a scenario + """ diff --git a/lib/cucumber/formatter/html.rb b/lib/cucumber/formatter/html.rb index 67637518d0..95a87d9d73 100644 --- a/lib/cucumber/formatter/html.rb +++ b/lib/cucumber/formatter/html.rb @@ -2,20 +2,22 @@ require 'cucumber/html_formatter' -require_relative 'message_builder' +require_relative 'io' module Cucumber module Formatter - class HTML < MessageBuilder + class HTML + include Io + def initialize(config) + @config = config @io = ensure_io(config.out_stream, config.error_stream) @html_formatter = Cucumber::HTMLFormatter::Formatter.new(@io) @html_formatter.write_pre_message - super(config) + config.on_event :envelope, &method(:on_envelope) end def on_envelope(event) - super(event) envelope = event.envelope @html_formatter.write_message(envelope) # TODO: Move this conditional logic into the HTML formatter proper From d19f668629831e0727246839dc709ecb624cdae2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Rasmusson?= Date: Mon, 27 Jul 2026 13:06:22 +0200 Subject: [PATCH 2/4] No formatter should inherit from the MessageBuilder --- lib/cucumber/runtime.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/cucumber/runtime.rb b/lib/cucumber/runtime.rb index fd5f1e4233..dbca77ee9c 100644 --- a/lib/cucumber/runtime.rb +++ b/lib/cucumber/runtime.rb @@ -175,8 +175,7 @@ def create_formatters # Define all formatters which are specified via cli options formatters # Define the MessageBuilder formatter - Required until all messages are generated at the source - # Skip when a user formatter already inherits from MessageBuilder (e.g. HTML) to avoid sending every event twice. - message_builder unless formatters.any? { |f| f.is_a?(Formatter::MessageBuilder) } + message_builder # `summary_report` and `global_hooks_summary_report` are used to determine the exit code summary_report global_hooks_summary_report From cb3ea117362d89941b50dbb49b36a651fe8697a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Rasmusson?= Date: Tue, 28 Jul 2026 21:19:38 +0200 Subject: [PATCH 3/4] Create the formatters in the correct order - MessageBuilder first --- lib/cucumber/runtime.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/cucumber/runtime.rb b/lib/cucumber/runtime.rb index dbca77ee9c..9cddf73a69 100644 --- a/lib/cucumber/runtime.rb +++ b/lib/cucumber/runtime.rb @@ -172,13 +172,13 @@ def set_encoding require 'cucumber/core/report/summary' def create_formatters - # Define all formatters which are specified via cli options - formatters - # Define the MessageBuilder formatter - Required until all messages are generated at the source + # Define the MessageBuilder - Required until all messages are generated at the source message_builder # `summary_report` and `global_hooks_summary_report` are used to determine the exit code summary_report global_hooks_summary_report + # Define all formatters which are specified via cli options + formatters fail_fast_report if @configuration.fail_fast? publish_banner_printer unless @configuration.publish_quiet? end From ae86c530c188ba93a5175021dcc0093da70299f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Rasmusson?= Date: Tue, 28 Jul 2026 21:26:37 +0200 Subject: [PATCH 4/4] Update the Changelog.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79e9f1c86f..b38bbd1b6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,9 @@ Please visit [cucumber/CONTRIBUTING.md](https://github.com/cucumber/cucumber/blo logic and some old rspec helper files) - Removed handling of a Ruby 2.1 system error (Minimum Ruby is now 3.2) ([luke-hill](https://github.com/luke-hill)) +### Fixed +- Updated the `html-formatter` to access message stream correctly ([#1899](https://github.com/cucumber/cucumber-ruby/pull/1899)) [brasmusson](https://github.com/brasmusson) + ## [11.1.1] - 2026-06-25 ### Changed - Change to use events to pass the data from "log" and "attach" calls from the step definitions to the formatters. With this the last part of the ancient (pre event) formatter inteface has been removed. ([#1881](https://github.com/cucumber/cucumber-ruby/pull/1881) [brasmusson](https://github.com/brasmusson))