Class: TestStatus

Inherits:
Object show all
Defined in:
lib/test_case/test_status.rb

Overview

The TestStatus module defines all the possible statuses for tests and steps

Constant Summary collapse

NOT_RUN =
:'not run'
RUNNING =
:running
PASSED =
:passed
DONE =

currently, performance tests do not pass or fail in TMC–this is determined by SWORD

:done
FAILED =
:failed
ERROR =
:error

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(test_case, status, reason: nil, backtrace: nil, exception: nil, trace: nil) ⇒ TestStatus

Returns a new instance of TestStatus.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/test_case/test_status.rb', line 14

def initialize(test_case, status, reason: nil, backtrace: nil, exception: nil, trace: nil)
  @status = status
  @backtrace = exception.nil? ? backtrace : exception.backtrace
  if !exception.nil?
    if (exception.message || '').empty?
      @reason = exception.class.name
    else
      @reason = exception.message
    end
  else
    @reason = reason
  end
  if !@backtrace.nil?
    @trace = TestTrace.new(test_case, @backtrace)
  else
    @trace = trace
  end
end

Instance Attribute Details

#backtraceObject (readonly)

Returns the value of attribute backtrace.



12
13
14
# File 'lib/test_case/test_status.rb', line 12

def backtrace
  @backtrace
end

#reasonObject (readonly)

Returns the value of attribute reason.



12
13
14
# File 'lib/test_case/test_status.rb', line 12

def reason
  @reason
end

#statusObject (readonly)

Returns the value of attribute status.



12
13
14
# File 'lib/test_case/test_status.rb', line 12

def status
  @status
end

#traceObject (readonly)

Returns the value of attribute trace.



12
13
14
# File 'lib/test_case/test_status.rb', line 12

def trace
  @trace
end

Instance Method Details

#to_hObject



33
34
35
36
37
38
# File 'lib/test_case/test_status.rb', line 33

def to_h
  {
    status: @status.to_s,
    reason: @reason
  }.merge(@trace.nil? ? {} : @trace.to_h)
end