Class: CemAcpt::Bolt::Tests::TestList
- Inherits:
-
Object
- Object
- CemAcpt::Bolt::Tests::TestList
- Includes:
- Logging
- Defined in:
- lib/cem_acpt/bolt/tests.rb
Overview
Loads test data and provides an interface for running tests against Bolt tasks
Constant Summary
Constants included from Logging
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#inventory ⇒ Object
Returns the value of attribute inventory.
-
#project ⇒ Object
Returns the value of attribute project.
-
#run_data ⇒ Object
Returns the value of attribute run_data.
-
#tasks ⇒ Object
readonly
Returns the value of attribute tasks.
-
#test_data ⇒ Object
readonly
Returns the value of attribute test_data.
-
#tests ⇒ Object
readonly
Returns the value of attribute tests.
Instance Method Summary collapse
-
#initialize(config = nil, run_data = nil, inventory = nil, project = nil) ⇒ TestList
constructor
A new instance of TestList.
- #inspect ⇒ Object
- #length ⇒ Object (also: #count, #size)
-
#load! ⇒ Object
Loads the test data from the Bolt test files specified in the run data.
- #loaded? ⇒ Boolean
-
#setup! ⇒ Object
Sets up the tests by loading the Bolt tasks and creating a TestWrapper for each test.
- #setup? ⇒ Boolean
- #split_into_groups(num_groups) ⇒ Object
- #to_a ⇒ Object
- #to_s ⇒ Object
Methods included from Logging
current_log_config, #current_log_config, current_log_format, #current_log_format, current_log_level, #current_log_level, included, logger, #logger, new_log_config, #new_log_config, new_log_formatter, #new_log_formatter, new_log_level, #new_log_level, new_logger, #new_logger, verbose?, #verbose?
Constructor Details
#initialize(config = nil, run_data = nil, inventory = nil, project = nil) ⇒ TestList
Returns a new instance of TestList.
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 |
# File 'lib/cem_acpt/bolt/tests.rb', line 313 def initialize(config = nil, run_data = nil, inventory = nil, project = nil) @config = config @run_data = run_data @inventory = inventory @project = project @test_data = nil @tasks_only = @config&.get('bolt.tasks.only') || [] @tasks_ignore = @config&.get('bolt.tasks.ignore') || [] @tasks = [] @tests_only = @config&.get('boly.tests.only') || [] @tests_ignore = @config&.get('bolt.tests.ignore') || [] @tests = [] @loaded = false @setup = false end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
310 311 312 |
# File 'lib/cem_acpt/bolt/tests.rb', line 310 def config @config end |
#inventory ⇒ Object
Returns the value of attribute inventory.
310 311 312 |
# File 'lib/cem_acpt/bolt/tests.rb', line 310 def inventory @inventory end |
#project ⇒ Object
Returns the value of attribute project.
310 311 312 |
# File 'lib/cem_acpt/bolt/tests.rb', line 310 def project @project end |
#run_data ⇒ Object
Returns the value of attribute run_data.
310 311 312 |
# File 'lib/cem_acpt/bolt/tests.rb', line 310 def run_data @run_data end |
#tasks ⇒ Object (readonly)
Returns the value of attribute tasks.
311 312 313 |
# File 'lib/cem_acpt/bolt/tests.rb', line 311 def tasks @tasks end |
#test_data ⇒ Object (readonly)
Returns the value of attribute test_data.
311 312 313 |
# File 'lib/cem_acpt/bolt/tests.rb', line 311 def test_data @test_data end |
#tests ⇒ Object (readonly)
Returns the value of attribute tests.
311 312 313 |
# File 'lib/cem_acpt/bolt/tests.rb', line 311 def tests @tests end |
Instance Method Details
#inspect ⇒ Object
376 377 378 |
# File 'lib/cem_acpt/bolt/tests.rb', line 376 def inspect to_s end |
#length ⇒ Object Also known as: count, size
366 367 368 |
# File 'lib/cem_acpt/bolt/tests.rb', line 366 def length @tests.length end |
#load! ⇒ Object
Loads the test data from the Bolt test files specified in the run data
330 331 332 333 334 335 336 |
# File 'lib/cem_acpt/bolt/tests.rb', line 330 def load! return if loaded? raise 'Run data has not been set, assign it to the #run_data attribute first' unless @run_data @test_data = load_test_data(@run_data) @loaded = true end |
#loaded? ⇒ Boolean
338 339 340 |
# File 'lib/cem_acpt/bolt/tests.rb', line 338 def loaded? @loaded end |
#setup! ⇒ Object
Sets up the tests by loading the Bolt tasks and creating a TestWrapper for each test
343 344 345 346 347 348 349 350 |
# File 'lib/cem_acpt/bolt/tests.rb', line 343 def setup! load! unless loaded? @tasks = CemAcpt::Bolt::TaskList.new(@config) @tasks.tasks # Ensure tasks are loaded logger.verbose('CemAcpt::Bolt::Tests') { "TaskList metadata:\n#{@tasks..to_yaml}" } @tests = new_test_array(@tasks, @test_data) @setup = true end |
#setup? ⇒ Boolean
352 353 354 |
# File 'lib/cem_acpt/bolt/tests.rb', line 352 def setup? @setup end |
#split_into_groups(num_groups) ⇒ Object
360 361 362 363 364 |
# File 'lib/cem_acpt/bolt/tests.rb', line 360 def split_into_groups(num_groups) raise 'Tests have not been setup, call the #setup! method first' unless setup? @tests.split_into_groups(num_groups) end |
#to_a ⇒ Object
356 357 358 |
# File 'lib/cem_acpt/bolt/tests.rb', line 356 def to_a @tests end |
#to_s ⇒ Object
372 373 374 |
# File 'lib/cem_acpt/bolt/tests.rb', line 372 def to_s "#<#{self.class}:#{object_id.to_s(16)} #{tests.join(',')}>" end |