Class: DecisionAgent::Testing::TestResult

Inherits:
Object
  • Object
show all
Defined in:
lib/decision_agent/testing/batch_test_runner.rb

Overview

Result of a single test scenario execution

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scenario_id:, decision: nil, confidence: nil, execution_time_ms: 0, error: nil, evaluations: []) ⇒ TestResult



11
12
13
14
15
16
17
18
19
20
# File 'lib/decision_agent/testing/batch_test_runner.rb', line 11

def initialize(scenario_id:, decision: nil, confidence: nil, execution_time_ms: 0, error: nil, evaluations: [])
  @scenario_id = scenario_id.to_s.freeze
  @decision = decision&.to_s&.freeze
  @confidence = confidence&.to_f
  @execution_time_ms = execution_time_ms.to_f
  @error = error
  @evaluations = evaluations.freeze

  freeze
end

Instance Attribute Details

#confidenceObject (readonly)

Returns the value of attribute confidence.



9
10
11
# File 'lib/decision_agent/testing/batch_test_runner.rb', line 9

def confidence
  @confidence
end

#decisionObject (readonly)

Returns the value of attribute decision.



9
10
11
# File 'lib/decision_agent/testing/batch_test_runner.rb', line 9

def decision
  @decision
end

#errorObject (readonly)

Returns the value of attribute error.



9
10
11
# File 'lib/decision_agent/testing/batch_test_runner.rb', line 9

def error
  @error
end

#evaluationsObject (readonly)

Returns the value of attribute evaluations.



9
10
11
# File 'lib/decision_agent/testing/batch_test_runner.rb', line 9

def evaluations
  @evaluations
end

#execution_time_msObject (readonly)

Returns the value of attribute execution_time_ms.



9
10
11
# File 'lib/decision_agent/testing/batch_test_runner.rb', line 9

def execution_time_ms
  @execution_time_ms
end

#scenario_idObject (readonly)

Returns the value of attribute scenario_id.



9
10
11
# File 'lib/decision_agent/testing/batch_test_runner.rb', line 9

def scenario_id
  @scenario_id
end

Instance Method Details

#success?Boolean



22
23
24
# File 'lib/decision_agent/testing/batch_test_runner.rb', line 22

def success?
  @error.nil?
end

#to_hObject



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/decision_agent/testing/batch_test_runner.rb', line 26

def to_h
  {
    scenario_id: @scenario_id,
    decision: @decision,
    confidence: @confidence,
    execution_time_ms: @execution_time_ms,
    error: @error&.message,
    success: success?,
    evaluations: @evaluations.map { |e| e.respond_to?(:to_h) ? e.to_h : e }
  }
end