Create a Generate Stubs Test Configuration
- Open the Test Configuration dialog by choosing Parasoft> Test Configurations.
- Choose Built-in> Unit Testing and right-click the Generate Stubs configuration.
- Choose Duplicate to copy the configuration to the User-defined category.
- Open the Execution> General tab on the new user-defined configuration and confirm that the Test execution flow field is set to Generate stubs.
- Open the Execution> Symbols tab and confirm the following settings:
- Library Symbols Identification mode is set to Automatic, which is appropriate for most situations.
- Use symbols from additional project files is selected and set to include all project files (Project Scope).
- Use extra symbols from files found in is set to the default location. This will prevent stubs from being recreated. By default, any functionality provided by project object/library files will be used.
- Auto-generated stubs output location is set to ${project} /stubs/autogenerated.
- Enable Stub Callbacks is enabled.
- Rename the configuration Generate Stubs (Project Scope).
- Apply the changes and close the Test Configurations window.
- When running the stub generation configuration, you should select the same test scope that you intend to run unit tests on.
Run the stub generation configuration
- Select ATM.cxx as the test scope.
- Choose Parasoft> Test Using> User-Defined> Generate Stubs (Project Scope).
- Open the Stubs view and note that the original code will be used for all function calls (as seen in the previous exercise), and that no stubs were generated.
Generate Stubs (File Scope vs Project Scope)
If we want to isolate ATM.cxx from the other files in the project for testing, we need to use a configuration setup for File Scope stub generation.
- Open the Test Configurations window and duplicate Built-in> Unit Testing> File Scope> Generate Stubs (File Scope).
- Select the duplicate configuration and choose Execution> Symbols tabs.
- Disable the Use symbols from additional project files setting.
- Apply changes and close the Test Configurations window.
- Select ATM.cxx in the project tree and run the User-Defined> Generate Stubs (File Scope) configuration.
- Click the Stubs tab to view the results.
All symbols are now resolved for file scope testing of ATM.cxx. Original code will be used for all functionality within the ATM.cxx file and auto-generated stubs will be used for all external functionality.