Class: Inferno::Entities::TestSuite

Inherits:
Object
  • Object
show all
Extended by:
Forwardable, DSL::FHIRClient::ClassMethods, DSL::HTTPClient::ClassMethods, DSL::Runnable
Includes:
DSL::Assertions, DSL::FHIRResourceValidation, DSL::FHIRValidation, DSL::FhirpathEvaluation, DSL::Messages, DSL::Results
Defined in:
lib/inferno/entities/test_suite.rb

Overview

A ‘TestSuite` represents a packaged group of tests, usually for a single Implementation Guide

Constant Summary

Constants included from DSL::Runnable

DSL::Runnable::VARIABLES_NOT_TO_COPY

Instance Attribute Summary collapse

Attributes included from DSL::Runnable

#parent, #suite_option_requirements

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DSL::Runnable

add_self_to_repository, all_children, block, child_metadata, children, configure_child_class, copy_instance_variables, create_child_class, default_id, define_child, description, extended, handle_child_definition_block, id, input_instructions, inspect, optional, optional?, process_args, repository, required, required?, required_suite_options, resume_test_route, route, short_description, short_title, suite, suite_endpoint, test_count, title, user_runnable?

Methods included from Utils::MarkdownFormatter

#format_markdown

Methods included from DSL::FHIRClient::ClassMethods

fhir_client, fhir_client_definitions

Methods included from DSL::HTTPClient::ClassMethods

http_client, http_client_definitions

Methods included from DSL::Messages

#add_message, #info, #messages, #warning

Methods included from DSL::Assertions

#assert, #assert_resource_type, #assert_response_content_type, #assert_response_status, #assert_valid_bundle_entries, #assert_valid_http_uri, #assert_valid_json, #assert_valid_resource, #bad_content_type_message, #bad_resource_type_message, #bad_response_status_message, #invalid_bundle_entries_message, #invalid_resource_message, #no_content_type_message, #normalize_resource_type, #normalize_types_to_check

Methods included from DSL::Results

#cancel, #identifier, #omit, #omit_if, #pass, #pass_if, #skip, #skip_if, #wait, #wait_timeout

Methods included from DSL::FhirpathEvaluation

#evaluate_fhirpath, included

Methods included from DSL::FHIRResourceValidation

included

Methods included from DSL::FHIRValidation

#find_validator, included, #resource_is_valid?

Constructor Details

#initializeTestSuite

Returns a new instance of TestSuite.



29
30
31
# File 'lib/inferno/entities/test_suite.rb', line 29

def initialize
  @results = Inferno::ResultCollection.new
end

Instance Attribute Details

#result_messageObject

Returns the value of attribute result_message.



26
27
28
# File 'lib/inferno/entities/test_suite.rb', line 26

def result_message
  @result_message
end

#resultsObject

Returns the value of attribute results.



26
27
28
# File 'lib/inferno/entities/test_suite.rb', line 26

def results
  @results
end

Class Method Details

.check_configuration(&block) ⇒ void

This method returns an undefined value.

Provide a block which will verify any configuration needed for this test suite to operate properly.

Yield Returns:

  • (Array<Hash>)

    An array of message hashes containing the keys ‘:type` and `:message`. Type options are `info`, `warning`, and `error`.



115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/inferno/entities/test_suite.rb', line 115

def check_configuration(&block)
  @check_configuration_block = lambda do
    block.call&.each do |configuration_message|
      case configuration_message[:type]
      when 'warning'
        Application[:logger].warn(configuration_message[:message])
      when 'error'
        Application[:logger].error(configuration_message[:message])
      end
    end
  end
end

.configuration_messages(new_messages = nil, force_recheck: false) ⇒ Object



97
98
99
100
101
102
103
104
105
106
# File 'lib/inferno/entities/test_suite.rb', line 97

def configuration_messages(new_messages = nil, force_recheck: false)
  return @configuration_messages = new_messages unless new_messages.nil?

  @configuration_messages =
    if force_recheck
      @check_configuration_block ? @check_configuration_block.call : []
    else
      @configuration_messages || (@check_configuration_block ? @check_configuration_block.call : [])
    end
end

.default_groupObject



39
40
41
42
43
44
45
# File 'lib/inferno/entities/test_suite.rb', line 39

def default_group
  return @default_group if @default_group

  @default_group = Class.new(TestGroup)
  all_children << @default_group
  @default_group
end

.groupvoid

This method returns an undefined value.

Add a child group



65
66
67
68
# File 'lib/inferno/entities/test_suite.rb', line 65

def group(...)
  ()
  define_child(...)
end

.group_metadataObject



71
72
73
74
75
76
# File 'lib/inferno/entities/test_suite.rb', line 71

def 
  {
    class: TestGroup,
    repo: Inferno::Repositories::TestGroups.new
  }
end

.groups(options = nil) ⇒ Array<Inferno::Entities::TestGroup>

Get this suite’s child groups, filtered by suite options, if provided.

Parameters:

Returns:



57
58
59
# File 'lib/inferno/entities/test_suite.rb', line 57

def groups(options = nil)
  children(options).select { |child| child < Inferno::Entities::TestGroup }
end

Set/get a list of links which are displayed in the footer of the UI.

Examples:

links [
  {
    label: 'Report Issue',
    url: 'https://github.com/onc-healthit/onc-certification-g10-test-kit/issues/'
  },
  {
    label: 'Open Source',
    url: 'https://github.com/onc-healthit/onc-certification-g10-test-kit/'
  }
]

Parameters:

  • links (Array<Hash>) (defaults to: nil)

    A list of Hashes for the links to be displayed. Each hash needs a ‘label:` and `url:` entry.

Returns:

  • (Array<Hash>, nil)


194
195
196
197
198
# File 'lib/inferno/entities/test_suite.rb', line 194

def links(links = nil)
  return @links if links.nil?

  @links = links
end

.presetsObject



129
130
131
# File 'lib/inferno/entities/test_suite.rb', line 129

def presets
  @presets ||= Repositories::Presets.new.presets_for_suite(id)
end

.reference_hashObject



79
80
81
82
83
# File 'lib/inferno/entities/test_suite.rb', line 79

def reference_hash
  {
    test_suite_id: id
  }
end

.repositoryObject



48
49
50
# File 'lib/inferno/entities/test_suite.rb', line 48

def repository
  Inferno::Repositories::TestSuites.new
end

.suite_option(identifier, **option_params) ⇒ void

This method returns an undefined value.

Define an option for this suite. Options are used to define suite-wide configuration which is selected by a user at the start of a test session. These options can be used to change what tests/groups are run or behavior within particular tests.

Examples:

suite_option :ig_version,
            list_options: [
              {
                label: 'IG v1',
                value: 'ig_v1'
              },
              {
                label: 'IG v2',
                value: 'ig_v2'
              }
            ]

group from: :ig_v1_group,
      required_suite_options: { ig_version: 'ig_v1' }

group from: :ig_v2_group do
  required_suite_options ig_version: 'ig_v2'
end

Parameters:

  • identifier (Symbol, String)

    The identifier which will be used to refer to this option

  • option_params (Hash)

    a customizable set of options

Options Hash (**option_params):

  • :title (String)

    Title which will be displayed in the UI

  • :list_options (Array<Hash>)

    The list of possible values for this option. Each hash needs to have a ‘label:` and a `value:` entry which are Strings.



166
167
168
# File 'lib/inferno/entities/test_suite.rb', line 166

def suite_option(identifier, **option_params)
  suite_options << DSL::SuiteOption.new(option_params.merge(id: identifier))
end

.suite_optionsArray<Inferno::DSL::SuiteOption>

Returns The options defined for this suite.

Returns:



172
173
174
# File 'lib/inferno/entities/test_suite.rb', line 172

def suite_options
  @suite_options ||= []
end

.suite_summary(suite_summary = nil) ⇒ String?

Set/get a description which for this test suite which will be displayed in the UI.

Parameters:

  • suite_summary (String) (defaults to: nil)

Returns:

  • (String, nil)


206
207
208
209
210
# File 'lib/inferno/entities/test_suite.rb', line 206

def suite_summary(suite_summary = nil)
  return @suite_summary if suite_summary.nil?

  @suite_summary = format_markdown(suite_summary)
end

.version(version = nil) ⇒ String?

Set/get the version of this test suite.

Parameters:

  • version (String) (defaults to: nil)

Returns:

  • (String, nil)


90
91
92
93
94
# File 'lib/inferno/entities/test_suite.rb', line 90

def version(version = nil)
  return @version if version.nil?

  @version = version
end