Class: Capsium::Package::Testing::TestSuite

Inherits:
Object
  • Object
show all
Defined in:
lib/capsium/package/testing/test_suite.rb,
sig/capsium/package/testing/test_suite.rbs

Overview

Loads and runs the package's tests/*.yaml suites (05x-testing). Route tests are served by a reactor on an ephemeral port for the duration of the run.

Constant Summary collapse

TESTS_DIR =

Returns:

  • (String)
"tests"
BUILTIN_TEST_KINDS =

Referencing the built-in test kinds triggers their autoload, which registers them in TestCase.types (each kind file self-registers on load).

[RouteTest, FileTest, DataValidationTest, ConfigTest].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(package) ⇒ TestSuite

Returns a new instance of TestSuite.

Parameters:



23
24
25
# File 'lib/capsium/package/testing/test_suite.rb', line 23

def initialize(package)
  @package = package
end

Instance Attribute Details

#packageCapsium::Package (readonly)

Returns the value of attribute package.

Returns:



21
22
23
# File 'lib/capsium/package/testing/test_suite.rb', line 21

def package
  @package
end

Instance Method Details

#runReport

Returns:



31
32
33
34
35
36
37
38
39
# File 'lib/capsium/package/testing/test_suite.rb', line 31

def run
  report = Report.new
  loaded = load_cases(report)
  with_reactor(loaded) do |base_url|
    context = Context.new(package_path: @package.path, base_url: base_url)
    loaded.each { |test_case| report << run_case(test_case, context) }
  end
  report
end

#test_filesArray[String]

Returns:

  • (Array[String])


27
28
29
# File 'lib/capsium/package/testing/test_suite.rb', line 27

def test_files
  Dir.glob(File.join(@package.path, TESTS_DIR, "*.{yaml,yml}"))
end