Class: Cucumber::Runtime

Inherits:
Object
  • Object
show all
Includes:
Core, Formatter::Duration, UserInterface
Defined in:
lib/cucumber/runtime.rb,
lib/cucumber/runtime/step_hooks.rb,
lib/cucumber/runtime/after_hooks.rb,
lib/cucumber/runtime/before_hooks.rb,
lib/cucumber/runtime/support_code.rb,
lib/cucumber/runtime/user_interface.rb,
lib/cucumber/runtime/for_programming_languages.rb

Defined Under Namespace

Modules: UserInterface Classes: AfterHooks, BeforeHooks, ForProgrammingLanguages, NormalisedEncodingFile, StepHooks, SupportCode

Instance Attribute Summary collapse

Attributes included from UserInterface

#visitor

Instance Method Summary collapse

Methods included from UserInterface

#ask, #embed, #puts

Methods included from Formatter::Duration

#format_duration

Constructor Details

#initialize(configuration = Configuration.default) ⇒ Runtime

Returns a new instance of Runtime.



53
54
55
56
57
# File 'lib/cucumber/runtime.rb', line 53

def initialize(configuration = Configuration.default)
  @configuration = Configuration.new(configuration)
  @support_code = SupportCode.new(self, @configuration)
  @results = Formatter::LegacyApi::Results.new
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



47
48
49
# File 'lib/cucumber/runtime.rb', line 47

def configuration
  @configuration
end

#resultsObject (readonly)

Returns the value of attribute results.



47
48
49
# File 'lib/cucumber/runtime.rb', line 47

def results
  @results
end

#support_codeObject (readonly)

Returns the value of attribute support_code.



47
48
49
# File 'lib/cucumber/runtime.rb', line 47

def support_code
  @support_code
end

Instance Method Details

#begin_scenario(test_case) ⇒ Object



98
99
100
# File 'lib/cucumber/runtime.rb', line 98

def begin_scenario(test_case)
  @support_code.fire_hook(:begin_scenario, test_case)
end

#configure(new_configuration) ⇒ Object

Allows you to take an existing runtime and change its configuration



60
61
62
63
# File 'lib/cucumber/runtime.rb', line 60

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) ⇒ Object

Returns Ast::DocString for string_without_triple_quotes.



108
109
110
111
# File 'lib/cucumber/runtime.rb', line 108

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?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/cucumber/runtime.rb', line 82

def dry_run?
  @configuration.dry_run?
end

#end_scenario(_scenario) ⇒ Object



102
103
104
# File 'lib/cucumber/runtime.rb', line 102

def end_scenario(_scenario)
  @support_code.fire_hook(:end_scenario)
end

#failure?Boolean

Returns:

  • (Boolean)


228
229
230
231
232
233
234
# File 'lib/cucumber/runtime.rb', line 228

def failure?
  if @configuration.wip?
    summary_report.test_cases.total_passed > 0
  else
    !summary_report.ok?(@configuration.strict)
  end
end

#features_pathsObject



78
79
80
# File 'lib/cucumber/runtime.rb', line 78

def features_paths
  @configuration.paths
end

#run!Object



66
67
68
69
70
71
72
73
74
75
76
# File 'lib/cucumber/runtime.rb', line 66

def run!
  load_step_definitions
  install_wire_plugin
  fire_after_configuration_hook
  # TODO: can we remove this state?
  self.visitor = report

  receiver = Test::Runner.new(@configuration.event_bus)
  compile features, receiver, filters
  @configuration.notify :test_run_finished
end

#scenarios(status = nil) ⇒ Object



86
87
88
# File 'lib/cucumber/runtime.rb', line 86

def scenarios(status = nil)
  @results.scenarios(status)
end

#steps(status = nil) ⇒ Object



90
91
92
# File 'lib/cucumber/runtime.rb', line 90

def steps(status = nil)
  @results.steps(status)
end

#unmatched_step_definitionsObject



94
95
96
# File 'lib/cucumber/runtime.rb', line 94

def unmatched_step_definitions
  @support_code.unmatched_step_definitions
end