Class: Rutema::Runners::Default

Inherits:
Object
  • Object
show all
Includes:
Messaging
Defined in:
lib/rutema/core/runner.rb

Overview

The default test runner

Direct Known Subclasses

NoOp

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Messaging

#error, #message

Constructor Details

#initialize(context, queue) ⇒ Default

Returns a new instance of Default.



14
15
16
17
18
19
20
21
# File 'lib/rutema/core/runner.rb', line 14

def initialize(context, queue)
  @setup = nil
  @teardown = nil
  @context = context || {}
  @queue = queue
  @number_of_runs = 0
  @cleanup_blocks = []
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



11
12
13
# File 'lib/rutema/core/runner.rb', line 11

def context
  @context
end

#setupObject

Returns the value of attribute setup.



12
13
14
# File 'lib/rutema/core/runner.rb', line 12

def setup
  @setup
end

#teardownObject

Returns the value of attribute teardown.



12
13
14
# File 'lib/rutema/core/runner.rb', line 12

def teardown
  @teardown
end

Instance Method Details

#run(spec, is_special = false) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/rutema/core/runner.rb', line 23

def run(spec, is_special = false)
  @context["spec_name"] = spec.name
  steps = []
  run_status = :success
  state = { "start_time" => Time.now, "sequence_id" => @number_of_runs, :test => spec.name }
  message(:test => spec.name, :text => "started")
  if @setup
    message(:test => spec.name, :text => "setup")
    run_status, steps = execute_and_collect_state("_setup_", @setup.scenario, true, run_status, steps)
  end
  if run_status == :error
    message(:test => spec.name, "number" => 0, "status" => :error, "out" => "Setup failed", "err" => "", "duration" => 0)
  else
    message(:test => spec.name, :text => "running")
    run_status, steps = execute_and_collect_state(spec.name, spec.scenario, is_special, run_status, steps)
  end
  @context["rutema_status"] = run_status
  if @teardown
    message(:test => spec.name, :text => "teardown")
    run_status, steps = execute_and_collect_state("_teardown_", @teardown.scenario, true, run_status, steps)
  end
  wrap_up_execution(run_status, steps, spec, state)
ensure
  ensure_cleanup_on_exception
end