Refinement Testing
Introduction
A concrete (implemented) component refines an abstract component if the concrete component shows the same behavior as an abstract component.
AF3 provides means for checking the refinement with the help of model based testing. Basically, a test suite is generated based on the abstract
component specification and these tests are then transported to the implementation level and used to check whether the implementation complies
with the abstract specification.
Testing the Refinement
Steps to create a refinement test suite:
- Step 1 - Right click on the concrete component in the model navigator and select "Refinement Specification"
to create a refinement specification for it.
The refinement specification should then automatically be opened.
- Step 2 - In the opened refinement specification click on the "Choose" button and select in the following dialog
the abstract component of which the concrete component should be a refinement.
After choosing the abstract component the representation and interpretation functions for the refinement specification are automatically generated. Their purpose is to specify the mapping of the input and output ports from the abstract to the
concrete component and the other way round (see picture below). If necessary they can transform the values.
- Step 3 Expand the refinement specification in the model navigator to see the functions node. Expand again the functions node to
see the refinement and interpretation functions.
If you double click on the functions node it is opened in the editor and you can see
the input and output ports which the representation and interpretation functions have.
- Step 4 Create a behavior specification (e.g. code specification, automaton specification etc.) for the representation and
interpretation functions, like for a normal component. The behavior of the function should map its input ports to its output ports.
A simple example for such behavior definition is the following code specification, which directly maps Input1 of the abstract component to Input1
of the concrete component.
- Step 4 b Instead of using the abstract input you can also assign random values to certain inputs ports of the concrete component
for which the values cannot be derived from the abstract input. To use random input for one input port check the "Use random value" checkbox for
the port in the refinement specification editor.
Then additional input fields will be shown in which you can specify details for the random value creation.
- Step 5
After specifying all port mappings or setting the input ports to random values you can now test if the concrete component is a correct
refinement of the abstract component. To run the test right click of the refinement specification in the model navigator and select
"Test Refinement".
In the following dialog you have to choose a test suite of the abstract component. The input values of the abstract test suite will be used
as input for the refinement test and the interpreted output will be compared to the output of the abstract test suite.
After choosing the abstract test suite a refinement test suite will be generated:
It shows the test values in the following order: abstract input, concrete input (result of the representation function or random values),
concrete output, abstract output compared with the interpreted output(listed as "simulated value" if different).
If the compared outputs do not match in one test step, it and the parent test case and test suite will be marked with an error symbol.
The test cases in the refinement test suite can be also simulated on the model, like described in "Simulate Test Case".