Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions features/docs/formatters/html.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
10 changes: 6 additions & 4 deletions lib/cucumber/formatter/html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions lib/cucumber/runtime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might need re-ordering and going above formatters

# `summary_report` and `global_hooks_summary_report` are used to determine the exit code
summary_report
global_hooks_summary_report
Expand Down