Class: Pod::TestResult

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-unit-test/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json_path, cov_path) ⇒ TestResult



11
12
13
14
# File 'lib/cocoapods-unit-test/result.rb', line 11

def initialize(json_path, cov_path)
  @json_path = File.expand_path(json_path)
  @cov_path = File.expand_path(cov_path)
end

Instance Attribute Details

#cov_pathObject

Returns the value of attribute cov_path.



8
9
10
# File 'lib/cocoapods-unit-test/result.rb', line 8

def cov_path
  @cov_path
end

#json_pathObject

Returns the value of attribute json_path.



9
10
11
# File 'lib/cocoapods-unit-test/result.rb', line 9

def json_path
  @json_path
end

Instance Method Details

#dump_json_to_file(result, file) ⇒ Object



49
50
51
52
53
# File 'lib/cocoapods-unit-test/result.rb', line 49

def dump_json_to_file(result, file)
  File.open(file,"w") do |w|
    w.write(JSON.neat_generate(result, sort:true, wrap:true, after_colon:1))
  end
end

#load_json_from_fileObject



41
42
43
44
45
46
47
# File 'lib/cocoapods-unit-test/result.rb', line 41

def load_json_from_file
  if File.file?(json_path)
    json_file = File.open json_path
    return JSON.load json_file
  end
  {}
end

#parseObject



36
37
38
39
# File 'lib/cocoapods-unit-test/result.rb', line 36

def parse
  parse_json_result
  parse_cov_result
end

#parse_cov_resultObject



32
33
34
# File 'lib/cocoapods-unit-test/result.rb', line 32

def parse_cov_result
  ## line_cov fun_cov headerCovTableEntry
end

#parse_json_resultObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/cocoapods-unit-test/result.rb', line 16

def parse_json_result
  ## build_success, tests_count, tests_failed_count
  load_json_from_file.fetch("metrics", {}).tap { |result|
    UI.puts "Test case count :" + result.fetch("testsCount", {}).fetch("_value", 0).to_s
    UI.puts "Test case fail count :" + result.fetch("testsFailedCount", {}).fetch("_value", 0).to_s

    result.fetch("issues", {}).fetch("errorSummaries", {}).fetch("_values", []).each { |issues|
      UI.puts "❌ #{issues.fetch("issueType", {}).fetch("_value", "").to_s} -> #{issues.fetch("message", {}).fetch("_value", "").to_s}"
    }

    result.fetch("issues", {}).fetch("testFailureSummaries", {}).fetch("_values", []).each { |issues|
      UI.puts "❌ #{issues.fetch("testCaseName", {}).fetch("_value", "").to_s} -> #{issues.fetch("message", {}).fetch("_value", "").to_s}"
    }
  }
end