Specifying Tests with DECOR

Revision as of 17:41, 1 May 2014 by Mdegraauw (talk | contribs) (concept)

Making Test Specifications

DECOR allows the specification and generation of tests for messages and documents specified in DECOR; especially HL7 messages and documents.

Tests are specified by stating a simple condition which a message either conforms to or not. The test tooling can then test whether a message fulfills the test requirements. Test specs require an XML file called {my-project}-tests.xml, which will normally reside in apps/hl7 in eXist. Next we will describe the contents of {my-project}-tests.xml.

Content models are described in the following shorthand: X = {@a, @b?, c+, d*) meaning: element X contains 1 attribute a, optionally an attribute b, one or more elements c and zero or more elements d).

testset

This is the root element. It must contain @name.

<testset name="Colonoscopy report testset">

The content model of testset = {@name, release, test+}.

release

Must contain @uri, which points to an XML transactionDataset (a transaction in a dataset-like view) retrieved with the RetrieveTransaction function. Preferably an archived version from apps/decor/release, which is fulle specified (i.e. all terminologyAssociations present, all concepts linked to templates etc.).

<testset name="Colonoscopy report testset">
<release uri="http://decor.nictiz.nl/decor/services/RetrieveTransaction?id=2.16.840.1.113883.2.4.3.36.77.4.401&amp;language=nl-NL&amp;version=2014-04-25T12:07:09&amp;format=xml"/>

Note:

  • format must be 'xml'
  • it should retrieve a transaction, not a dataset
  • preferably the 'version' query parameter is used.

test

The content model of test = {@id?, @name, @transactionRef, @version?, name+, desc+, suppliedConcepts}

  • @name is the identifier which is used in references
  • @transactionRef must point to a transaction. It is used for retrieval of Xpaths for concepts.

suppliedConcepts

suppliedConcepts = {concept+}

concept

concepts occur in two forms:

concept = {@ref, @multiplicity}

This form will require the concept which @ref points to, to occur in the tested message the number of times @multiplicity states.

<concept multiplicity="2" ref="2.16.840.1.113883.2.4.3.36.77.2.2.125059">
Incident must occur twice.</concept>

This would require the concept with @id '2.16.840.1.113883.2.4.3.36.77.2.2.125059' to occur twice in a tested message. The text in the concept clause is shown if the condition is not met.

concept = {@ref, @occurrence, @assert}

This form is used to require specific values in a concept item in a message.

<concept occurrence="2" assert="@code='9'" ref="2.16.840.1.113883.2.4.3.36.77.2.2.125070">Second incident must be of type "Perforation".</concept>

This would require the second occurrence of the concept with @id '2.16.840.1.113883.2.4.3.36.77.2.2.125070' to contain '9' in @code. The text in the concept clause is shown if the condition is not met. Having the text directly in the tested concept makes the tests readable and maintainable.

Other possibilities would be:

<concept occurrence="1" assert="@value='5'" ...</concept>
<concept occurrence="1" assert="@unit='mg'" ...</concept>
<concept occurrence="2" assert="@code='N01AH01'" ...</concept>

The counting of occurrences is document-wide at the moment.