class Cucumber::Runtime
Attributes
configuration[R]
results[R]
support_code[R]
Public Class Methods
new(configuration = Configuration.default)
click to toggle source
# File lib/cucumber/runtime.rb, line 47 def initialize(configuration = Configuration.default) @configuration = Configuration.new(configuration) @support_code = SupportCode.new(self, @configuration) @results = Formatter::LegacyApi::Results.new end
Public Instance Methods
begin_scenario(scenario)
click to toggle source
# File lib/cucumber/runtime.rb, line 96 def begin_scenario(scenario) @support_code.fire_hook(:begin_scenario, scenario) end
configure(new_configuration)
click to toggle source
Allows you to take an existing runtime and change its configuration
# File lib/cucumber/runtime.rb, line 54 def configure(new_configuration) @configuration = Configuration.new(new_configuration) @support_code.configure(@configuration) end
doc_string(string_without_triple_quotes, content_type='', line_offset=0)
click to toggle source
Returns Ast::DocString for string_without_triple_quotes
.
# File lib/cucumber/runtime.rb, line 110 def doc_string(string_without_triple_quotes, content_type='', line_offset=0) location = Core::Ast::Location.of_caller Core::Ast::DocString.new(string_without_triple_quotes, content_type, location) end
dry_run?()
click to toggle source
# File lib/cucumber/runtime.rb, line 76 def dry_run? @configuration.dry_run? end
end_scenario(scenario)
click to toggle source
# File lib/cucumber/runtime.rb, line 100 def end_scenario(scenario) @support_code.fire_hook(:end_scenario) end
failure?()
click to toggle source
# File lib/cucumber/runtime.rb, line 222 def failure? if @configuration.wip? summary_report.test_cases.total_passed > 0 else summary_report.test_cases.total_failed > 0 || summary_report.test_steps.total_failed > 0 || (@configuration.strict? && (summary_report.test_steps.total_undefined > 0 || summary_report.test_steps.total_pending > 0)) end end
features_paths()
click to toggle source
# File lib/cucumber/runtime.rb, line 72 def features_paths @configuration.paths end
load_programming_language(language)
click to toggle source
# File lib/cucumber/runtime.rb, line 59 def load_programming_language(language) @support_code.load_programming_language(language) end
run!()
click to toggle source
# File lib/cucumber/runtime.rb, line 63 def run! load_step_definitions fire_after_configuration_hook self.visitor = report receiver = Test::Runner.new(report) compile features, receiver, filters end
scenarios(status = nil)
click to toggle source
# File lib/cucumber/runtime.rb, line 80 def scenarios(status = nil) @results.scenarios(status) end
steps(status = nil)
click to toggle source
# File lib/cucumber/runtime.rb, line 84 def steps(status = nil) @results.steps(status) end
unknown_programming_language?()
click to toggle source
# File lib/cucumber/runtime.rb, line 104 def unknown_programming_language? @support_code.unknown_programming_language? end
unmatched_step_definitions()
click to toggle source
# File lib/cucumber/runtime.rb, line 88 def unmatched_step_definitions @support_code.unmatched_step_definitions end
Private Instance Methods
create_formatter(factory, path_or_io, options)
click to toggle source
# File lib/cucumber/runtime.rb, line 205 def create_formatter(factory, path_or_io, options) if !legacy_formatter?(factory) out_stream = Cucumber::Formatter::Io.ensure_io(path_or_io) return factory.new(@configuration.with_options(out_stream: out_stream)) end results = Formatter::LegacyApi::Results.new runtime_facade = Formatter::LegacyApi::RuntimeFacade.new(results, @support_code, @configuration) formatter = factory.new(runtime_facade, path_or_io, options) Formatter::LegacyApi::Adapter.new( Formatter::IgnoreMissingMessages.new(formatter), results, @support_code, @configuration) end
event_bus_report()
click to toggle source
# File lib/cucumber/runtime.rb, line 191 def event_bus_report @event_bus_report ||= Formatter::EventBusReport.new(@configuration) end
fail_fast_report()
click to toggle source
# File lib/cucumber/runtime.rb, line 195 def fail_fast_report @fail_fast_report ||= Formatter::FailFast.new(@configuration) end
feature_files()
click to toggle source
# File lib/cucumber/runtime.rb, line 129 def feature_files filespecs.files end
features()
click to toggle source
# File lib/cucumber/runtime.rb, line 122 def features @features ||= feature_files.map do |path| source = NormalisedEncodingFile.read(path) Cucumber::Core::Gherkin::Document.new(path, source) end end
filespecs()
click to toggle source
# File lib/cucumber/runtime.rb, line 133 def filespecs @filespecs ||= FileSpecs.new(@configuration.feature_files) end
filters()
click to toggle source
# File lib/cucumber/runtime.rb, line 233 def filters tag_expressions = @configuration.tag_expressions name_regexps = @configuration.name_regexps tag_limits = @configuration.tag_limits [].tap do |filters| filters << Filters::Randomizer.new(@configuration.seed) if @configuration.randomize? 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::Quit.new filters << Filters::ActivateSteps.new(@support_code) @configuration.filters.each do |filter| filters << filter end 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) # need to do this last so it becomes the first test step filters << Filters::PrepareWorld.new(self) end end end
fire_after_configuration_hook()
click to toggle source
# File lib/cucumber/runtime.rb, line 117 def fire_after_configuration_hook #:nodoc @support_code.fire_hook(:after_configuration, @configuration) end
formatters()
click to toggle source
# File lib/cucumber/runtime.rb, line 199 def formatters @formatters ||= @configuration.formatter_factories { |factory, path_or_io, options| create_formatter(factory, path_or_io, options) } end
legacy_formatter?(factory)
click to toggle source
# File lib/cucumber/runtime.rb, line 218 def legacy_formatter?(factory) factory.instance_method(:initialize).arity > 1 end
load_step_definitions()
click to toggle source
# File lib/cucumber/runtime.rb, line 259 def load_step_definitions files = @configuration.support_to_load + @configuration.step_defs_to_load @support_code.load_files!(files) end
log()
click to toggle source
# File lib/cucumber/runtime.rb, line 264 def log Cucumber.logger end
report()
click to toggle source
# File lib/cucumber/runtime.rb, line 180 def report return @report if @report reports = [summary_report, event_bus_report] + formatters reports << fail_fast_report if @configuration.fail_fast? @report ||= Formatter::Fanout.new(reports) end
summary_report()
click to toggle source
# File lib/cucumber/runtime.rb, line 187 def summary_report @summary_report ||= Core::Report::Summary.new end