Class: Rutema::RunnerMessage

Inherits:
Message
  • Object
show all
Defined in:
lib/rutema/core/framework.rb

Overview

Message container continually being emitted by runners (see Runners module) during test execution

These messages inform about the progress of test execution. Test errors are propagated through instances of this class as well. If it's an engine error (e.g. during parsing), then an ErrorMessage will be used in that case.

Instance Attribute Summary collapse

Attributes inherited from Message

#test, #text, #timestamp

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ RunnerMessage

Initialize a new runner message from data passed in a hash

Additionally to the keys of the Message initializer the following keys of the hash are being utilized:

  • "duration" - the time a test step took for execution
  • "status" - the status of the respective step
  • :timestamp - most often the timestamp of the creation of the message, defaults to Time.now


88
89
90
91
92
93
94
95
96
97
# File 'lib/rutema/core/framework.rb', line 88

def initialize(params)
  super
  @duration = params.fetch("duration", 0)
  @status = params.fetch("status", :none)
  @number = params.fetch("number", 1)
  @out = params.fetch("out", "")
  @err = params.fetch("err", "")
  @backtrace = params.fetch("backtrace", [])
  @is_special = params.fetch("is_special", "")
end

Instance Attribute Details

#durationObject

Returns the value of attribute duration.



77
78
79
# File 'lib/rutema/core/framework.rb', line 77

def duration
  @duration
end

#errObject

Returns the value of attribute err.



77
78
79
# File 'lib/rutema/core/framework.rb', line 77

def err
  @err
end

#is_specialObject

Returns the value of attribute is_special.



77
78
79
# File 'lib/rutema/core/framework.rb', line 77

def is_special
  @is_special
end

#numberObject

Returns the value of attribute number.



77
78
79
# File 'lib/rutema/core/framework.rb', line 77

def number
  @number
end

#outObject

Returns the value of attribute out.



77
78
79
# File 'lib/rutema/core/framework.rb', line 77

def out
  @out
end

#statusObject

Returns the value of attribute status.



77
78
79
# File 'lib/rutema/core/framework.rb', line 77

def status
  @status
end

Instance Method Details

#outputObject



110
111
112
113
114
115
116
# File 'lib/rutema/core/framework.rb', line 110

def output
  msg = ""
  msg << "#{@out}\n" unless @out.empty?
  msg << @err unless @err.empty?
  msg << "\n#{@backtrace.is_a?(Array) ? @backtrace.join("\n") : @backtrace}" unless @backtrace.empty?
  return msg.chomp
end

#to_sObject

Convert the instance to a convenient textual representation



101
102
103
104
105
106
107
108
# File 'lib/rutema/core/framework.rb', line 101

def to_s
  msg = "#{@test}:"
  msg << " #{@timestamp.strftime("%H:%M:%S")} :"
  msg << "#{@text}." unless @text.empty?
  outpt = output
  msg << " Output:\n#{outpt}" unless outpt.empty? || @status != :error
  return msg
end