Structures
Structures, or layouts, in Total Test are descriptions of the data areas passed when calling a test target. This description is in an language-independent format based on XML. This allows you to create tests independent from the programming language of the test target.
In COBOL, these are the USING parameters in the CALL statement of the caller, or the USING parameters of the PROCEDURE DIVISION statement in the called program.
If your COBOL structures include REDEFINES, they are created as overlapping structures and require special attention in the interface usage definition. Refer also to Usage none for more information.
Importing Structures
Before a test interface can be defined, the structures used in the interface must be imported into Total Test.
During the import of a structure, the language specific description of the structure is transformed into the language independent format used in Total Test. The import input may not even be in a programming language format, but can be virtually any format for which an import plug-in is installed.
Currently, a Unit Test Structure from Copybook Import plug-in is included with Total Test. Other import plug-ins can be made available on request.
Unit Test Structure from Copybook Import
You can import COBOL Copybooks using the Import facility.
- Perform one of the following actions:
- Right-click in the Project Explorer and select Import from the context menu
- Select File > Import from the menu.
This opens the import wizard.
- From the list, select Total Test > Unit Test Structure from Copybook, then click Next >.
- This opens the Import Unit Test Structure wizard.
- Now click on the Select button, navigate to the where your copybooks are stored, and select one or more copybooks that you wish to import. If necessary, change the Encoding to match the character encoding used in your copybooks.
- In the middle area, select the structures folder (or a subfolder) of the Total Test project into which you want to import.
By default, the name of the output structure file is derived from the file name of the input copybook. This may optionally be changed. - If the structure files already exist in the project, you must select Overwrite existing structures in order to replace them during the import. This is usually the case, when you re-import copybooks because they have been modified.
- Click Finish.
Create Unit Test Structure from Selection Context Menu
Total Test also provides context menus to import COBOL layouts from these other Workbench for Eclipse programs:
- Workbench for Eclipse Editors
- Host Explorer
- Code debug session
Workbench for Eclipse Editors
When you are editing a COBOL layout or program with one of the Workbench for Eclipse Editors, you can create unit test structures from the selected COBOL layouts.
- Select the COBOL layout(s) in your Edit session, starting with Level 01 and including all of the associated layout elements.
- Right-click in the selected Level 01 data structure of the layout and select
Create Unit Test Structure from Selection... from the context menu.
This opens the Create Structure from Selection wizard with the Structures folder highlighted and the structure name pre-filled as it was derived from the Level 01 description. - If the structure files already exist in the project, you must select Overwrite existing structures in order to replace them during the import. This is usually the case, when you re-import copybooks because they have been modified.
- Click Finish.
Host Explorer
When navigating in the Host Explorer to a COBOL layout member in a z/OS dataset, you can create a unit test structure from the selected layout.
- Select the COBOL layout in your Host Explorer session.
- Right-click the selected layout member and select
Create Unit Test Structure from Copybook... from the context menu.
This opens the Create Structure from Copybook wizard with the Structures folder highlighted and the structure name pre-filled with the member name. - If the structure files already exist in the project, you must select Overwrite existing structures without warning in order to replace them during the import. This is usually the case, when you re-import copybooks because they have been modified.
- Click Finish.
Import Processing in Detail
Usually, it is assumed that each copybook file contains the description of exactly one level 01 data structure. In such a case, one copybook file corresponds to one Total Test structure.
However, if, during import, this is found not to be true, the following actions are taken:
- If a copybook file contains multiple level 01 data structures, the import will automatically create multiple structure files. The file names will be suffixed by a consecutive number.
This does not apply for level 01 REDEFINES structures. - If a copybook file does not contain a level 01 structure at all, a surrounding structure will be automatically created based on the copybook file name.
During import, the following information will be taken from the COBOL copybook:
- Structure names
- Structure alignment
- Attribute names
- Attribute data type (from USAGE clause)
- Attribute default values (from VALUE clause)
REDEFINES structures are recognized, too, creating overlapping structures.
Update Structures
If structures change due to ongoing development or error fixing, these changes must be made available in Total Test, too. Simply re-import the affected structures. Of course, the option Overwrite existing structures in the import wizard must be active.
After that, open the interfaces which use the changed structures, and set default values and usage of any new fields, if applicable.
Thanks to the automatic intelligent migration technique in Total Test, it is not necessary to manually update all test scenarios. Instead, they will be migrated on the fly when they are opened or executed in a test run.
Naturally, if new attributes have been added to a structure, and these new attributes must be provided in an existing scenario, there is no way to avoid a manual update of that test scenario. The same applies if the name of an attribute has changed, so the migration cannot automatically match old name with new name.
Viewing a Structure
The Structure Editor has two tabs that can be selected in the top area of the editor view:
- Edit Parameters to view the type and values of the layout structure.
- Information to display the name of the structure.
Edit Parameters
The Edit Parameters tab of the Structure Editor is used to view the structure definition.
- The Structure column displays the fields of the structure. Use the Expand buttons to expand and collapse the levels.
The following icons identify the structure types:
identifies 01 LEVEL
identifies GROUP
identifies NUMERIC
identifies CHARACTER
identifies REDEFINES
identifies KEYS
identifies ARRAYS
- The Type column displays the data type of the fields.
- The Input Length column displays the maximum input length for the field. To copy the value, right-click on the field and select Copy value.