class Cucumber::Runtime
Attributes
Public Class Methods
Source
# File lib/cucumber/runtime.rb, line 56 def initialize(configuration = Configuration.default) @configuration = Configuration.new(configuration) @support_code = SupportCode.new(self, @configuration) end
Public Instance Methods
Source
# File lib/cucumber/runtime.rb, line 94 def begin_scenario(test_case) @support_code.fire_hook(:begin_scenario, test_case) end
Source
# File lib/cucumber/runtime.rb, line 62 def configure(new_configuration) @configuration = Configuration.new(new_configuration) @support_code.configure(@configuration) end
Allows you to take an existing runtime and change its configuration
Source
# File lib/cucumber/runtime.rb, line 104 def doc_string(string_without_triple_quotes, content_type = '', _line_offset = 0) Core::Test::DocString.new(string_without_triple_quotes, content_type) end
Returns Ast::DocString for string_without_triple_quotes.
Source
# File lib/cucumber/runtime.rb, line 98 def end_scenario(_scenario) @support_code.fire_hook(:end_scenario) end
Source
# File lib/cucumber/runtime.rb, line 108 def failure? if @configuration.wip? summary_report.test_cases.total_passed.positive? else !summary_report.ok?(@configuration.strict) || !global_hooks_summary_report.ok? end end
Source
# File lib/cucumber/runtime.rb, line 82 def features_paths @configuration.paths end
Source
# File lib/cucumber/runtime.rb, line 67 def run! @configuration.notify :envelope, Cucumber::Messages::Envelope.new( meta: MetaMessageBuilder.build_meta_message ) load_step_definitions fire_install_plugin_hook create_formatters receiver = Test::Runner.new(@configuration.event_bus) compile features, receiver, filters, @configuration.event_bus fire_after_all_hook unless dry_run? @configuration.notify :test_run_finished, !failure? end
Source
# File lib/cucumber/runtime.rb, line 90 def unmatched_step_definitions @support_code.unmatched_step_definitions end
Private Instance Methods
Source
# File lib/cucumber/runtime.rb, line 252 def accept_options?(factory) factory.instance_method(:initialize).arity > 1 end
Source
# File lib/cucumber/runtime.rb, line 239 def create_formatter(factory, formatter_options, path_or_io) if accept_options?(factory) return factory.new(@configuration, formatter_options) if path_or_io.nil? factory.new(@configuration.with_options(out_stream: path_or_io), formatter_options) else return factory.new(@configuration) if path_or_io.nil? factory.new(@configuration.with_options(out_stream: path_or_io)) end end
Source
# File lib/cucumber/runtime.rb, line 199 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) } # `summary_report` and `global_hooks_summary_report` are used to determine the exit code summary_report global_hooks_summary_report fail_fast_report if @configuration.fail_fast? publish_banner_printer unless @configuration.publish_quiet? end
Source
# File lib/cucumber/runtime.rb, line 224 def fail_fast_report @fail_fast_report ||= Formatter::FailFast.new(@configuration) end
Source
# File lib/cucumber/runtime.rb, line 151 def feature_files filespecs.files end
Source
# File lib/cucumber/runtime.rb, line 127 def features @features ||= feature_files.map do |path| source = NormalisedEncodingFile.read(path) @configuration.notify :gherkin_source_read, path, source # TODO: When core is v17+ switch the below code out to the following # Cucumber::Core::Gherkin::Document.new(path, source).tap do |document| # @configuration.notify(:envelope, document.to_envelope) # end to_envelope = Cucumber::Messages::Envelope.new( source: Cucumber::Messages::Source.new( uri: path, data: source, media_type: 'text/x.cucumber.gherkin+plain' ) ) @configuration.notify(:envelope, to_envelope) Cucumber::Core::Gherkin::Document.new(path, source) end end
Source
# File lib/cucumber/runtime.rb, line 155 def filespecs @filespecs ||= FileSpecs.new(@configuration.feature_files) end
Source
# File lib/cucumber/runtime.rb, line 257 def filters tag_expressions = @configuration.tag_expressions name_regexps = @configuration.name_regexps tag_limits = @configuration.tag_limits [].tap do |filters| filters << Filters::TagLimits.new(tag_limits) if tag_limits.any? filters << Cucumber::Core::Test::TagFilter.new(tag_expressions) filters << Cucumber::Core::Test::NameFilter.new(name_regexps) filters << Cucumber::Core::Test::LocationsFilter.new(filespecs.locations) filters << Filters::Randomizer.new(@configuration.seed) if @configuration.randomize? filters << Filters::Reverser.new if @configuration.reverse_order? # TODO: can we just use Glue::RegistryAndMore's step definitions directly? step_match_search = StepMatchSearch.new(@support_code.registry.method(:step_matches), @configuration) filters << Filters::ActivateSteps.new(step_match_search, @configuration) @configuration.filters.each { |filter| filters << filter } unless configuration.dry_run? filters << Filters::ApplyAfterStepHooks.new(@support_code) filters << Filters::ApplyBeforeHooks.new(@support_code) filters << Filters::ApplyAfterHooks.new(@support_code) filters << Filters::ApplyAroundHooks.new(@support_code) filters << Filters::BroadcastTestRunStartedEvent.new(@configuration) filters << Filters::FireBeforeAllHooks.new(@support_code) filters << Filters::Quit.new end filters << Filters::BroadcastTestCaseReadyEvent.new(@configuration) unless configuration.dry_run? filters << Filters::Retry.new(@configuration) # need to do this last so it becomes the first test step filters << Filters::PrepareWorld.new(self) end end end
Source
# File lib/cucumber/runtime.rb, line 232 def formatters @formatters ||= @configuration.formatter_factories do |factory, formatter_options, path_or_io| create_formatter(factory, formatter_options, path_or_io) end end
Source
# File lib/cucumber/runtime.rb, line 220 def global_hooks_summary_report @global_hooks_summary_report ||= Formatter::GlobalHooksSummary.new(@configuration) end
Source
# File lib/cucumber/runtime.rb, line 293 def load_step_definitions files = @configuration.support_to_load + @configuration.step_defs_to_load @support_code.load_files!(files) end
Source
# File lib/cucumber/runtime.rb, line 212 def message_builder @message_builder ||= Formatter::MessageBuilder.new(@configuration) end
Source
# File lib/cucumber/runtime.rb, line 298 def registry_wrapper Cucumber::Glue::RegistryWrapper.new(@support_code.registry) end
Source
# File lib/cucumber/runtime.rb, line 216 def summary_report @summary_report ||= Core::Report::Summary.new(@configuration.event_bus) end