class Crucible::Tests::BaseTest
Constants
- BASE_SPEC_LINK
- JSON_FIELDS
Base test fields, used in
Crucible::Tests::Executor.list_all
- METADATA_FIELDS
- REST_SPEC_LINK
- STATUS
Attributes
category[RW]
tests_subset[RW]
warnings[RW]
Public Class Methods
new(client, client2=nil)
click to toggle source
# File lib/tests/base_test.rb, line 26 def initialize(client, client2=nil) @client = client FHIR::Resource.new.client = client @client2 = client2 @client.monitor_requests if @client @client2.monitor_requests if @client2 @tags ||= [] @warnings = [] end
Public Instance Methods
description()
click to toggle source
# File lib/tests/base_test.rb, line 87 def description # String containing test file description self.class.name end
details()
click to toggle source
# File lib/tests/base_test.rb, line 92 def details {} end
execute()
click to toggle source
# File lib/tests/base_test.rb, line 40 def execute @client.use_format_param = false if @client @client2.use_format_param = false if @client2 {id => execute_test_methods} end
execute_test_method(test_method)
click to toggle source
# File lib/tests/base_test.rb, line 76 def execute_test_method(test_method) response = self.method(test_method).call().to_hash.merge!({:test_method => test_method }) response.merge!({:requests => @client.requests.map { |r| r.to_hash } }) if @client response end
execute_test_methods()
click to toggle source
# File lib/tests/base_test.rb, line 50 def execute_test_methods result = [] begin setup if respond_to? :setup and not @metadata_only rescue AssertionException => e @setup_failed = e end prefix = if @metadata_only then 'generating metadata' else 'executing' end methods = tests methods = tests & @tests_subset unless @tests_subset.blank? methods.each do |test_method| @client.requests = [] if @client FHIR.logger.info "[#{title}#{('_' + @resource_class.name.demodulize) if @resource_class}] #{prefix}: #{test_method}..." begin result << execute_test_method(test_method) rescue => e result << TestResult.new('ERROR', "Error #{prefix} #{test_method}", STATUS[:error], "#{test_method} failed, fatal error: #{e.message}", e.backtrace.join("\n")).to_hash.merge!({:test_method => test_method}) end end begin teardown if respond_to? :teardown and not @metadata_only rescue end result end
id()
click to toggle source
# File lib/tests/base_test.rb, line 96 def id # String used to order test files for execution self.object_id.to_s end
ignore_client_exception() { || ... }
click to toggle source
# File lib/tests/base_test.rb, line 122 def ignore_client_exception begin yield rescue ClientException end end
multiserver()
click to toggle source
# File lib/tests/base_test.rb, line 36 def multiserver false end
tests(keys=nil)
click to toggle source
# File lib/tests/base_test.rb, line 101 def tests(keys=nil) # Array of test methods within test file methods = self.methods.grep(/_test$/) if keys matches = [] keys.each do |key| matches << methods.grep(/^#{key}/i) end methods = matches.flatten end methods end
warning() { || ... }
click to toggle source
# File lib/tests/base_test.rb, line 114 def warning begin yield rescue AssertionException => e @warnings << e.message end end