Package org.fhirfrog.frog.shorthand
package org.fhirfrog.frog.shorthand
TestScript Shorthand (TSH) - A concise syntax for authoring FHIR TestScripts.
Overview
This package provides a FHIR Shorthand-inspired domain-specific language for authoring FHIR TestScripts with reduced verbosity (70-80% fewer lines than JSON/XML).
Architecture
The TSH processor uses ANTLR4 for parsing and HAPI FHIR for TestScript generation:
Example TSH Syntax
TestScript: PatientReadTest
Title: "Patient Read Test"
Description: "Test reading a patient resource"
Status: #draft
Url: "http://example.org/TestScript/patient-read"
Setup:
* operation create Patient from "patient.json" as createResponse
* assert responseCode = 201
* variable patientId = Patient.id from createResponse
Test: "Read the created patient"
* operation read Patient/123 as readResponse
* assert responseCode = 200
* assert resource = Patient
Teardown:
* operation delete Patient/123
Usage
Parse TSH files and compile to FHIR TestScript resources:
TSHProcessor processor = new TSHProcessor();
TestScript testScript = processor.parse(Path.of("test.tsh"));
String json = processor.toJson(testScript);
Integration
TSH files are automatically recognized by all FHIR Frog deployment modes:
- CLI:
java -jar fhir-frog-cli.jar test.tsh - Maven:
<testScript>test.tsh</testScript> - Ant:
<fhirtest testScript="test.tsh" />
Grammar
The TSH grammar is defined in ANTLR4 format:
TSH.g4- Parser grammarTSHLexer.g4- Lexer grammar
- See Also:
-
ClassDescriptionThis class provides an empty implementation of
TSHListener, which can be extended to create a listener which only needs to handle a subset of the available methods.This class provides an empty implementation ofTSHVisitor, which can be extended to create a visitor which only needs to handle a subset of the available methods.Compiles TSH AST to FHIR TestScript resources.This interface defines a complete listener for a parse tree produced byTSHParser.Main entry point for parsing TSH files and compiling to FHIR TestScript resources.TSHVisitor<T>This interface defines a complete generic visitor for a parse tree produced byTSHParser.