An engine that runs FHIR TestScript resources against a FHIR server. It is a Ruby port of testscript-eval-py, built on fhir_client and fhirpath-rb.
gem "testscript_eval", git: "https://github.com/beda-software/testscript-eval-ruby"require "testscript_eval"
definition = TestscriptEval.load_file("TestScript/testscript-example.yaml")
warnings = TestscriptEval.eval(definition, {
"baseUrl" => "http://localhost:8080/fhir",
"authorization" => "Basic cm9vdDpzZWNyZXQ="
})TestscriptEval.eval loads fixtures, autocreates them, resolves variables, then runs setup,
every test and teardown (always), and finally autodeletes fixtures.
- A failed assert raises
TestscriptEval::AssertionFailed. - A failed
warningOnlyassert does not stop the script; its message is in the returned array. - Anything else (an unsupported assert or operator, a missing variable, a
$validatethe server could not run) raisesTestscriptEval::Erroror one of its subclasses,warningOnlyor not.
The env hash holds baseUrl, authorization (sent as is in the Authorization header) and
values for TestScript variables without a sourceId. Without one, it is read from
FHIR_SERVER_BASE_URL and FHIR_SERVER_AUTHORIZATION.
Options:
root_dir:(default: the current directory) resolvesfile://fixture references, e.g.file://tests/resources/patient.yaml.include_dir:(default:<root_dir>/tests/resources) resolves!include pathtags in YAML fixtures.
YAML files are loaded safely, with dates and datetimes kept as strings.
The engine logs to TestscriptEval.logger (stderr). fhir_client logs every request to stdout at debug
level; quiet it with FHIR.logger.level = Logger::WARN.
- Fixtures: contained (
#Type/id), files (file://), server references (Type/id),autocreate,autodelete - Operations:
read,search,create,update,delete,history,populate,extract, or an explicitmethod(get,post,put,delete), withparams,targetId,sourceId,responseId - Asserts:
response,responseCode,resource,headerField,contentType,path(JSONPath),expression(FHIRPath),value,compareToSourceExpression,minimumId,navigationLinks,validateProfileId(via$validate) - Operators:
equals,in,contains,exists,notEmpty,eval
bundle install
bundle exec rspecMade with ❤️ by Beda Software