Class: Moto::Runner::TestGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/runner/test_generator.rb

Instance Method Summary collapse

Constructor Details

#initializeTestGenerator

Returns a new instance of TestGenerator.



10
11
12
# File 'lib/runner/test_generator.rb', line 10

def initialize
  @internal_counter = 0
end

Instance Method Details

#get_test_with_variants(test_metadata) ⇒ Array

Method returns an array of test instances that represent all variants (parameter sets from test’s config).

Example: A test with no config file will be returned as an array with single Moto::Test::Base in it.
Example: A test with a config file and 2 sets of parameters there will be returned as array with two elements.

Parameters:

  • Metadata that describes test to be instantiated

Returns:

  • An array of [Moto::Test::Base] descendants each entry is a Test with set of parameters injected



21
22
23
# File 'lib/runner/test_generator.rb', line 21

def get_test_with_variants()
  variantize()
end

#inject_error_to_test(test, error_message) ⇒ Object

Injects raise into test.run so it will report an error when executed

Parameters:

  • An instance of test that is supposed to be modified

  • Message to be attached to the raised exception



94
95
96
97
98
99
100
101
102
103
104
# File 'lib/runner/test_generator.rb', line 94

def inject_error_to_test(test, error_message)
  class << test
    attr_accessor :injected_error_message

    def run
      raise injected_error_message
    end
  end

  test.injected_error_message = error_message
end