fhir-crucible / testscript-engine

Ruby FHIR TestScript execution engine
Apache License 2.0
5 stars 2 forks source link
fhir testscript

About the Project

The TestScript Engine is an open source, command-line tool for executing tests described by Fast Healthcare Interoperability Resources (FHIR) TestScript instances. The key goals of the project include:

Running the Engine

There are two methods for running the TestScript Engine:

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

This is the recommended method if you don't have TestScripts of your own, as this repository includes sample TestScripts in the ./TestScripts folder for processing and execution.

First, download the TestScript gem by running: gem install testscript_engine. Then, launch the engine by running: testscript_engine.

This is the recommended method if you already have a collection of your own TestScripts, as it allows you the freedom of running the engine from within your TestScript repository (or anywhere).

Configure the Engine

The engine can be configured through three methods: configuration file, commandline arguments, and interactive mode.

Configuration file

Running the engine on a configuration file provides testing on predefined settings.

bundle exec bin/testscript_engine execute --config [PATH] : Put name and path of a configuration YAML file.

Below are properties in the configuration files.

Commandline Arguments

Command line arguments can be used when you want to run specific files and/or conditions. Run the engine with the following format:

bundle exec bin/testscript_engine execute [OPTIONS]

[OPTIONS]

Interactive mode

Running the engine on interactive mode provides flexibility to change the properties while executing testing. Simply run the command below.

bundle exec bin/testscript_engine interactive

Folders and Files

TestScripts are validated and loaded in by the engine. By default, the engine looks for a ./TestScripts folder in its given context, but will allow the user to specify an alternate path. Once TestScripts are loaded, they are converted into 'runnables'. The engine allows users to specify which runnable to execute, and by default will execute all available runnables. Likewise, the user can specify the endpoint upon which the runnable(s) should be executed. Following execution, the user can either re-execute -- specifying a different runnable or endpoint -- or shut-down the engine. Finally, the results from each runnable's latest execution are written out to a subfolder corresponding to the execution completion time under the ./TestReports folder.

./lib:

./spec:

./TestReports:

./TestScripts:

Features

Assertion

The engine uses various algorithms to evaluate the results of previous operations to determine if the server under test behaves appropriately.

Extension

The TestScript Engine supports several extensions to both the TestScript and TestReport resources. Details on these extensions are their use can be found in this IG. Feedback on the need for and approach to these extensions welcome.

Feedback and Result Interpretation

The value of tests derives from the feedback they provide. The testscript-engine currently provides three mechanisms for feedback:

  1. Terminal output: when running the engine on the command line, details on the execution steps and the results are provided as execution proceeds. This includes a summary at the end of the tests executed, split into passing and failing lists, along with pointers to the TestReport instances and the summary CSV, if configured.
  2. TestReport instances: an instance is generated for each TestScript instance executed, including subtest executions. The result of each action (operation and assertion) taken by the engine is recorded, including error details for those that failed. This means that these instances serve as a permanent record of the execution and can be used after the fact to investigate failures. However, no tools currently exist to help with the inspection of these instances.
  3. Summary CSV: in order to help users navigate the generated TestReport instances in the absence of direct tools, the engine optionally (see the summary_path configuration option) will generate a summary file that can be opened as a spreadsheet for simple interaction and filtering. While it does not contain all details such as the specific errors that caused failures, it provides a flexible and familiar way to navigate and find the TestReport instances that contain this information. Information in the summary CSV includes:
    • name: name of the TestScript instance executed.
    • title: title of the TestScript instance executed, which generally is easier to interpret than the name.
    • result: pass or fail.
    • inputs: list of dynamic variable bindings for the execution. Each entry is of the form [variable-name]=[value]. Entries are separated by ;.
    • subtest?: true if the TestScript was executed as a subtest.
    • mustPass?: true if the TestScript execution had to pass in order for the invoking assertion to pass. If false, then a failure may not be indicative of an actual problem.
    • testReportFilePath: where detailed results in the form of a TestReport instance can be found.

Interpretation Approach

The current best practice for interacting with results based on current functionality is to:

  1. Open the Summary CSV in a spreadsheet application
  2. Sort based on the result column to separate failing tests
  3. Use the name and title columns to identify the specific tests and functionality failing
  4. Prioritize directly-executed tests (subtest? = false) and subtests that were required to pass (mustPass = true) since those that didn't need to pass may not be indicative of problems
  5. Open TestReport instances and search for the string fail to get details on what failed.

Limitations

The TestScript Engine is still in the infancy of its development; it is neither fully complete nor bug-free and we encourage contributions, feedback, and issue-opening from the community. There are known gaps in the TestScript Engine:

References

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.