fhir-crucible / testscript-generator

FHIR TestScript generator
Apache License 2.0
1 stars 2 forks source link
fhir testing testscript

TestScript Generator

The TestScript Generator is an open source, command-line tool for generating Fast Healthcare Interoperability Resources (FHIR) TestScript resources. It requires a FHIR Implentation Guide (IG) to direct how it creates TestScripts.

Running the Generator

Clone this repository and navigate to your local copy. Once there, run: bundle install, followed by bundle exec bin/testscript_generator. This will start the generator within the context of your local copy.

Configure the Generator

Background and Overview

The TestScript Generator aims to ease the testing process by creating a suite of FHIR TestScript instances to be executed against FHIR servers to check conformance to a given Implementation Guide (IG). FHIR IGs include formal definitions of data structure requirements, interaction patterns, and other details that can be used to generate tests. By attempting to use this information to generate tests as TestScript instances the TestScript Generator project seeks to provide feedback to the FHIR community around

This generator is intended to be used in concert with the TestScript Engine: users can auto-create TestScripts with this generator and then execute them against endpoint(s) with the engine.

Generation Methodology

The generator currently contains several approaches to generation that reflect the experimental nature of this functionality. The common threads are:

  1. Use of IG formal conformance resources including StructureDefinition for profiles and CapabilityStatement instances for server API capabilities. Additionally, allow supplemental documention in situations where the structured resources don't provide the detail needed to generate the desired tests.
  2. Generation of TestScript instances following the FHIR testing methodology.

Within this framework, a few different approaches to generation have been tried:

  1. Indirect Building: create an internal model that looks for information within conformance resources, builds up tests based on them, and translates those tests into TestScript instances.
  2. Direct Templating: write a template TestScript instance and instantiate it using details from conformance resources using a string-replace approach.
  3. Direct Building: build a TestScript instances using details from the conformance resources to decide what to add to them.

Current experience suggests that a combination of direct templating and building are effective and creation of a library of functions to build common patterns would be worthwhile.

Generator Capabilities

The generator can currently generate 4 types of tests. The following sections provide details on their capabilities and status.

Profile Read Tests

The profile read tests are simple tests that read a supplied instance and validate conformance to a profile. In addition, generation supports the creation of a combined search and read test that will use some additional information to create patient-specific searches for profile instances to remove the need to provide individual instance ids and instead provide only a single patient id.

To generate these specific tests, run bundle exec bin/testscript_generator read

Process

Relevant Code

Uses the template approach under the templates directory:

Current Status

These read tests are simple and robust. The user experience is not good using the individual tests, but the combined test relies on profiles that have a search that returns only that profile. This is the most complete generation case to date and seems promising, but will need more work on the engine and generation side to fine-tune the feedback and usability.

Profile Must Support Tests

Must Support tests check that for elements flagged as MustSupport within a profile, an instance can be provided that demonstrates the server's ability to expose data in that form. The theory is that if it can be demonstrated on at least one resource, then that proves that the system supports it.

To generate these specific tests, run bundle exec bin/testscript_generator mustSupport

Process

Relevant Code

Uses the template approach under the templates directory:

Current Status

These tests are a solid work in progress. They will work for many common MustSupport patterns, including choice types, some slices. They don't currently generate tests for complex or nested slices and have trouble with multiple response References and cases where multiple profiles are allowed. In addition, the need to provide a specific instance id for each test means that they aren't currently practical to use. Recently added support for subtest execution in the engine may support completing unimplemented cases and improving the use experience.

Base Search Parameter Tests

Search Parameter tests check that a server supports searching using specific criteria. The tests currently generated focus on cross-resource parameters that can be used on any resource type.

To generate these specific tests, run bundle exec bin/testscript_generator search

Process

Relevant Code

Under the generators directory:

Current Status

These generated tests currently will not execute and represent a rough idea about how search parameters could be tested. Additional work needed to

Interaction Tests

Interaction tests are designed to check whether a server supports the API interactions required by the IG, such as the ability to create, update, read, and search for resource instances.

To generate these specific tests, run bundle exec bin/testscript_generator interaction

Process

Currently, the generator can create two types of TestScripts. The first tests single resource-level interactions on individual resource types (e.g., read an AllergyIntolerance or create a Patient). These tests are known as interaction conformance tests. A second type of tests the generator creates are the basic search parameter tests, which test whether the implementation supports interactions with simple search params (e.g. _id). Both types of tests depend on the Capability Statement being included within the consumed IG.

Relevant Code

Under the testscript_generator directory

Current Status

These generated tests currently will not execute and represent a rough idea about how interactions could be tested. Additional work needed to

Extensions

The TestScript Generator supports several extensions to the TestScript resource that the TestScript Engine also supports. Details on these extensions are their use can be found in this IG. Feedback on the need for and approach to these extensions welcome.

Future Directions

License

Copyright 2022 The MITRE Corporation

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.