Class: UnityTestResults::TestResult

Inherits:
Object
  • Object
show all
Defined in:
lib/unity_test_results/domain/test_result.rb

Constant Summary collapse

CHECKMARK =
"\u2705".freeze
CROSSMARK =
"\u274c".freeze
INCONCLUSIVEMARK =
"\u00B7".freeze
FOLDER =
"\u2192".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash_value) ⇒ TestResult

Returns a new instance of TestResult.



10
11
12
13
14
15
16
17
18
19
# File 'lib/unity_test_results/domain/test_result.rb', line 10

def initialize(hash_value)
  @methodname = hash_value[:methodname]
  @classname = classname_from(hash_value[:classname])
  @namespace = namespace_from(hash_value[:classname])
  @result = hash_value[:result]
  @start_time = hash_value[:'start-time']
  @end_time = hash_value[:'end-time']
  @duration = hash_value[:duration]
  @failure = hash_value[:failure]
end

Instance Attribute Details

#classnameObject (readonly)

Returns the value of attribute classname.



21
22
23
# File 'lib/unity_test_results/domain/test_result.rb', line 21

def classname
  @classname
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



21
22
23
# File 'lib/unity_test_results/domain/test_result.rb', line 21

def namespace
  @namespace
end

Instance Method Details

#classname_from(fullname) ⇒ Object



39
40
41
# File 'lib/unity_test_results/domain/test_result.rb', line 39

def classname_from(fullname)
  fullname.split('.').last
end

#failed?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/unity_test_results/domain/test_result.rb', line 47

def failed?
  @result == 'Failed'
end

#get_markObject



33
34
35
36
37
# File 'lib/unity_test_results/domain/test_result.rb', line 33

def get_mark
  return CROSSMARK if failed?

  CHECKMARK
end

#namespace_from(fullname) ⇒ Object



51
52
53
54
55
# File 'lib/unity_test_results/domain/test_result.rb', line 51

def namespace_from(fullname)
  a = fullname.split('.')
  a.pop
  a.join('.')
end

#output_result(indent) ⇒ Object



23
24
25
26
# File 'lib/unity_test_results/domain/test_result.rb', line 23

def output_result(indent)
  puts "#{indent} #{get_mark} #{@methodname} result: #{@result} duration: #{@duration}".colorize(test_color)
  puts "#{indent}   #{@failure}".colorize(test_color) unless @failure.empty?
end

#passed?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/unity_test_results/domain/test_result.rb', line 43

def passed?
  @result == 'Passed'
end

#test_colorObject



28
29
30
31
# File 'lib/unity_test_results/domain/test_result.rb', line 28

def test_color
  return :red if failed?
  return :green if passed?
end