Class: Cucumber::Messages::TestRunFinished

Inherits:
Message
  • Object
show all
Defined in:
lib/cucumber/messages/test_run_finished.rb

Overview

Represents the TestRunFinished message in Cucumber’s message protocol.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Message

camelize, from_json, #to_h, #to_json

Constructor Details

#initialize(message: nil, success: false, timestamp: Timestamp.new, exception: nil) ⇒ TestRunFinished

Returns a new instance of TestRunFinished.



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/cucumber/messages/test_run_finished.rb', line 31

def initialize(
  message: nil,
  success: false,
  timestamp: Timestamp.new,
  exception: nil
)
  @message = message
  @success = success
  @timestamp = timestamp
  @exception = exception
  super()
end

Instance Attribute Details

#exceptionObject (readonly)

Any exception thrown during the test run, if any. Does not include exceptions thrown while executing steps.



29
30
31
# File 'lib/cucumber/messages/test_run_finished.rb', line 29

def exception
  @exception
end

#messageObject (readonly)

An informative message about the test run. Typically additional information about failure, but not necessarily.



14
15
16
# File 'lib/cucumber/messages/test_run_finished.rb', line 14

def message
  @message
end

#successObject (readonly)

A test run is successful if all steps are either passed or skipped, all before/after hooks passed and no other exceptions where thrown.



19
20
21
# File 'lib/cucumber/messages/test_run_finished.rb', line 19

def success
  @success
end

#timestampObject (readonly)

Timestamp when the TestRun is finished



24
25
26
# File 'lib/cucumber/messages/test_run_finished.rb', line 24

def timestamp
  @timestamp
end

Class Method Details

.from_h(hash) ⇒ Object

Returns a new TestRunFinished from the given hash. If the hash keys are camelCased, they are properly assigned to the corresponding snake_cased attributes.

Cucumber::Messages::TestRunFinished.from_h(some_hash) # => #<Cucumber::Messages::TestRunFinished:0x... ...>


51
52
53
54
55
56
57
58
59
60
# File 'lib/cucumber/messages/test_run_finished.rb', line 51

def self.from_h(hash)
  return nil if hash.nil?

  new(
    message: hash[:message],
    success: hash[:success],
    timestamp: Timestamp.from_h(hash[:timestamp]),
    exception: Exception.from_h(hash[:exception])
  )
end