Class: Testgenai::Reporter

Inherits:
Object
  • Object
show all
Defined in:
lib/testgenai/reporter.rb

Instance Method Summary collapse

Instance Method Details

#context_result(method_info, context) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/testgenai/reporter.rb', line 18

def context_result(method_info, context)
  puts "=== Context for #{method_info[:class]}##{method_info[:method]} ==="
  puts "  File: #{method_info[:file]}"
  unless context[:dependencies].to_a.empty?
    puts "  Dependencies:"
    context[:dependencies].each { |d| puts "    #{d}" }
  end
  unless context[:example_usage].to_a.empty?
    puts "  Example usages found: #{context[:example_usage].size}"
  end
  puts "  Related tests: #{context[:related_tests] ? "yes" : "none"}"
  puts
end

#failure(method_info, result) ⇒ Object



36
37
38
39
# File 'lib/testgenai/reporter.rb', line 36

def failure(method_info, result)
  puts "#{method_info[:class]}##{method_info[:method]} failed after #{result[:attempts]} attempt(s)"
  puts "    → Generated tests saved to #{result[:fallback_path]} for manual review" if result[:fallback_path]
end

#fatal_error(error) ⇒ Object



50
51
52
# File 'lib/testgenai/reporter.rb', line 50

def fatal_error(error)
  puts "Fatal error: #{error.message}"
end

#scan_results(methods, files_scanned: nil) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/testgenai/reporter.rb', line 3

def scan_results(methods, files_scanned: nil)
  if methods.empty?
    if files_scanned
      puts "Scanned #{files_scanned} source file(s) — no untested methods found."
    else
      puts "No untested methods found."
    end
    return
  end
  puts "Found #{methods.size} untested method(s):"
  methods.each do |m|
    puts "  #{m[:class]}##{m[:method]}  #{m[:file]}:#{m[:start_line]}-#{m[:end_line]}"
  end
end

#skipped(method_info, error) ⇒ Object



41
42
43
# File 'lib/testgenai/reporter.rb', line 41

def skipped(method_info, error)
  puts "  - #{method_info[:class]}##{method_info[:method]} skipped: #{error.message}"
end

#success(method_info, result) ⇒ Object



32
33
34
# File 'lib/testgenai/reporter.rb', line 32

def success(method_info, result)
  puts "#{method_info[:class]}##{method_info[:method]}#{result[:output_path]} (#{result[:attempts]} attempt(s))"
end

#summary(results) ⇒ Object



45
46
47
48
# File 'lib/testgenai/reporter.rb', line 45

def summary(results)
  puts "\nSummary: #{results[:successful].size} generated, " \
       "#{results[:failed].size} failed, #{results[:skipped].size} skipped"
end