class Pod::TestResult

Attributes

cov_path[RW]
json_path[RW]

Public Class Methods

new(json_path, cov_path) click to toggle source
# 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

Public Instance Methods

dump_json_to_file(result, file) click to toggle source
# 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_file() click to toggle source
# 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
parse() click to toggle source
# File lib/cocoapods-unit-test/result.rb, line 36
def parse
  parse_json_result
  parse_cov_result
end
parse_cov_result() click to toggle source
# File lib/cocoapods-unit-test/result.rb, line 32
def parse_cov_result
  ## line_cov fun_cov headerCovTableEntry
end
parse_json_result() click to toggle source
# 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