Class: DecisionAgent::Dmn::DmnTestSuite
- Inherits:
-
Object
- Object
- DecisionAgent::Dmn::DmnTestSuite
- Defined in:
- lib/decision_agent/dmn/testing.rb
Overview
Test Suite for organizing multiple DMN models' tests
Instance Attribute Summary collapse
-
#models ⇒ Object
readonly
Returns the value of attribute models.
-
#testers ⇒ Object
readonly
Returns the value of attribute testers.
Instance Method Summary collapse
-
#add_model(model_id, model) ⇒ Object
Add a model to the test suite.
-
#generate_suite_report(results) ⇒ Object
Generate overall suite report.
-
#initialize ⇒ DmnTestSuite
constructor
A new instance of DmnTestSuite.
-
#run_all ⇒ Object
Run all tests for all models.
-
#tester_for(model_id) ⇒ Object
Get tester for a model.
Constructor Details
#initialize ⇒ DmnTestSuite
286 287 288 289 |
# File 'lib/decision_agent/dmn/testing.rb', line 286 def initialize @models = {} @testers = {} end |
Instance Attribute Details
#models ⇒ Object (readonly)
Returns the value of attribute models.
284 285 286 |
# File 'lib/decision_agent/dmn/testing.rb', line 284 def models @models end |
#testers ⇒ Object (readonly)
Returns the value of attribute testers.
284 285 286 |
# File 'lib/decision_agent/dmn/testing.rb', line 284 def testers @testers end |
Instance Method Details
#add_model(model_id, model) ⇒ Object
Add a model to the test suite
292 293 294 295 |
# File 'lib/decision_agent/dmn/testing.rb', line 292 def add_model(model_id, model) @models[model_id] = model @testers[model_id] = DmnTester.new(model) end |
#generate_suite_report(results) ⇒ Object
Generate overall suite report
314 315 316 317 318 319 320 321 322 323 324 325 326 327 |
# File 'lib/decision_agent/dmn/testing.rb', line 314 def generate_suite_report(results) total_tests = results.values.sum { |r| r[:summary][:total] } total_passed = results.values.sum { |r| r[:summary][:passed] } total_failed = results.values.sum { |r| r[:summary][:failed] } { models_tested: results.size, total_tests: total_tests, total_passed: total_passed, total_failed: total_failed, overall_pass_rate: total_tests.positive? ? (total_passed.to_f / total_tests * 100).round(2) : 0, model_results: results } end |
#run_all ⇒ Object
Run all tests for all models
303 304 305 306 307 308 309 310 311 |
# File 'lib/decision_agent/dmn/testing.rb', line 303 def run_all results = {} @testers.each do |model_id, tester| results[model_id] = tester.run_all_tests end generate_suite_report(results) end |
#tester_for(model_id) ⇒ Object
Get tester for a model
298 299 300 |
# File 'lib/decision_agent/dmn/testing.rb', line 298 def tester_for(model_id) @testers[model_id] end |