Stubs
Stubs are very useful for:
- Simulation of programs or functions which are not yet implemented or fully functional
- Isolated unit testing without unwanted side effects from sub-programs
- Emulation of environment data that are costly to establish
- Emulation of error conditions that are too complex to provoke
These problems can be solved by assigning and using stubs in test scenarios. A stub simulates a program call by returning a given set of return values. The actual program is not called, but for the caller, this is transparent which means, it cannot see a difference.
With Total Test, it is not necessary to modify the called program, nor is a special linkage step required. The simulation is performed at runtime. A stub affects those test cases that include it, but will have no effect on other test cases of the test scenario. Optionally, stubs can be switched off during runtime without having to remove them from the test scenario.
Stub Creation During Code Debug Session
When debugging a COBOL Batch program you can request that Total Test automatically create stubs from the captured debug session. For more information, see Context-Menus-from-Code-Debug-Session.
Creating a new Stub
In order to manually create a new test stub, select the project in which you want to create the stub, right- click to open the context menu and select New > Unit Test Stub (or from the File menu, select New > Other > Total Test >
Unit Test Stub). The Test Stub wizard opens. On the first page, enter the following data (obligatory fields listed in bold):
Field | Description |
---|---|
Name | File name for the test stub |
Alias Name | More descriptive name |
Type | Select the stub type, either:
|
Entry Assertion | Check the Entry Assertion checkbox to enable sub-program assertions when Type is Program. Sub-program assertions validate all of the data that is being passed into a sub-program call just like a Write Assertion validates all the data that is passed into a Write I/O call. Useful if I/O is done inside of sub-program and can't be validated by write assertions. |
Subprogram | Specify the name of the sub-program if the Stub Type is program. |
File DD Name | Specify the file name (DD name) of the Read or Write file for the stub. |
Description | Detailed description |
- If you have not selected a Total Test project before invoking the wizard, a list of Total Test projects displays in the Project list at the bottom of the wizard pages. You must select a project to continue to the next wizard page.
- If you have selected an appropriate interface for the stub type before invoking the wizard, this interface will automatically be used for the test stub and you can just click Finish to create the stub.
Click Next > to continue to the next page where you select an interface for the stub. Only interfaces that match the stub type are included in the selection list. Click Finish to create the stub.
Or optionally, click Next > instead to proceed to the final page where you can select another destination folder for the stub and enter another name for the stub.
If there are no interfaces of the appropriate type then you need to create an interface of the correct type in the Total Test project or change to a Total Test project that contains an interface of the correct type.
After completing the wizard, the newly created test stub opens in the Test Stub Editor where you can specify the parameters, or simulation data, to be used by the stub. The name listed in the Parameters tab's Description column for the stub was derived from the interface name.
This section provides information about the following topics: