Class: Ace::TestRunner::Models::TestReport
- Inherits:
-
Object
- Object
- Ace::TestRunner::Models::TestReport
- Defined in:
- lib/ace/test_runner/models/test_report.rb
Overview
Represents a complete test report
Instance Attribute Summary collapse
-
#configuration ⇒ Object
Returns the value of attribute configuration.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#files_tested ⇒ Object
Returns the value of attribute files_tested.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#report_path ⇒ Object
Returns the value of attribute report_path.
-
#result ⇒ Object
Returns the value of attribute result.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
Instance Method Summary collapse
- #failure_summary ⇒ Object
-
#initialize(attributes = {}) ⇒ TestReport
constructor
A new instance of TestReport.
- #success? ⇒ Boolean
- #summary ⇒ Object
- #to_h ⇒ Object
- #to_json(*args) ⇒ Object
- #to_markdown ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ TestReport
Returns a new instance of TestReport.
13 14 15 16 17 18 19 20 21 |
# File 'lib/ace/test_runner/models/test_report.rb', line 13 def initialize(attributes = {}) @result = attributes[:result] || TestResult.new @configuration = attributes[:configuration] || TestConfiguration.new @timestamp = attributes[:timestamp] || Time.now @report_path = attributes[:report_path] @files_tested = attributes[:files_tested] || [] @environment = attributes[:environment] || capture_environment @metadata = attributes[:metadata] || {} end |
Instance Attribute Details
#configuration ⇒ Object
Returns the value of attribute configuration.
10 11 12 |
# File 'lib/ace/test_runner/models/test_report.rb', line 10 def configuration @configuration end |
#environment ⇒ Object
Returns the value of attribute environment.
10 11 12 |
# File 'lib/ace/test_runner/models/test_report.rb', line 10 def environment @environment end |
#files_tested ⇒ Object
Returns the value of attribute files_tested.
10 11 12 |
# File 'lib/ace/test_runner/models/test_report.rb', line 10 def files_tested @files_tested end |
#metadata ⇒ Object
Returns the value of attribute metadata.
10 11 12 |
# File 'lib/ace/test_runner/models/test_report.rb', line 10 def @metadata end |
#report_path ⇒ Object
Returns the value of attribute report_path.
10 11 12 |
# File 'lib/ace/test_runner/models/test_report.rb', line 10 def report_path @report_path end |
#result ⇒ Object
Returns the value of attribute result.
10 11 12 |
# File 'lib/ace/test_runner/models/test_report.rb', line 10 def result @result end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
10 11 12 |
# File 'lib/ace/test_runner/models/test_report.rb', line 10 def @timestamp end |
Instance Method Details
#failure_summary ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/ace/test_runner/models/test_report.rb', line 41 def failure_summary return [] unless result.has_failures? result.failures_detail.map do |failure| { type: failure.type, test: failure.full_test_name, location: failure.location, message: failure. } end end |
#success? ⇒ Boolean
23 24 25 |
# File 'lib/ace/test_runner/models/test_report.rb', line 23 def success? result.success? end |
#summary ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ace/test_runner/models/test_report.rb', line 27 def summary { status: success? ? "success" : "failure", passed: result.passed, failed: result.failed, errors: result.errors, skipped: result.skipped, total: result.total_tests, pass_rate: result.pass_rate, duration: result.duration, timestamp: .iso8601 } end |
#to_h ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/ace/test_runner/models/test_report.rb', line 54 def to_h { summary: summary, result: result.to_h, configuration: configuration.to_h, timestamp: .iso8601, report_path: report_path, files_tested: files_tested, environment: environment, failures: failure_summary, deprecations: result.deprecations, metadata: } end |
#to_json(*args) ⇒ Object
69 70 71 |
# File 'lib/ace/test_runner/models/test_report.rb', line 69 def to_json(*args) to_h.to_json(*args) end |
#to_markdown ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/ace/test_runner/models/test_report.rb', line 73 def to_markdown lines = [] lines << "# Test Report" lines << "" lines << "**Generated:** #{.strftime("%Y-%m-%d %H:%M:%S")}" lines << "**Status:** #{success? ? "✅ Success" : "❌ Failed"}" lines << "" lines << "## Summary" lines << "" lines << "| Metric | Value |" lines << "|--------|-------|" lines << "| Total Tests | #{result.total_tests} |" lines << "| Passed | #{result.passed} |" lines << "| Failed | #{result.failed} |" lines << "| Errors | #{result.errors} |" lines << "| Skipped | #{result.skipped} |" lines << "| Pass Rate | #{result.pass_rate}% |" lines << "| Duration | #{result.duration}s |" lines << "" if result.has_failures? lines << "## Failures" lines << "" result.failures_detail.each_with_index do |failure, idx| lines << "### #{idx + 1}. #{failure.full_test_name}" lines << "" lines << "- **Type:** #{failure.type}" lines << "- **Location:** `#{failure.location}`" lines << "- **Message:** #{failure.}" lines << "- **Fix:** #{failure.fix_suggestion}" if failure.fix_suggestion lines << "" end end if result.has_deprecations? lines << "## Deprecations" lines << "" result.deprecations.each do |deprecation| lines << "- #{deprecation}" end lines << "" end if files_tested.any? lines << "## Files Tested" lines << "" files_tested.each do |file| lines << "- #{file}" end lines << "" end lines.join("\n") end |