Class: Cucumber::Messages::TestStepResult

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

Overview

Represents the TestStepResult 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(duration: Duration.new, message: nil, status: TestStepResultStatus::UNKNOWN, exception: nil) ⇒ TestStepResult

Returns a new instance of TestStepResult.



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/cucumber/messages/test_step_result.rb', line 25

def initialize(
  duration: Duration.new,
  message: nil,
  status: TestStepResultStatus::UNKNOWN,
  exception: nil
)
  @duration = duration
  @message = message
  @status = status
  @exception = exception
  super()
end

Instance Attribute Details

#durationObject (readonly)

Returns the value of attribute duration.



11
12
13
# File 'lib/cucumber/messages/test_step_result.rb', line 11

def duration
  @duration
end

#exceptionObject (readonly)

Exception thrown while executing this step, if any.



23
24
25
# File 'lib/cucumber/messages/test_step_result.rb', line 23

def exception
  @exception
end

#messageObject (readonly)

An arbitrary bit of information that explains this result. This can be a stack trace of anything else.



16
17
18
# File 'lib/cucumber/messages/test_step_result.rb', line 16

def message
  @message
end

#statusObject (readonly)

Returns the value of attribute status.



18
19
20
# File 'lib/cucumber/messages/test_step_result.rb', line 18

def status
  @status
end

Class Method Details

.from_h(hash) ⇒ Object

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

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


45
46
47
48
49
50
51
52
53
54
# File 'lib/cucumber/messages/test_step_result.rb', line 45

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

  new(
    duration: Duration.from_h(hash[:duration]),
    message: hash[:message],
    status: hash[:status],
    exception: Exception.from_h(hash[:exception])
  )
end